Fedora grub2 repair for system using UEFI firmware

A long-running server suddenly stopped booting successfully. It started displaying a “grub rescue>” prompt after reboot. My searches suggested this meant grub needed to be reinstalled. This server uses EFI firmware so all the instructions on using “grub2-install” that I found everywhere are moot. After a couple of days of searching, this is the procedure I found that is supposed to work on a system with EFI firmware. Unfortunately, after doing this, I continued to get boot rescue> prompts after rebooting.

  1. Boot a Fedora Live image from USB being sure to select the UEFI boot device listing for it in the BIOS boot menu.
  2. Open a terminal window and do:
    sudo su -
    mkdir /mnt/root
  3. The root filesystem is on an LVM partition on this server, so activate all the LVMs on the system:
    vgchange -a y
  4. mount /dev/mapper/fedora_fedora-root /mnt/root
  5. Examine /mnt/root/etc/fstab to figure out which partitions should be mounted where. The lsblk -o name,size,mountpoint,uuid command can help map physical devices to fstab entries that identify partitions by their UUID.
    mount /dev/sda2 /mnt/root/boot
    mount /dev/sda1 /mnt/root/boot/efi
  6. Mount all the system partitions:
    mount -o bind /dev /mnt/root/dev
    mount -o bind /proc /mnt/root/proc
    mount -o bind /sys /mnt/root/sys
    mount -o bind /run /mnt/root/run
    mount -o bind /sys/firmware/efi/efivars /mnt/root/sys/firmware/efi/efivars
  7. chroot /mnt/root /bin/bash
  8. dnf reinstall shim-* grub2-*
  9. grub2-mkconfig -o /boot/grub2/grub.cfg

dlk

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.