| |

How to Regenerate Grub2 Config Files on Linux

Grub2 config file may need to be re-generated after changing Grub2 configurations such as configuration changes and setting default boot entries. The Grub2’s config file may be at different locations depending on your Linux 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.

The quick way: use the grub2-regen-cfg.bash script

We provide a script grub2-regen-cfg.bash that you can directly use to regenerate the Grub2 config file.

The manual way: step by step

Depending whether your Linux systems 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/.

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:

# cp $grubcfg $grubcfg.bak # make a backup in case bad things happened
# grub2-mkconfig -o $grubcfg

Okay, it is done.

Notes for Ubuntu users

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.

Similar Posts

  • Finding All Available Versions of a Package in Ubuntu

    How to find all available versions of a package in Ubuntu? To list available versions of a package: apt-cache showpkg <package-name> For example, to check all versions of thunderbird: $ sudo apt-cache showpkg thunderbird Package: thunderbird Versions: 1:31.1.1+build1-0ubuntu0.14.04.1 (/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty-updates_main_binary-amd64_Packages) (/var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_trusty-security_main_binary-amd64_Packages) Description Language: File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty_main_binary-amd64_Packages MD5: 68ed1001b79d708ad48956a0c129114d Description Language: en File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_trusty_main_i18n_Translation-en MD5: 68ed1001b79d708ad48956a0c129114d 1:31.0+build1-0ubuntu0.14.04.1 (/var/lib/dpkg/status)…

  • MySQL at Facebook

    Facebook uses lots MySQL databases. Any information about how Facebook scales MySQL? Some information on the Web: MySQL at Facebook’s page https://www.facebook.com/MySQLatFacebook?filter=1 A post by Ryan Thiessen, Database Operations at Facebook on Quora: http://www.quora.com/Facebook-Engineering/How-does-Facebook-structure-MySQL-so-that-it-is-robust-and-scalable And more: http://mashable.com/2011/12/15/facebook-timeline-mysql/ http://gigaom.com/2011/12/06/facebook-shares-some-secrets-on-making-mysql-scale/ http://www.wired.com/wiredenterprise/2011/12/facebook-timeline-anatomy “A lot of people are surprised that for this shiny new thing for Facebook, we’re using…

One Comment

  1. Note that if the /etc/grub2.cfg or /etc/grub2-efi.cfg is not a softlink to the configuration file under /boot/grub2/, you may manually copy the files to the correct location or re-construct the soft link structure.

Leave a Reply

Your email address will not be published. Required fields are marked *