如何在 Arch Linux 和衍生产品(Manjaro、BlackArch)中更新 GRUB 引导加载程序如何在 Arch Linux 和衍生产品(Manjaro、BlackArch)中更新 GRUB 引导加载程序如何在 Arch Linux 和衍生产品(Manjaro、BlackArch)中更新 GRUB 引导加载程序如何在 Arch Linux 和衍生产品(Manjaro、BlackArch)中更新 GRUB 引导加载程序
  • 文章
  • 正则表达式
    • 工具
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容
发表 admin at 2025年2月28日
类别
  • 未分类
标签

如何在 Arch Linux 和衍生产品(Manjaro、BlackArch)中更新 GRUB 引导加载程序

GRUB 操作系统加载器像任何其他软件包一样在 Linux 上安装和更新。但是 bootloader 的特殊之处在于,即使在更新包之后,位于沿 /boot/grub/ 路径挂载的分区上的 bootloader 的实际工作文件也不会自动更新。

也就是说,当发布新版本的 GRUB 时,操作系统中的软件包会自动更新。

但是安装在单独的磁盘分区上并沿 /boot/grub/ 路径安装的引导加载程序本身不会更新。

要开始使用新版本 GRUB 中添加的新功能,您需要手动更新引导加载程序。

何时更新 /boot/grub/ 中的 GRUB 引导装载程序

新版本 GRUB 已发布的信号类似于以下消息:


(3/4) upgrading grub                               [######################] 100%
:: To use the new features provided in this GRUB update, it is recommended
   to install it to the MBR or UEFI. Due to potential configuration
   incompatibilities, it is advised to run both, installation and generation
   of configuration:
     $ grub-install ...
     $ grub-mkconfig -o /boot/grub/grub.cfg

此消息表示,为了使用此 GRUB 更新中引入的新功能,建议将其安装在 MBR 或 UEFI 中。由于潜在的配置不兼容,建议您同时执行安装和配置创建。并给出了模范命令。

也就是说,如果您看到此消息,那么您需要更新 /boot/grub/ 中的引导加载程序。

如何检查操作系统是否正在使用 GRUB

在 Arch Linux 和衍生发行版上,GRUB 包可以安装但不能使用,因为引导加载程序是 systemd-boot。

要验证 GRUB 是引导加载程序,请运行以下命令:


ls -l /boot/grub/grub.cfg

如果找到 /boot/grub/grub.cfg 文件,则说明正在使用 GRUB,如果未找到 grub.cfg 文件,则说明未使用 GRUB,无需更新。也就是说,您不需要按照本文中显示的步骤操作!

详见文章:如何检查电脑使用的是BIOS还是UEFI; GRUB 或 systemd-boot 引导程序; MBR 或 GPT 分区表

如何更新 /boot/grub/ 中的 GRUB 引导装载程序

要更新引导加载程序,您需要运行如下命令:


grub-install --recheck /dev/DISK

其中 /dev/DISK 应该是您的驱动器的名称。

可以使用以下命令检查驱动器名称:


fdisk -l

示例输出:


Disk /dev/vda: 30 GiB, 32212254720 bytes, 62914560 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x4b23ea92

Device     Boot  Start      End  Sectors  Size Id Type
/dev/vda1  *      2048   411647   409600  200M 83 Linux
/dev/vda2       411648 62914559 62502912 29.8G 83 Linux

在这种情况下,驱动器名称是 /dev/vda。请注意,/dev/vda 不是引导分区或其他分区——它是整个驱动器。

因此,在我的例子中,更新 /boot/grub/ 中的 GRUB 的命令如下:


grub-install --recheck /dev/vda

您还需要使用以下命令创建一个新的配置文件:


grub-mkconfig -o /boot/grub/grub.cfg

示例输出:


Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
Found fallback initrd image(s) in /boot:  initramfs-linux-fallback.img
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done

GRUB 引导装载程序更新和 GRUB 配置更新已成功完成。下次启动时,您的操作系统将使用 GRUB 更新添加的新功能。

©2015-2025 艾丽卡 support@alaica.com