System Crash with message failed to open \efi\redhat\grubx64.efi

Latest response

I am having trouble starting my system. Whenever I try to power it up it fails with this message "failed to open \efi\redhat\grubx64.efi" Believing that this problem is related to grub I tried to rescue the system using a rescue mode from bootable USB drive. I followed the procedure described here (https://access.redhat.com/solutions/1521 - Reinstalling grub2 on to MBR). However, when I tried to install grub2 using the command grub2-install /dev/sda1, I get the following error "cannot find EFI directory". Any suggestions on how to re install grub2 ?

Responses

The file path with the .efi suffix in the error message indicates the system is using UEFI boot scheme instead of the traditional MBR, so the MBR is not currently used at all. The procedure in https://access.redhat.com/solutions/1521 is for the MBR boot scheme only; for UEFI, you'll need https://access.redhat.com/solutions/2933521 instead, although that KB article looks a little bare-bones at the moment.

In UEFI boot scheme, the system disk must have a GPT partition table and an ESP partition on it. The ESP partition is essentially a 0.1-0.5 GB FAT32 filesystem with a specific GPT partition type UUID set on it.

The UEFI firmware contains boot variables that will specify the GPT disk UUID and a pathname for each configured boot loader. You can view and edit these boot variables from within Linux OS - but only if the OS has been booted using an UEFI boot scheme. If a legacy-compatibility boot scheme is used instead, the compatibility module will usually disable access to UEFI boot variables. To view the UEFI boot variables in Linux, you can use this command:

# efibootmgr -v

Other options to the efibootmgr command will allow adding/deleting boot entries, changing boot order, and other functions. Please see "man efibootmgr" for details.

If your bootable USB drive uses a filesystem other than FAT32 and/or does not include a \EFI\BOOT\BOOTx64.efi file, it might be bootable under the legacy MBR boot scheme but not under the UEFI boot scheme. If your USB drive includes that file, it might be bootable under both schemes - and then the BIOS boot menus might include two boot options for the USB drive: one using the MBR scheme and the other using UEFI. If possible, you would want to select the UEFI-style boot entry, in order to allow the grub2-efi installation scripts to have access to UEFI boot variables.

You might also have to mount the ESP partition to the standard location (typically /boot/efi in RedHat, although it might vary on other Linux distributions). With the mount point pathname included, the full path to the boot loader file would be /boot/efi/efi/redhat/grubx64.efi in Linux. Since the FAT32 filesystem is case-insensitive, the character case in the boot file pathname should not matter... but there seems to be some buggy UEFI firmware implementations that are case-sensitive.

I just had the dreaded "\EFI\BOOT\grubx64.efi not found" and "failed to open". Even though I suspect the grub2-install command will be controversial, I ended up running it to fix my system. As the grub2-install command creates a custom grubx64.efi, deletes the original installed one, and looks for grub.cfg in /boot/grub2/, while the grub2-efi package installs a prebaked grubx64.efi on the EFI System partition, which looks for grub.cfg on the ESP in /EFI/redhat/. I believe even though i reinstalled the grub2-efi package it didn't replace it until after I ran the grub2-install (because it installed a different one), as it will only replace files if the are deemed corrupt. It could be that the grub2-install command isn't needed and the grubx64.efi could just be deleted. I didn't do it, and cannot speak to the outcome of just doing it.

- To list network devices
nmicli dev show 

- To turn on network device
nmicli con up {interface}
  • Install additional grub2 module
yum install grub2-efi-modules
  • Find your /boot partition
findfs $(grep "/boot/efi" /etc/fstab | cut -f 1 -d " ")
  • Run /sbin/grub2-install command on the boot partition
/sbin/grub2-install {boot partition above}
  • Reinstall grub-efi and shim packages
yum reinstall grub-efi shim
  • Rebuild grub.cfg
grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
  • Reboot