Ben Stienstra

Linux, Unix, network, radio and more...

User Tools

Site Tools


reinstall_grub2_efi_fedora

Fedora - reinstall / fix grub2 UEFI

Some hints to fix booting your favourite OS. Tested with Fedora 25 and Windows 10.

Fedora

  • Boot from live USB
  • Switch to root and mount the needed filesystems:
    sudo -i
    
    mkdir -p /mnt/sysimage
    mount /dev/fedora/root /mnt/sysimage
    
    mount --bind /dev /mnt/sysimage/dev
    mount --bind /run /mnt/sysimage/run
    mount -t devpts pts /mnt/sysimage/dev/pts
    mount -t proc proc /mnt/sysimage/proc
    mount -t sysfs sys /mnt/sysimage/sys 
    
    modprobe efivarfs
    mount -t efivarfs efivarfs /mnt/sysimage/sys/firmware/efi/efivars
  • Copy the resolv.conf to have some networking in the chroot:
    mkdir -p /mnt/sysimage/var/run/NetworkManager
    cp /var/run/NetworkManager/resolv.conf /mnt/sysimage/var/run/NetworkManager
  • Enter the chroot and mount /boot and /boot/efi filesystems:
    chroot /mnt/sysimage
    
    mount /boot
    mount /boot/efi
  • Reinstall grub2:
    dnf -y reinstall grub2 grub2-efi grub2-efi-modules shim
    grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
  • Check if entry exists in EFI menu:
    efibootmgr
  • Add entry if it is missing:
    grep efibootmgr /var/log/anaconda/program.log 
    22:47:35,458 INFO program: Running... efibootmgr
    22:47:35,477 INFO program: Running... efibootmgr -c -w -L Fedora -d /dev/nvme0n1 -p 2 -l \EFI\fedora\shim.efi
    
    #Run the command found above:
    efibootmgr -c -w -L Fedora -d /dev/nvme0n1 -p 2 -l '\EFI\fedora\shim.efi'
  • (optional) Add another OS for example:
    efibootmgr -c -w -L Windows -d /dev/nvme0n1 -p 2 -l '\EFI\Microsoft\Boot\bootmgfw.efi'
  • (optional) Change the boot order:
    efibootmgr -o 1,0
  • (optional) Delete entry:
    efibootmgr -b 0 -B
  • (optional) Change timeout:
    efibootmgr -t 2
  • Unmount filesystems and reboot:
    umount /boot/efi
    umount /boot
    exit
    umount /mnt/sysimage/sys/firmware/efi/efivars
    umount /mnt/sysimage/sys
    umount /mnt/sysimage/run
    umount /mnt/sysimage/proc
    umount /mnt/sysimage/dev/pts
    umount /mnt/sysimage/dev
    umount /mnt/sysimage
    
    reboot

Windows 10

  • Modify the path for the Windows boot manager to Fedora:
    bcdedit /set {bootmgr} path \EFI\fedora\shim.efi
  • Alternatively you can use EasyUEFI to edit the entries.
reinstall_grub2_efi_fedora.txt · Last modified: 2017/04/19 20:26 by admin