The kernel order cannot be changed on boot with the Rocky 8.10 cloud image

info

used image : https://dl.rockylinux.org/pub/rocky/8/images/x86_64/Rocky-8-GenericCloud-Base.latest.x86_64.qcow2
distro : Rocky 8.10
boot mode : bios(legacy)
cat /etc/default/grub

GRUB_TIMEOUT=1
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=auto"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true



steps to reproduce

[root@rock810-ori ~]# grubby --info ALL | grep -E "^kernel|^index"
index=0
kernel="/boot/vmlinuz-4.18.0-553.el8_10.x86_64"
index=1
kernel="/boot/vmlinuz-0-rescue-5dedb03890064d12ae33dd13b8e4dc31"
index=2
kernel="/boot/vmlinuz-4.18.0-553.16.1.el8_10.x86_64"
index=3
kernel="/boot/vmlinuz-0-rescue-3dd925f0ad2d4f3a80f6d8c9713b52bf"
...
[root@rock810-ori ~]# grubby --set-default-index 0
The default is /boot/loader/entries/5dedb03890064d12ae33dd13b8e4dc31-4.18.0-553.el8_10.x86_64.conf with index 0 and kernel /boot/vmlinuz-4.18.0-553.el8_10.x86_64

[root@rock810-ori ~]# grubby --default-kernel
/boot/vmlinuz-4.18.0-553.el8_10.x86_64
[root@rock810-ori ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
done
[root@rock810-ori ~]# sync; reboot

  • Problem occurred
    • The version 4.18.0-553.el8_10.x86_64 should appear.
[root@rock810-ori ~]# uname -r
4.18.0-553.16.1.el8_10.x86_64


  • And the index value in the command output seems to be different from the actual kernel index value that can be selected during boot.
[root@rock810-ori ~]# grubby --info ALL | grep -E "^kernel|^index"
index=0
kernel="/boot/vmlinuz-4.18.0-553.el8_10.x86_64"
index=1
kernel="/boot/vmlinuz-0-rescue-5dedb03890064d12ae33dd13b8e4dc31"
index=2
kernel="/boot/vmlinuz-4.18.0-553.16.1.el8_10.x86_64"
index=3
kernel="/boot/vmlinuz-0-rescue-3dd925f0ad2d4f3a80f6d8c9713b52bf"
...

Take a look at /usr/sbin/grub2-set-default

You did set default first, before grub2-mkconfig. What if the latter did redefine the default?

ls -l /boot/loader/entries/

The GRUB uses BLS (boot loader specification) module to add those entries to the menu. The entry files do not have index in them.
Perhaps grubby and BLS enumerate the entries differently?

The “index 0” is “first on list”. If BLS puts “greatest version” first, then that is the “0”. One can refer to entry more explicitly than with index number.

Says to use saved_entry from the grubenv. Did grubby or grub2-mkconfig touch that? (Install of kernel package does.)