After upgrading to F36, I updated fedora kernel belows:
sudo dnf upgrade
When the system is updated, I reboot the system. And I found the new kernel has not shown in grub menu.
To solve this problem, I did that:
~ sudo sed -i ‘s/GRUB_ENABLE_BLSCFG=true/GRUB_ENABLE_BLSCFG=false/g’ /etc/default/grub
~ sudo grub2-mkconfig -o /boot/grub2/grub.cfg
~ sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
I have to do it again and again when the kernel is updated. How to fix this bug? Please help.
When you used this command you overwrote a system file that is not supposed to be changed. The only file that is used for grub updates since fedora 34 is /boot/grub2/grub.cfg.
The fix is to
- remove /boot/efi/EFI/fedora/grub.cfg
- dnf reinstall grub2-common grub2-efi-*
- reboot.
Doing this will force grub to reinstall the proper grub.cfg file under /boot/efi and then since kernel updates only make changes to /boot/grub2/grub.cfg you will automatically see the updates.
Full instructions are here
https://fedoraproject.org/wiki/GRUB_2#Updating_the_GRUB_configuration_file
Followed your instructions, the problem is still not fixed.
When I reboot the system, /boot/efi/EFI/fedora/grub.cfg recovered.
Is /etc/default/grub indeed changed each time? It’s adapted to BLSCFG=true once upon a Fedora upgrade, but it should not change now. But BLSCFG=true should not harm, only the current kernel options are no longer in grub.cfg but in /boot/loader/entries. This should work.
You write, /boot/efi/EFI/fedora/grub.cfg recovered. To what stage is it recovered? It should read like
search --no-floppy --fs-uuid --set=dev 68a309af-fc6d-4c0c-a7a8-74a52d909bbe
set prefix=($dev)/grub2
export $prefix
configfile $prefix/grub.cfg
with the long number the boot partition UUID.
This file should not be touched anymore.
If you follow the advice of Jeff V and keep BLSCFG enabled, you should see a new entry in /boot/loader/entries after each kernel update which should be reflected in the grub menu.
vim /etc/default/grub, and enable BLSCFG. Then:
- remove /boot/efi/EFI/fedora/grub.cfg
- dnf reinstall grub2-common grub2-efi-*
- reboot.
When the kernel is updated, remove the old kernels belows:
sudo dnf remove --oldinstallonly
The problem is fixed. Thanks for Jeff V and h.janssen’s help.