Site icon UnixArena

RHEL7/CentOS 7 – Recover/Reinstall GRUB2 with UEFI

UEFI - GRUB2 Recovery

UEFI - GRUB2 Recovery

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.

UEFI – GRUB Corrupted

 

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.

Rescue a Red Hat Enterprise Linux

 

3. Select Continue to mount the image under /mnt/sysimage.

Continue – Rescue Mode – RHEL

 

4. chroot to the OS image.

chroot to OS Image – RHEL

 

5. Tried to list the EFI contents from the boot partition.  Here, efi directory looks empty.

List the EFI directory contents

 

6. Let’s restore the GRUB2 by re-installing grub2-efi and shim packages.

Reinstall grub2-efi and shim

 

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.

efi directory restored – GRUB2

 

8. Regenerate the grub.cfg file.

Restore grub.cfg

 

9. If SELINUX is enabled on the system, please create the “autorelabel” file.

SeLinux- Autorelabel

 

10. Exit from chroot and reboot the system.

Exit mobile version