Chapter 9. Reinstalling GRUB
You can reinstall the GRUB boot loader to fix certain problems, usually caused by an incorrect installation of GRUB, missing files, or a broken system. You can resolve these issues by restoring the missing files and updating the boot information.
Reasons to reinstall GRUB:
- Upgrading the GRUB boot loader packages.
- Adding the boot information to another drive.
- The user requires the GRUB boot loader to control installed operating systems. However, some operating systems are installed with their own boot loaders 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 Copy linkLink copied to clipboard!
You can reinstall the GRUB boot loader on your BIOS-based system. Always reinstall GRUB after updating the GRUB packages.
This overwrites the existing GRUB to install the new GRUB. Ensure that the system does not cause data corruption or boot crash during the installation.
Procedure
Reinstall GRUB on the device where it is installed. For example, if
sdais your device:grub2-install /dev/sda
# grub2-install /dev/sdaCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reboot your system for the changes to take effect:
reboot
# rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow
9.2. Reinstalling GRUB on UEFI-based machines Copy linkLink copied to clipboard!
You can reinstall the GRUB boot loader on your UEFI-based system.
Ensure that the system does not cause data corruption or boot crash during the installation.
Procedure
Reinstall the
grub2-efiandshimboot loader files:yum reinstall grub2-efi shim
# yum reinstall grub2-efi shimCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reboot your system for the changes to take effect:
reboot
# rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow
9.3. Reinstalling GRUB on IBM Power machines Copy linkLink copied to clipboard!
You can reinstall the GRUB boot loader on the Power PC Reference Platform (PReP) boot partition of your IBM Power system. Always reinstall GRUB after updating the GRUB packages.
This overwrites the existing GRUB to install the new GRUB. Ensure that the system does not cause data corruption or boot crash during the installation.
Procedure
Determine the disk partition that stores GRUB:
bootlist -m normal -o
# bootlist -m normal -o sda1Copy to Clipboard Copied! Toggle word wrap Toggle overflow Reinstall GRUB on the disk partition:
grub2-install partition
# grub2-install partitionCopy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
partitionwith the identified GRUB partition, such as/dev/sda1.Reboot your system for the changes to take effect:
reboot
# rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow
9.4. Resetting GRUB Copy linkLink copied to clipboard!
Resetting GRUB completely removes all GRUB configuration files and system settings, and reinstalls the boot loader. You can reset all the configuration settings to their default values, and therefore fix failures caused by corrupted files and invalid configuration.
The following procedure will remove all the customization made by the user.
Procedure
Remove the configuration files:
rm /etc/grub.d/* rm /etc/sysconfig/grub
# rm /etc/grub.d/* # rm /etc/sysconfig/grubCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reinstall packages.
On BIOS-based machines:
yum reinstall grub2-tools
# yum reinstall grub2-toolsCopy to Clipboard Copied! Toggle word wrap Toggle overflow On UEFI-based machines:
yum reinstall grub2-efi shim grub2-tools grub2-common
# yum reinstall grub2-efi shim grub2-tools grub2-commonCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Rebuild the
grub.cfgfile for the changes to take effect.On BIOS-based machines:
grub2-mkconfig -o /boot/grub2/grub.cfg
# grub2-mkconfig -o /boot/grub2/grub.cfgCopy to Clipboard Copied! Toggle word wrap Toggle overflow On UEFI-based machines:
grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfgCopy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Follow Reinstalling GRUB procedure to restore GRUB on the
/boot/partition.