Skip to content

Instantly share code, notes, and snippets.

@suryastef
Created May 3, 2024 07:23
Show Gist options
  • Select an option

  • Save suryastef/6b1de8432dd4d48d561d0cc75efd5d93 to your computer and use it in GitHub Desktop.

Select an option

Save suryastef/6b1de8432dd4d48d561d0cc75efd5d93 to your computer and use it in GitHub Desktop.
$ # Use Live CD to boot
$ sudo su # Switch to root
$ fdisk -l # Get names of root, boot & EFI partition names. you can also use blkid
$ mount /dev/mapper/fedora_localhost--live-root /mnt # mount root partition
$ cat /mnt/etc/fedora-release
Fedora release 39 (Thirty Nine)
$ mount /dev/nvme0n1p2 /mnt/boot # mount boot partition
$ mount -o rw /dev/nvme0n1p1 /mnt/boot/efi # mount EFI partition, use '-o remount,rw' instead when the system back to RO state
$ ls /mnt/boot/efi # should show all OS names under EFI
$ # mount the virtual filesystems that the system uses to communicate with processes and devices
$ for dir in /dev /proc /sys /run; do mount --bind $dir /mnt/$dir ; done
$ for dir in /dev /proc /sys /run; do mount --bind $dir /mnt/$dir ; done
$ # enter chroot
$ chroot /mnt
$ # Now you can do all the work e.g. fix grub
$ dnf reinstall grub2-efi shim -y
$ grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg # Regenerate grub2
$ # Check BIOS boot details [ Note: this command won't work if you are inside chroot. ]
$ efibootmgr -v
$ reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment