Correct way to update grub boot entries

Hi all,

I recently installed Fedora 40 KDE Spin, and set up a dual-boot configuration with Windows 11 using the Fedora Media Writer. This was installed using EFI.

So far everything’s good, however I noticed that neither kernel updates nor Grub Customiser changed the grub entries. I checked similar discussions and couldn’t find solutions to permanently resolve the issue, namely using:

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

I then saw a video from a popular Linux youtuber who ran into the same issues trying to customise the grub bootloader, until he ran the command:

sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

Which also solved the issue for me, though today a new kernel update came and that didn’t update the grub entries, so just wondering what the issue might be since the grub.cfg file in EFI doesn’t seem to update?

For reference I followed the docs from 2022 which said to delete both grub.cfgs from EFI and boot, but after both files regenerated Fedora went past the grub bootloader and straight into Fedora, so Windows wasn’t being picked up. Would appreciate any in-depth explanations to understand the technicalities, as well as a solution for this. Happy to give more info too.

Thank you!

1 Like

This command overwrites a default pointer file that has been in place since about fedora 32 or 33 which redirects grub to the actual file at /boot/grub2/grub.cfg. If you were to run ls -l /efi/grub*.cfg you would also find two symlinks there that point to the actual grub.cfg file.

What the command does is overwrite that pointer file. Kernel and system updates which are done automatically never touch the file under /boot/efi so the system never sees updates and the only way to update it then becomes manually.

Recovery requires removal of the file you created and re-creating the proper file so the system properly sees and uses newer updates.

  1. sudo rm /boot/efi/EFI/fedora/grub.cfg /boot/grub2/grub.cfgto remove the invalid files
  2. sudo dnf reinstall grub2-common which recreates both those files as they should be

The following 3 commands are functionally equivalent. The last 2 use symlinks that redirect the output to the file named in the first.
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-mkconfig -o /etc/grub2.cfg
grub2-mkconfig -o /etc/grub2-efi.cfg

My notes above explain that.

4 Likes

Added bootupd, dual-boot, grub, uefi

Hi Jeff, thanks for the detailed explanation, your steps resolved the issue.

Some follow up questions:

  • Does grub.cfg in boot/grub2/ need to be updated each time a new kernel is released, or does it automatically update after a kernel update?
  • Do the three grub2-mkconfig commands need to be run through sudo?
  • If the grub.cfg file is damaged and locks a user out of their system, can one change the boot order in the BIOS to regain access into another OS (Windows in my case)?
  • How would one troubleshoot grub issues if they can’t access their Linux user account?

In case it helps anyone, I kept a backup of the original grub.cfg file, when I first installed Fedora, from /boot/efi/EFI/fedora (before I overwrote it), and can now see that it has static boot entries as opposed to the pointer links Jeff V mentioned.

I suspect this was the cause of grub not updating, as the newly generated grub.cfg in /EFI/fedora file looks to point to /grub2 directories where my boot entries are kept. After following the above, my first restart took me straight into Linux, but a second restart restored the boot entries containing my Windows partition.

Thanks again.

What advice did you follow from the popular Linux youtuber?

Installing and using grub-customizer can create a real mess of your grub configuration. Maybe not immediately, but some times in the future.

Disabling BLS in /etc/default/grub is not compatible with the way the kernel updates are handled.

In the default setup the answer is no. The kernel configuration are located in /boot/loader/entries.

The three commands are equivalent and you only run one of them. If you get permission problems, you need to run with sudo.

The UEFI boot menu should have an entry for booting windows. To fix grub, you need to original install iso image and boot that. So it is a good idea to keep that USB memory device with the install image, just in case.

That is hard to say, and even harder from remote.

1 Like

He was trying to customise his grub bootloader and nothing worked, until the very end when he ran the command to overwrite the grub.cfg file in EFI. Mistake from my end to follow that without understanding what was being done.

Funny enough I also followed a guide for installing Fedora and installing grub-customiser was in that list… is there a way to safely remove it? Also, what does BLS stand for?

Big thank you for the replies also, good learning experience this is. As an update the bootloader is working normally now, sometimes it does skip straight into Fedora but restarting again takes me back there.

Automatic

Yes, but only one is required and then only if you make changes. Otherwise it updates automatically.

Bios usually has a key that opens the bios boot menu to select what device to boot. On most systems it is in the range F10, F11, F12

On most systems when dual booting with windows the grub menu should automatically be displayed during boot.
This sometimes does not happen if fast boot is enabled in grub or in windows.

If the display is not always done it can be enabled to always show the grub menu with the command sudo grub2-editenv - unset menu_auto_hide

Thanks for your reply and answers, appreciate the explanations. Did some further reading into the command for always showing the grub menu, looks like it was a feature added to cut down on boot time, and I could use either esc or shift to interrupt this and view the grub menu.

Either way I ran the command and now the behaviour at boot is as expected for my usage. Thanks again as always and appreciate everyone’s help and support.

1 Like

Many users do not want the displayed menu which does, as stated, add a few seconds to the boot and by default boots into the latest installed kernel.

When dual booting with windows the default ‘should be’ to always display the grub menu so the OS being booted may be selected. For most that seems to function properly.

There are workarounds available for almost everything and the grub2-editenv command forces the menu to be always displayed, even when not dual booting.

I did some further investigating and, based on other forum posts, I think grub customizer may have caused the issues. Is it safe to just uninstall it through dnf (as that’s how I installed it)?

I assume I would need to rebuild the grub.cfg file after removing it, but just wanted to check since I’ve seen a range of experiences and want to exercise caution in case it breaks my system.

Thanks again for all your help and explanations.

Grub customizer has been known to cause issues.
Removing it should cause no problems, then after it is removed there may still be issues, but running the command sudo grub2-mkconfig -o /boot/grub2/grub.cfg should fix it mostly.

Let us know the results.

There is more. The files in /etc/grub.d may have been renamed so that needs to be fixed.

I would sudo rm /etc/grub.d/* followed by sudo dnf reinstall grub2-tools fwupd. If you have any of greenboot, ostree-grub2 or tboot, these needs to be reinstalled as well.

I tried to run sudo rm /etc/grub.d/* but it says ‘no such file or directory found’. Should I try running another command? Please do let me know.

Uninstalling grub customizer worked though regenerating the grub.cfg file has created duplicate entries for fedora, and the new kernel, 6.11.5-200 doesn’t load at all so I’m using 6.11.4-201.

Also it looks like /grub.d/ has been changed a lot from grub customizer, there’s a backup and some custom files in it.

Can you check the contents of /etc/grub.d?

That is why I would remove everything in /etc/grub.d and then re-install all packages which have files in that directory. It should then have these entries.

/etc/grub.d
/etc/grub.d/00_header
/etc/grub.d/01_users
/etc/grub.d/08_fallback_counting
/etc/grub.d/10_linux
/etc/grub.d/10_reset_boot_success
/etc/grub.d/12_menu_auto_hide
/etc/grub.d/14_menu_show_once
/etc/grub.d/20_linux_xen
/etc/grub.d/20_ppc_terminfo
/etc/grub.d/30_os-prober
/etc/grub.d/30_uefi-firmware
/etc/grub.d/35_fwupd
/etc/grub.d/40_custom
/etc/grub.d/41_custom
/etc/grub.d/README
00_header
02_grub-customizer_menu_color_helper 
01_users
08_fallback_counting
10_linux_proxy
32_os-prober
33_linux_proxy
34_reset_boot_success
35_menu_auto_hide
35_fwupd
37_linux_xen
36_menu_show_once
38_ppc_terminfo
39_uefi-firmware
40_fwupd
42_custom
43_custom
backup
proxifiedScripts
bin
README

Ah I see, could I manually do this from Dolphin? Also, just to confirm, when deleting those files will they regenerate once I reinstall grub2-tools and fwupd? Do let me know otherwise if there’s another command which can delete the contents from Konsole.

I checked if I have greenboot, ostree-grub2, or tboot via dnf list --installed | grep <package_name> and can confirm no extra packages. Thanks again for your support.

That might give permission problems.

Oh, how should I proceed in that case, since the previous command didn’t work from my end?

For example remove the files one by one.

sudo rm /etc/grub.d/00_header
sudo rm /etc/grub.d/02_grub-customizer_menu_color_helper 
sudo rm /etc/grub.d/01_users
sudo rm /etc/grub.d/08_fallback_counting
sudo rm /etc/grub.d/10_linux_proxy
sudo rm /etc/grub.d/32_os-prober
sudo rm /etc/grub.d/33_linux_proxy
sudo rm /etc/grub.d/34_reset_boot_success
sudo rm /etc/grub.d/35_menu_auto_hide
sudo rm /etc/grub.d/35_fwupd
sudo rm /etc/grub.d/37_linux_xen
sudo rm /etc/grub.d/36_menu_show_once
sudo rm /etc/grub.d/38_ppc_terminfo
sudo rm /etc/grub.d/39_uefi-firmware
sudo rm /etc/grub.d/40_fwupd
sudo rm /etc/grub.d/42_custom
sudo rm /etc/grub.d/43_custom
sudo rm /etc/grub.d/backup
sudo rm /etc/grub.d/proxifiedScripts
sudo rm /etc/grub.d/bin
sudo rm /etc/grub.d/README
1 Like

This worked! I deleted the files as you suggested, reinstalled grub2-tools and fwupd, then I followed the instructions to unset menu autohide from Jeff’s post (I assume it would have reset by deleting the contents of grub.d), then rebuilt grub.cfg via grub2-mkconfig.

This has not only rebuilt my grub.d directory, but also resolved the issues I had with duplicate entries and the inability to boot into kernel 6.11.5-200.

Thank you both so much, huge relief to have removed grub-customizer and restored my system’s grub configuration, now I don’t feel like I’m using a system that’s waiting to break in the future. Please let me know if I’ve missed anything, otherwise, thank you again!

2 Likes