Boot/grub issues after attempt to delete Windows

Hi, I’ve been running Fedora workstation on my desktop for a year or two and have been dual booting with Windows 10. They were happily sharing the ESP, which was mounted as /boot/efi on my Fedora system. It’s a 300MB FAT 32 partition.

Today I booted to a live Fedora 36 USB and with efibootmgr did -b 0005 -B to remove the Windows entry, then I deleted the Windows partition and grew the ext4 one next to it on the same disk. Much success, no data loss on the ext4 partition, except that after this Win10 was still present in the grub menu. (The Fedora ones worked as usual).

Since the mentioned ESP has been around for a while I decided to mount it in a live USB session and “air it out”, that is to say I did sudo rm -rf microsoft/ at /boot/efi/EFI/ (I’ve done similar things with other Linux system remnants here without much issue) so that there remained a fedora folder and an old Solus folder among others. Then I rebooted and Windows was still present in the grub menu and now the standard Fedora options did not work with an error saying a kernel needed to be loaded. Hm.

Rebooted to the Live fedora USB again and did sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg which added a Fedora entry, it said. Upon reboot the grub menu had three Solus entries, no Windows entry, two Fedora entries (one advanced and one other) and there was a border of ‘?’ around the entire grub menu, so that the menu looked a bit like a NES game. Choosing advanced there were four identical and anonymous Fedora 36 entries and I’m now booted into one of them, the second one. (The first one yields the same result as the other Fedora entry in the main grub menu, the system doesn’t boot properly and ends up asking for a root password, if one continues it fails to find /boot/efi.)

First thing I did was refresh my backups so whatever happens next isn’t the end of the world.

The system acts a bit funny, nvidia-smi doesn’t work because “it couldn’t communicate with the NVIDIA driver”. The Konsole started as a very small Window. Firefox didn’t think I was logged in here etc.

Is there a potential way to fix this before reinstalling Fedora?

lsblk shows sda which has the ESP and the Fedora partition, sdb which had the Windows partition and now just a larger ext4 partition:

sda           8:0    0 465,8G  0 disk 
├─sda1        8:1    0   300M  0 part /boot/efi
└─sda2        8:2    0 465,5G  0 part /
sdb           8:16   0 465,8G  0 disk 
└─sdb3        8:19   0 465,8G  0 part /mnt/Utrymme
sdc           8:32   0 465,8G  0 disk 
└─sdc2        8:34   0 464,8G  0 part 

sudo os-prober yields nothing

The current kernel is 5.17.5, I’m not sure if that was the latest kernel prior to the incident.

You can re-install grub2, which will regenerate the boot menu I believe. There is also efibootmgr which you can use to delete duplicates for instance, as well as manipulate bootloader entries.

I hope the grub2-mkconfig command was done in a chroot environment and not from the live media as indicated in the way you posted that.

If it was then that was the wrong command for fedora 36.

Since fedora 33 the location of the (real) grub.cfg file that is automatically updated by the system when kernels are updated is /boot/grub2/grub.cfg, so the proper command would have been sudo grub2-mkconfig -o /boot/grub2/grub.cfg. Your command would have overwritten a stub grub.cfg file which redirects grub to the /boot/grub2/grub.cfg file. Without that proper stub file future system updates will never be seen by grub when you boot.

To restore the proper grub.cfg stub file I suggest you delete the file /boot/efi/EFI/fedora/grub.cfg then reinstall the proper one with sudo dnf reinstall grub2-efi grub2-common. Then if you wish to manually update grub.cfg run sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Thanks alot for the info regarding the different grub.cfgs.

It was done from the live media like indicated I am afraid, I have never used chroot or indeed setup my own chroot environment, from a live USB or elsehow.

From a chroot environment I take it? In regards to creating such I saw Fedora documention for this for Fedora 23 and am not sure whether that is still relevant. There are various gists like Setting up chroot from a live image in Fedora. Regenerate grub2 for Fedora. · GitHub , though I am having issues parsing part of that (how they mount /boot for instance. /boot is not a separate partition in my machine though /boot/efi is the esp.) Is there a specific method recommended nowadays?

Right, the four “advanced” Fedora entries in the ‘?’ Grub meny were kernel versions. The latest worked okay but modprobe was constantly taking up around 10% of cpu and things were not OK.

Did:

  1. Booted a live Fedora 36 USB
  2. Mounted my system’s root partition (sda2) as /mnt
  3. Mounted my system’s ESP partition (sda1) as /mnt/boot/efi
  4. Did for dir in /dev /proc /sys /run; do mount --bind $dir /mnt/$dir ; done. There were no complaints.
  5. chroot /mnt
  6. rm /boot/efi/EFI/fedora/grub.cfg
  7. sudo dnf reinstall grub2-efi grub2-common
  8. sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Which is in essence your advice and the “how chroot” via Setting up chroot from a live image in Fedora. Regenerate grub2 for Fedora. · GitHub and lo and behold the grub menu is back as before and the system boots as before and looks and acts as before :slight_smile:

I’m still not certain why removing /boot/efi/EFI/microsoft/ would cause grub to fail to find a linux kernel but I’m very happy things are back to normal without a reinstall (that isn’t a worry but takes a few hours to get like I want it and time flies when you are having fun :slight_smile: )

Edit. And the Winnows grub entry is gone!