Red Hat Training
A Red Hat training course is available for RHEL 8
Chapter 9. Reinstalling GRUB
Reinstalling GRUB bootloader is a convenient way to fix certain problems usually caused by an incorrect installation of GRUB, missing files, or a broken system. You can resolve this issue by restoring the missing files and updating the boot information.
The following are the reasons to reinstall GRUB:
- Upgrading GRUB bootloader.
- Adding the boot information to another drive.
- The user requires the GRUB bootloader to control installed operating systems. However, some operating systems are installed with their own bootloaders and reinstalling GRUB returns control to the desired operating system.
GRUB restores files only if they are not corrupted.
9.1. Reinstalling GRUB on BIOS-based machines
You can reinstall GRUB using the grub2-install
command.
When you run the grub2-install
command on an existing boot device, it overrides the existing GRUB to install the new GRUB. Hence, ensure that the system does not cause data corruption or boot crash during the installation before issuing the grub2-install
command.
Procedure
Issue the
grub2-install
command with the device argument. For example, ifsda
is your device:# grub2-install /dev/sda
Reboot your system for the changes to take effect.
# reboot
Additional resources
-
the
grub-install(1)
man page
9.2. Reinstalling GRUB on UEFI-based machines
You can reinstall GRUB using the yum reinstall
command.
Ensure that the system does not cause data corruption or boot crash during the installation before issuing the yum reinstall
command.
Procedure
Enter the
yum reinstall
command with thegrub2-efi
andshim
bootloader files.# yum reinstall grub2-efi shim
Reboot your system for the changes to take effect.
# reboot
9.3. Resetting GRUB
Resetting GRUB completely removes all GRUB configuration files and system settings and reinstalls the bootloader. You can reset all the configuration settings to their default values, and thus fix failures caused by corrupted files and incorrect configuration.
The following procedure will remove all the customization the user has made.
Procedure
Remove the configuration files.
# rm /etc/grub.d/* # rm /etc/sysconfig/grub
Reinstall packages.
On BIOS-based machines, enter:
# yum reinstall grub2-tools
On UEFI-based machines, enter:
# yum reinstall grub2-efi shim grub2-tools
Rebuild the
grub.cfg
file for the changes to take effect.On BIOS-based machines, enter:
# grub2-mkconfig -o /boot/grub2/grub.cfg
On UEFI-based machines, enter:
# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
-
Follow Reinstalling GRUB procedure to restore GRUB on the
/boot/
partition.