Skip to content

Instantly share code, notes, and snippets.

@elivlo
Last active September 14, 2022 18:38
Show Gist options
  • Save elivlo/27369d4fcc292ce603a2e99a372bc6ef to your computer and use it in GitHub Desktop.
Save elivlo/27369d4fcc292ce603a2e99a372bc6ef to your computer and use it in GitHub Desktop.
Fix grub2 EFI bootloader config in live cd image if removed by accident
# https://docs.fedoraproject.org/en-US/quick-docs/bootloading-with-grub2/#restoring-bootloader-using-live-disk
# https://docs.fedoraproject.org/en-US/quick-docs/bootloading-with-grub2/#adding-other-operating-systems-grub2
# Download fedora image and boot to live mode
sudo mkdir -p /mnt/root
sudo mount /dev/nvme1n1p3 -o subvol=root /mnt/root
sudo mount /dev/nvme1n1p2 /mnt/root/boot/
sudo mount /dev/nvme1n1p1 /mnt/root/boot/efi
sudo mount -o bind /dev /mnt/root/dev
sudo mount -o bind /proc /mnt/root/proc
sudo mount -o bind /sys /mnt/root/sys
sudo mount -o bind /run /mnt/root/run
modprobe efivarfs
sudo chroot /mnt/root
mount -t efivarfs efivarfs /sys/firmware/efi/efivars
sudo dnf instsall grub2-efi-x64-modules
sudo dnf reinstall shim-* grub2-*
sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
shutdown # Reboot with new config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment