Manually update kernel `saved_entry` to the latest installed kernel after removing kernel (grub2-mkconfig didn't help)

I removed kernel version 6.4.4 and 6.4.6 using

sudo dnf remove kernel-{core,devel}-"${Version}"

sudo dnf remove kernel-{core,devel}-"${Version}"
  • After removing we can see that saved_entry is not updated even after running: sudo grub2-mkconfig -o "/boot/grub2/grub2-efi.cfg"
$ sudo grub2-editenv list

$ sudo dnf list --installed | grep -E ^kernel
kernel.x86_64                                        6.3.11-200.fc38                     @updates               
kernel.x86_64                                        6.3.12-200.fc38                     @updates               
kernel-core.x86_64                                   6.3.11-200.fc38                     @updates               
kernel-core.x86_64                                   6.3.12-200.fc38                     @updates               
kernel-devel.x86_64                                  6.3.11-200.fc38                     @updates               
kernel-devel.x86_64                                  6.3.12-200.fc38                     @updates               
kernel-headers.x86_64                                6.4.4-200.fc38                      @updates               
kernel-modules.x86_64                                6.3.11-200.fc38                     @updates               
kernel-modules.x86_64                                6.3.12-200.fc38                     @updates               
kernel-modules-core.x86_64                           6.3.11-200.fc38                     @updates               
kernel-modules-core.x86_64                           6.3.12-200.fc38                     @updates               
kernel-modules-extra.x86_64                          6.3.11-200.fc38                     @updates               
kernel-modules-extra.x86_64                          6.3.12-200.fc38                     @updates               
kernel-srpm-macros.noarch                            1.0-19.fc38                         @updates               

Any suggestion?

You can remove the saved_entry entry like this

sudo grub2-editenv - unset saved_entry

Will this automatically update the saved_entry to the latest installed kernel?

That depends on the value of GRUB_SAVEDEFAULT in /etc/default/grub.

     If this option is set to ‘true’, then, when an entry is selected,
     save it as a new default entry for use by future runs of GRUB. This
     is only useful if ‘GRUB_DEFAULT=saved’; it is a separate option
     because ‘GRUB_DEFAULT=saved’ is useful without this option, in
     conjunction with ‘grub2-set-default’.  Unset by default.  This
     option relies on the environment block, which may not be available
     in all situations (*note Environment block::).

You then run grub2-mkconfig once and on next boot the saved entry will be saved to the last booted entry.

different file name: sudo grub2-mkconfig -o /boot/grub2/grub.cfg

That is an invalid file name for booting.

When using grub2-mkconfig one may use the command as
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
sudo grub2-mkconfig -o /etc/grub2.cfg
sudo grub2-mkconfig -o /etc/grub2-efi.cfg
all of which will actually output to the file /boot/grub2/grub.cfg as one can see here

$ ls -l /etc/grub*
lrwxrwxrwx. 1 root root   22 Apr 11 19:00 /etc/grub2.cfg -> ../boot/grub2/grub.cfg
lrwxrwxrwx. 1 root root   22 Apr 11 19:00 /etc/grub2-efi.cfg -> ../boot/grub2/grub.cfg