I’m running a dual-boot desktop system with Fedora 28 and Windows 10. Today a strange error happened to my GRUB2 installation. This post documents how I fixed the error. Here is what happened: I was installing the Logitech software for my mouse in Windows because I need it to tune a new mousepad. After installation completed, it asked me to reboot the system. I did that and when the system boots up again, the normal GRUB boot menu didn’t appear. Instead, the GRUB command line shows up.
Identifying the root cause
Initially I tried to look for my grub.cfg
file and copy the commands inside to boot my Fedora OS. It did start booting as I can see the kernel loading. However, it stuck after a while and later it entered the emergency mode. I decided to reboot and do the same again in the GRUB CLI. This time, I noticed that the grub.cfg
was not displayed in its entirety. After printing part of the file to the screen, it complains with some cluster error. A quick search on Google suggests that the filesystem may have some error.
As I cannot boot my Fedora installation, I turned to my Fedora installation thumb drive and booted the live version. In the terminal, I ran fsck
on my EFI partition, then I got the following output
/EFI/FEDORA/GRUBENV
Contains a free cluster (5234). Assuming EOF.
/EFI/FEDORA/GRUBENV
File size is 1024 bytes, cluster chain length is 0 bytes.
Truncating file to 0 bytes.
/EFI/FEDORA/GRUB.CFG
Contains a free cluster (5235). Assuming EOF.
/EFI/FEDORA/GRUB.CFG
File size is 7971 bytes, cluster chain length is 0 bytes.
Truncating file to 0 bytes.
Reclaimed 1 unused cluster (4096 bytes).
Perform changes ? (y/n)
Clearly, the grubenv
and grub.cfg
files were broken.
Trying to fix the error
I first fiexed the filesystem error, I then mounted the partition and regenerated the two files.
# below operations were performed under 'root' user
$ mkdir /mnt/fedora-efi
$ mount /dev/sdb1 /mnt/fedora-efi
$ grub2-editenv /mnt/fedora-efi/EFI/fedora/grubenv create
$ grub2-mkconfig -o /mnt/fedora-efi/EFI/fedora/grub.cfg
The last two commands regenerate the two broken files. Since we are still in the live OS, the grub2-mkconfig
command will detect this system and also write it to the grub.cfg
file. Nonetheless, it found my Fedora and Windows OS on disk as well.
I rebooted again and this time I was able to boot into my Fedora installation (the display driver was not loaded properly, but that was OK). I then regenerated the grub.cfg
file now that I’m not running the Live OS anymore (the output path is now /boot/efi/EFI/fedora/grub.cfg
). It correctly detected every OS that I have just like what I had before in grub.cfg
. When I reboot with the latest grub.cfg
file, everything was working perfectly.
My PC can finally boot normally again with GRUB!
comments powered by Disqus