Grub not automatically updating boot menu

Hello there. I’m using f37 on my surface pro, and today I find that my grub is not updating boot menu after dnf updates. It only shows up previous kernels (such as 6.1.6 and 6.1.7) way older than newest ones installed (such as 6.2.6 and 6.2.8), and the old ones are kept installed.

I tried the same resolution for another issue(where my grub also not updating boot menu, but the old kernel have been autoremoved so it’s not booting), but it’s not working.

Is there any way to fix this? Thanks in advance.

My current kernel installations are pinned here:

[pairman@fedora ~]$ dnf list installed kernel*
Installed Packages
kernel-core.x86_64               6.1.6-200.fc37      @@System      
kernel-core.x86_64               6.1.7-200.fc37      @updates      
kernel-core.x86_64               6.2.7-200.fc37      @updates      
kernel-devel.x86_64              6.1.6-200.fc37      @@System      
kernel-devel.x86_64              6.1.7-200.fc37      @updates      
kernel-devel.x86_64              6.2.7-200.fc37      @updates      
kernel-devel-matched.x86_64      6.2.7-200.fc37      @updates      
kernel-headers.x86_64            6.2.6-200.fc37      @updates      
kernel-modules.x86_64            6.1.6-200.fc37      @@System      
kernel-modules.x86_64            6.1.7-200.fc37      @updates      
kernel-modules.x86_64            6.2.7-200.fc37      @updates      
kernel-modules-core.x86_64       6.2.7-200.fc37      @updates      
kernel-modules-extra.x86_64      6.1.6-200.fc37      @@System      
kernel-modules-extra.x86_64      6.1.7-200.fc37      @updates      
kernel-modules-extra.x86_64      6.2.7-200.fc37      @updates      
kernel-srpm-macros.noarch        1.0-15.fc37         @fedora       
kernel-surface.x86_64            6.1.6-1.fc37        @linux-surface
kernel-surface.x86_64            6.2.8-1.fc37        @linux-surface
kernel-surface-devel.x86_64      6.1.6-1.fc37        @linux-surface
kernel-surface-devel.x86_64      6.2.8-1.fc37        @linux-surface

Please post the output of cat /boot/efi/EFI/fedora/grub.cfg.

If it does not look similar to this then it has at some point been manually overwritten by using grub2-mkconfig and will need restored.

# cat /boot/efi/EFI/fedora/grub.cfg
search --no-floppy --fs-uuid --set=dev 0d7e9d7c-2d94-47c7-82d0-524d855be103
set prefix=($dev)/grub2

export $prefix
configfile $prefix/grub.cfg

Some time back that file was switched to become a pointer to redirect grub to the actual grub.cfg file located at /boot/grub2/grub.cfg.

When users overwrite the stub pointer file then updates are never seen because the system updates the file under /boot/grub2 and the file under /boot/efi is static as far as the system is normally concerned.

The fix has been as noted in this doc

The pertinent section would be under the heading Reinstalling GRUB 2 and the subheading Resetting and Reinstalling GRUB 2
That instruction is missing the need to remove /boot/grub2/grub.cfg and /boot/efi/EFI/fedora/grub.cfg. The reinstall will verify the files exist and if not rebuilds them. If they exist it does not rebuild them. Step 3 in that instruction should read dnf reinstall grub2-efi* shim grub2-common but otherwise is fully correct.

With this fix the system should now automatically update the grub menu according to installed kernel.

The alternative is the user must manually run the grub2-mkconfig command with every kernel install/update to update the /boot/efi/EFI/fedora/grub.cfg file. This is not the recommended procedure since that file is designed to remain static and is normally only a pointer. It is always best to have the system manage the updates for you.


Thanks! However my grub menu is still not updating.

I used these commands:

sudo rm /boot/grub2/grub.cfg
sudo rm /boot/efi/EFI/fedora/grub.cfg
sudo rm /etc/grub.d/* # No such file or directory
sudo rm /etc/sysconfig/grub
sudo dnf reinstall grub2-efi* shim grub2-common
sudo grub2-mkconfig -o /boot/grub2/grub.cfg

This is my /boot/efi/EFI/fedora/grub.cfg before resetting and reinstalling:

search --no-floppy --fs-uuid --set=dev 1f141e60-0039-4df5-a66c-f4aa4cb359d0
set prefix=($dev)/grub2
export $prefix
configfile $prefix/grub.cfg

This is my /etc/default/grub:

GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_CMDLINE_LINUX="rd.luks.uuid=luks-0a7c4fcf-c720-462f-8d34-7c0f5f3a6668 rhgb quiet intremap=nosid"

export GRUB_COLOR_NORMAL="light-gray/black"
export GRUB_COLOR_HIGHLIGHT="magenta/black"

# GRUB_FONT=/boot/grub2/DejaVuSansMono.pf2

While I cannot say for certain, the line in /etc/default/grub which has
may have an impact on the update of the grub menu.

If that kernel version is replaced or does not change then the grub menu may not see any changes since the default for dnf is to only keep the latest 3 kernels.

It also may be a bug in grub. I have noted in the past that even when I have changed the entry in /etc/dnf/dnf.conf from installonly_limit=3 to installonly_limit=4 that the grub menu still only displays the latest 3 kernels even when 4 are actually available to boot.

Maybe you should file a bug against grub.

1 Like

My first guess for those symptoms would be an error in /etc/fstab so that either the wrong partition is mounted as /boot or the wrong partition is mounted as /boot/efi

I would look at those entries in /etc/fstab and I would use the following command to get a clear picture of the partitions:

If that doesn’t identify the problem, the next place I would look to try to diagnose is
sudo grep linux /boot/loader/entries/*

1 Like

One thing of note is the missing kernel packages.
Note the first 3 in this list.

# dnf list installed kernel*
Installed Packages
kernel.x86_64                                                           6.1.15-200.fc37                                             @updates
kernel.x86_64                                                           6.1.18-200.fc37                                             @updates
kernel.x86_64                                                           6.2.7-200.fc37                                              @updates
kernel-core.x86_64                                                      6.1.15-200.fc37                                             @updates
kernel-core.x86_64                                                      6.1.18-200.fc37                                             @updates
kernel-core.x86_64                                                      6.2.7-200.fc37                                              @updates
kernel-devel.x86_64                                                     6.1.15-200.fc37                                             @updates
kernel-devel.x86_64                                                     6.1.18-200.fc37                                             @updates
kernel-devel.x86_64                                                     6.2.7-200.fc37                                              @updates
kernel-devel-matched.x86_64                                             6.2.7-200.fc37                                              @updates
kernel-headers.x86_64                                                   6.2.6-200.fc37                                              @updates
kernel-modules.x86_64                                                   6.1.15-200.fc37                                             @updates
kernel-modules.x86_64                                                   6.1.18-200.fc37                                             @updates
kernel-modules.x86_64                                                   6.2.7-200.fc37                                              @updates
kernel-modules-core.x86_64                                              6.2.7-200.fc37                                              @updates
kernel-modules-extra.x86_64                                             6.1.15-200.fc37                                             @updates
kernel-modules-extra.x86_64                                             6.1.18-200.fc37                                             @updates
kernel-modules-extra.x86_64                                             6.2.7-200.fc37                                              @updates
kernel-srpm-macros.noarch                                               1.0-15.fc37                                                 @fedora 

Your list does not display the kernel packages which are meta packages that pull in all the others when updates are done (and may run needed scripts during the install). Every install I have ever done has installed that package and every kernel version update has updated it.

Even this list from a VM I installed a couple days ago shows that package installed by anaconda during the install.

$ dnf list installed kernel*
Installed Packages
kernel.x86_64                                                           6.0.7-301.fc37                                             @anaconda
kernel.x86_64                                                           6.2.7-200.fc37                                             @updates 
kernel-core.x86_64                                                      6.0.7-301.fc37                                             @anaconda
kernel-core.x86_64                                                      6.2.7-200.fc37                                             @updates 
kernel-headers.x86_64                                                   6.2.6-200.fc37                                             @updates 
kernel-modules.x86_64                                                   6.0.7-301.fc37                                             @anaconda
kernel-modules.x86_64                                                   6.2.7-200.fc37                                             @updates 
kernel-modules-core.x86_64                                              6.2.7-200.fc37                                             @updates 
kernel-modules-extra.x86_64                                             6.0.7-301.fc37                                             @anaconda
kernel-modules-extra.x86_64                                             6.2.7-200.fc37                                             @updates 

Try doing sudo dnf install kernel and see what happens.


Thank all of you! I remember I did “sudo dnf remove --duplicates” since conflicts in updating, so probably this removed my kernel. I (re)installed my kernel and kernel-surface and the newest versions installed shows up in my grub menu.