如何更新 grub
Ubuntu 和很多其它的 Linux 发行版提供一个易使用的称为 update-grub
命令行实用程序。
为更新 grub ,你所要的全部工作就是使用 sudo
在终端中运行这个命令。
sudo update-grub
你应该看到一个像这样的输出:
[email protected]:~$ sudo update-grub
[sudo] password for abhishek:
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.0.0-37-generic
Found initrd image: /boot/initrd.img-5.0.0-37-generic
Found linux image: /boot/vmlinuz-5.0.0-36-generic
Found initrd image: /boot/initrd.img-5.0.0-36-generic
Found linux image: /boot/vmlinuz-5.0.0-31-generic
Found initrd image: /boot/initrd.img-5.0.0-31-generic
Found Ubuntu 19.10 (19.10) on /dev/sda4
Found MX 19 patito feo (19) on /dev/sdb1
Adding boot menu entry for EFI firmware configuration
done
你可能看到一个类似的称为 update-grub2
的命令。不需要在 update-grub
和 update-grub2
之间感到害怕或不知所措。这两个命令执行相同的动作。
大约在 10 年前,当 grub2 刚刚被引进时,update-grub2
命令也被引进。现在,update-grub2
只是一个链接到 update-grub
的符号,它们都更新 grub2 配置(因为 grub2 是默认的)。
不能找到 update-grub 命令?这里是在这种情况下该做什么
它可能是,你的 Linux 发行版可能没有可用的 update-grub
命令。
在这种情况下你该做什么?你如何在这样一个 Linux 发行版上更新 grub ?
在这里不需要惊慌。update-grub
命令只是一个入口,用于运行 grub-mkconfig -o /boot/grub/grub.cfg
来生成 grub2 配置文件。
这意味着你可以在任意 Linux 发行版上使用下面的命令更新 grub :
sudo grub-mkconfig -o /boot/grub/grub.cfg
当然,记住 update-grub
命令比上面的命令容易很多,这是为什么它在一开始被创建的原因。