Hi,
Back up the current BLS configuration files by moving them to a backup directory.
# mkdir /boot/loader/backup
# mv /boot/loader/entries/* /boot/loader/backup/
Re-create BLS configuration files:
# for i in `rpm -q kernel | sed 's/kernel-//g' | sort | xargs echo` ; do kernel-install add $i /lib/modules/$i/vmlinuz ; done
Recreate the GRUB configuration file.
For BIOS;
# grub2-mkconfig -o /boot/grub2/grub.cfg
For EFI;
# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
In case you have AlmaLinux 9.3 or later;
# grub2-mkconfig -o /boot/grub2/grub.cfg
Recreate the GRUB configuration file. On UEFI systems, the /boot/efi/EFI/redhat/grub.cfg file GRUB used before is now just a stub pointing to /boot/grub2/grub.cfg, which holds the actual configuration. In RHEL 9, avoid using grub2-mkconfig with /boot/efi/EFI/redhat/grub.cfg as the output.
The problem stems from a mismatch between the system’s updated machine-id and GRUB’s Boot Loader Specification (BLS) sorting mechanism.
Identifier Conflict: The /etc/machine-id file prefixes filenames in /boot/loader/entries/. When machine-id changes, new kernels use the updated ID, but older kernel entries retain the previous ID.
Sorting Priority: GRUB’s blscfg module sorts boot entries in reverse-alphanumeric order based on these filenames. Since filenames start with machine-id, it becomes the primary sorting key.
Old ID Wins: If the previous machine-id sorts higher alphanumerically (like “z…” before “a…”), older kernel entries appear first in the boot menu.
Default Behavior: With GRUB_DEFAULT=0 in /etc/default/grub, the system boots the first entry (index 0), which is the older kernel due to sorting precedence over version numbers.
Richard.