This article will provide the step by step procedure to recover the GRUB RHEL7 / CentOS7 which uses UEFI. In last article, we have demonstrated the BIOS-based system’s GRUB recovery. The newer system ships with UEFI firmware and here is the way to identify BIOS vs UEFI on Linux servers. To recover GRUB2 on RHEL7 /CentOS 7 with UEFI, you must have the latest DVD or ISO image to boot the system in rescue mode.
When the EFI based VM or Server is not booting in hard drive, you will get below message or it will be stuck in GRUB.
Reinstalling grub2 on UEFI-based machines:
1. Boot the system using RHEL/CentOS latest DVD.
2. Once the system is booted from DVD, select “Troubleshooting” – > Select Rescue a Redhat Enterprise Linux.
3. Select Continue to mount the image under /mnt/sysimage.
4. chroot to the OS image.
5. Tried to list the EFI contents from the boot partition. Here, efi directory looks empty.
6. Let’s restore the GRUB2 by re-installing grub2-efi and shim packages.
In Rescue mode, your system may not be able to communicate with the network. You could quickly configure local repo using the booted DVD like below if you need repo.
- mount the DVD and configure REPO
7. Once the packages are reinstalled, please navigate to the “efi” directory and check it’s content.
8. Regenerate the grub.cfg file.
9. If SELINUX is enabled on the system, please create the “autorelabel” file.
10. Exit from chroot and reboot the system.