How I reinstalled a deleted Boot Item and EFI file deletion Fedora

User discussion and information resource forum for BootIt Bare Metal and BootIt UEFI
Post Reply
Gary Seven
Posts: 61
Joined: Mon Sep 05, 2011 2:17 pm
Location: Tarragona, Spain

How I reinstalled a deleted Boot Item and EFI file deletion Fedora

Post by Gary Seven »

Recently I posted about accidentally deleting the "DEFAULT.BUM" file associated with BootIt's boot menu, which of course erased all my boot items along with the EFI boot files/entries. I had a backup of the EFI partition and was able to restore most of my entries, except for my Fedora 36 installation which I installed much later but never made another ESP backup...my bad.

I posted my dilemma here on the Terabyte forum looking for a solution but there was none, probably because my issue was rather rare. After several days of Googling possible solutions and visits to countless forums, the Fedora Docs, and the UEFI official docs themselves, I ran across a rather obscure post on a very similar situation to mine (except this dev was NOT using a TeraByte product) that led me down the road of success in solving my issue. It was much more complex than I had imagined, so I post it here in hopes that it may help out another user of TeraByte's BIU software.
-----------------------------------------------------------------------------------------------------------
Link to the original web page: https://wiki.polaire.nl/doku.php?id=rei ... uwiki__top

Very important to note that I booted from the Fedora 36 live iso, following the Terabyte instructions to reboot once inside the BootIt environment and then allow BIOS to boot the Live Iso USB drive.

I will insert my own comments with [] between the authors original comments for clarity:
-----------------------
Fedora - reinstall / fix grub2 UEFI

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

Part 1:
Boot from live USB
Switch to root and mount the needed filesystems:

sudo -i

mkdir -p /mnt/sysimage
mount /dev/fedora/root /mnt/sysimage

[note: what he means here is mount your disk/partition that leads to the root partition of your original Fedora installation. In my case, that was /dev/sdb2. So for me it was "mount /dev/sdb2 /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

Part 2:
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

Part 3:
Enter the chroot and mount /boot and /boot/efi filesystems:

chroot /mnt/sysimage

mount /boot
mount /boot/efi
[note: I was only able to mount /boot/efi because things have changed since this guide was written]

Part 4:
Reinstall grub2:
dnf -y reinstall grub2 grub2-efi grub2-efi-modules shim

then do first: grub2-mkconfig -o /boot/grub2/grub.cfg
and second: grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

Part 5:
Check if entry exists in EFI menu: [note: this is NOT related to the Terabyte Boot Item information]
efibootmgr

[note: this command did NOT produce an expected entry. So I continued with the instructions.]

Part 6:
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
[note: this was the output of the author after running the aforementioned GREP command. I ran the command and saw NO output at all]

#Run the command found above:
efibootmgr -c -w -L Fedora -d /dev/nvme0n1 -p 2 -l '\EFI\fedora\shim.efi'

[note: the author used "efibootmgr" to generate a new EFI entry based on what the output of the previous GREP command gave him. I saw no output so based my command line entry on where my ESP was located (/dev/sda2 in my case). So my command line entry to generate a new EFI entry was as follows: efibootmgr -c -w -L Fedora36 -d /dev/sda -p 2 -l '\EFI\fedora\shim.efi'
Notice the command contains both forward AND backwards slashes!]

Part 7:
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
--------------------------------------------------------------------

Upon reboot and entering back in to my BIU menu, my Fedora entry was back. A lot of freakin work if you ask me. I must add that it would have probably been easier to just reinstall F36 new from the iso, but I had a few items in my Home directory I wanted, plus I had my Cinnamon DE highly configured and customized (just not backed up for cryin out loud!).

I hope this helps someone in the future. Honestly, this would have been much easier with either an Arch or Debian installation, but it is what it is. ;)
Ouahibh
Posts: 1
Joined: Fri Sep 23, 2022 10:28 am

Re: How I reinstalled a deleted Boot Item and EFI file deletion Fedora

Post by Ouahibh »

Hi Gary Seven, I highly need help;
I have Fedora 35 installed in my ssd, I have accidentally deleted the efi partition,

I couldn’t find a solution, and to tell you all I’m a novice.
On the picture you see how my ssd looks:

Image

Does not know where to place:
/boot and
/Boot/efi

Thank you in advance for your interventions .
Attachments
Screenshot from 2022-09-23 06-35-53.png
Screenshot from 2022-09-23 06-35-53.png (59.41 KiB) Viewed 2290 times
Last edited by Ouahibh on Fri Sep 23, 2022 10:50 am, edited 1 time in total.
Post Reply