Create new Fedora in EFI from scratch

I installed Fedora Silverblue on an SD card, but that overwrote my main Fedora 36 installation on the EFI. How do I get the files that are supposed to be in EFI/fedora and restore them? I’m currently booting into Ubuntu and unable to boot Fedora manually using Grub, so I can’t use anything from within the Fedora installation I wish to restore. Please help.


You could try to mount the fedora partitions and chroot in the fedora installation.

The first thing would be to boot in a livecd, look up for fedora partitions using the sudo fdisk -l command, and mount them somewhat like this:

sudo mkdir /media/fedore # create directory for mount point
sudo mount /dev/sdX3 /media/fedora #mount the root partition
cd /media/fedora
# mount the temporary API filesystems and tmp
sudo mount -t proc /proc proc
sudo mount --rbind /sys sys
sudo mount --make-rslave sys
sudo mount --rbind /dev dev
sudo mount --make-rslave dev
sudo mount -t tmpfs tmpfs tmp
#mount boot and boot/efi
sudo mount /dev/sdX2 boot
sudo mount /dev/sdX1 boot/efi

After these steps you should be able to chroot in the fedora installation
sudo chroot /media/fedora

Now you can attempt to restore grub by reinstalling it and generating a new configuration:

dnf reinstall grub2-efi shim -y
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
exit #exit chroot

Check for boot details using efibootmgr -v, create new boot entry if needed. If you can access the grub menu, it’s probably not a necessary step.

sudo efibootmgr -c -d /dev/sdX1 -p 1 -L Fedora -l '\EFI\fedora\grubx64.efi' # or shimx64.efi
# If required, copy grubx64.efi from Live USB
sudo cp -p /boot/efi/EFI/grubx64.efi /media/fedora/boot/efi/EFI/fedora

Hope it helps.

Before I mess something up again, do I do the cp to the boot in Fedora, or do I put it in the partition where the eFI stuff was located?

Where the EFI stuff located, there should be the fedora directory

I had to cd into /media/fedora/boot, but now the DNS is apparently not working and get a no such file or directory when I try to edit /etc/resolv.conf (both in and outside of the chrooted state)

Nevermind it’s a symlink error I think I can fix it

Yes, resolv.conf supposed to be linked to systemd-resolved stub, but since resolved is not running in chroot, it gives such error. You might want to copy /etc/resolv.conf from live to the chroot environment to get DNS working or temporarily create a new one with nameserver or something

grub2-mkconfig gives me an error: cannot find a device for / (is /dev mounted?).

Are the api filesystems mounted to /media/fedora? Maybe you accidentally mounted them to /media/fedora/boot or somewhere else.

When I mount, I have a root and home folder in media/fedora. I did everything in root because that’s where dev and all the other things were

I managed to get it to boot by just copying the files in /boot in the live media and then using efibootmgr to register it, because my previous grub config was left untouched. Thank you so much for your help!! :smiling_face_with_tear:

1 Like