本文共 2130 字,大约阅读时间需要 7 分钟。
grub生成配置文件
config file may need to be re-generated after changing Grub2 configurations such as and . The Grub2’s config file may be at different locations depending on your distro and whether your Linux is booted in BIOS or UEFI mode. This makes regenerating Grub2 config file not easy for Linux users especially beginners. In this post, I will introduce a way that should be portable and easy to use. This method is tested on Fedora and will likely work on RHEL / CentOS / Scientific Linux . For Ubuntu users, please check the “Notes for Ubuntu users” at the end.
更改Grub2配置(例如和后,可能需要重新生成配置文件。 Grub2的配置文件可能位于不同的位置,具体取决于您的发行版以及Linux是以BIOS还是UEFI模式启动。 这使得Linux用户(尤其是初学者)不容易重新生成Grub2配置文件。 在这篇文章中,我将介绍一种应该可移植且易于使用的方法。 该方法已在Fedora上进行了测试,可能会在RHEL / CentOS / Scientific Linux上工作。 对于Ubuntu用户,请最后查看“ Ubuntu用户注意事项”。
We provide a script that you can directly use to regenerate the Grub2 config file.
我们提供了脚本 ,您可以直接使用该脚本来重新生成Grub2配置文件。
Depending whether your Linux is under BIOS or UEFI mode, we choose different config file locations. The files under /etc/
is the most portable location as far as I know as some Linux distros may change the default location that grub2 choose to store the config files under /boot/.
根据您的Linux 是BIOS还是UEFI模式,我们选择不同的配置文件位置。 据我所知, /etc/
下的文件是最可移植的位置,因为某些Linux发行版可能会更改grub2选择将配置文件存储在/ boot /下的默认位置。
if [ -d /sys/firmware/efi ]; then grubcfg="/etc/grub2-efi.cfg"else grubcfg="/etc/grub2.cfg"fi
After choosing the correct location of the grub2 config file and store it in $grubcfg
, we can re-generate the config file by:
选择正确的grub2配置文件位置并将其存储在$grubcfg
,我们可以通过以下方法重新生成配置文件:
# cp $grubcfg $grubcfg.bak # make a backup in case bad things happened# grub2-mkconfig -o $grubcfg
Okay, it is done.
好的,完成了。
Ubuntu and its derived distros have a useful script named update-grub
and you can use it to update your grub configuration file by running sudo update-grub
.
Ubuntu及其衍生发行版有一个名为update-grub
的有用脚本,您可以通过运行sudo update-grub
来使用它来更新grub配置文件。
翻译自:
grub生成配置文件
转载地址:http://tzlwd.baihongyu.com/