25.7. Reinstalling GRUB 2

Reinstalling GRUB 2 is a convenient way to fix certain problems usually caused by an incorrect installation of GRUB 2, missing files, or a broken system. Other reasons to reinstall GRUB 2 include the following:
  • Upgrading from the previous version of GRUB.
  • The user requires the GRUB 2 boot loader to control installed operating systems. However, some operating systems are installed with their own boot loaders. Reinstalling GRUB 2 returns control to the desired operating system.
  • Adding the boot information to another drive.

25.7.1. Reinstalling GRUB 2 on BIOS-Based Machines

When using the grub2-install command, the boot information is updated and missing files are restored. Note that the files are restored only if they are not corrupted.
Use the grub2-install device command to reinstall GRUB 2 if the system is operating normally. For example, if sda is your device:
~]# grub2-install /dev/sda

25.7.2. Reinstalling GRUB 2 on UEFI-Based Machines

When using the yum reinstall grub2-efi shim command, the boot information is updated and missing files are restored. Note that the files are restored only if they are not corrupted.
Use the yum reinstall grub2-efi shim command to reinstall GRUB 2 if the system is operating normally. For example:
~]# yum reinstall grub2-efi shim

25.7.3. Resetting and Reinstalling GRUB 2

This method completely removes all GRUB 2 configuration files and system settings. Apply this method to reset all configuration settings to their default values. Removing of the configuration files and subsequent reinstalling of GRUB 2 fixes failures caused by corrupted files and incorrect configuration. To do so, as root, follow these steps:
  1. Run the rm /etc/grub.d/* command;
  2. Run the rm /etc/sysconfig/grub command;
  3. For EFI systems only, run the following command:
    ~]# yum reinstall grub2-efi shim grub2-tools
  4. For BIOS and EFI systems, run this command:
    ~]# yum reinstall grub2-tools
  5. Rebuild the grub.cfg file by running the grub2-mkconfig -o command as follows:
    • On BIOS-based machines, issue the following command as root:
      ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
    • On UEFI-based machines, issue the following command as root:
      ~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
  6. Now follow the procedure in Section 25.7, “Reinstalling GRUB 2” to restore GRUB 2 on the /boot/ partition.