Chapter 13. 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 those operating systems.
GRUB restores files only if they are not corrupted.
13.1. Reinstalling GRUB on BIOS-based machines
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
Install
grub2-pc
:grub2-pc
# grub2-pc
Copy to Clipboard Copied! Reinstall GRUB on the device where it is installed. For example, if
sda
is your device:grub2-install /dev/sda
# grub2-install /dev/sda
Copy to Clipboard Copied! Reboot your system for the changes to take effect:
reboot
# reboot
Copy to Clipboard Copied!
13.2. Reinstalling GRUB on UEFI-based machines
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-efi
andshim
boot loader files:dnf reinstall grub2-efi-x64 shim
# dnf reinstall grub2-efi-x64 shim
Copy to Clipboard Copied! Reboot your system for the changes to take effect:
reboot
# reboot
Copy to Clipboard Copied!
13.3. Reinstalling GRUB on IBM Power machines
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
List the disk partition that stores GRUB:
bootlist -m normal -o
# bootlist -m normal -o sda1
Copy to Clipboard Copied! Reinstall GRUB on the disk partition:
grub2-install partition
# grub2-install partition
Copy to Clipboard Copied! Replace
partition
with the identified GRUB partition, such as/dev/sda1
.Reboot your system for the changes to take effect:
reboot
# reboot
Copy to Clipboard Copied!
13.4. Resetting GRUB
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/grub
Copy to Clipboard Copied! Reinstall packages.
On BIOS-based machines:
dnf reinstall grub2-pc grub2-tools
# dnf reinstall grub2-pc grub2-tools
Copy to Clipboard Copied! On UEFI-based machines:
dnf reinstall grub2-efi shim grub2-tools grub2-common
# dnf reinstall grub2-efi shim grub2-tools grub2-common
Copy to Clipboard Copied!
Rebuild the
grub.cfg
file for the changes to take effect:grub2-mkconfig -o /boot/grub2/grub.cfg
# grub2-mkconfig -o /boot/grub2/grub.cfg
Copy to Clipboard Copied! This applies to both, BIOS and UEFI based systems.
WarningThe path to rebuild
grub.cfg
is same for both BIOS and UEFI based machines. Actualgrub.cfg
is present at BIOS path only. The UEFI path has a stub file that must not be modified or recreated usinggrub2-mkconfig
command.-
Follow Reinstalling GRUB procedure to restore GRUB on the
/boot/
partition.