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.
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.
sherif says
if i booted from live cd you mount : as mount /dev/cdrom /mnt
but how to do so if i booted from a bootable device usb.
Marco says
Tnx for the Guide! Really helped me!
Rich says
Didn’t work for me. The grub.cfg file was installed properly, but there has never been a /usr/lib/grub/x86_64-efi directory.
grub2-install warnings:
this GPT partition label contains no BIOS Boot Partition: embedding won’t be possible
Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged…
error: will not proceed with blocklists
Rich says
I have to add this feedback for grub2-install:
Installing for i386-pc platform.
Chris says
Does your article assume there is already a /boot/efi partition available?
How can I do this when the /boot and /boot/efi partitions were on a separate disk which failed?
I add a new replacement disk /dev/sda. Should I partition this first? Or can I run grub2-install /dev/sda and resolve the efi issue afterwards? If so, how?
Lingeswaran R says
This article talks about fixing the corruption (which means partition already exists). If you wanna install grub on a new disk, you must create the required partition first before running the command.
Lingesh
David Morgan says
I am forever grateful and indebted to you. Thanks so much