This is a well known bug:
- grub2-mkconfig creates boot choices in wrong order (CentOS Bug 0007651)
- grub2-mkconfig wrong sorting (RHEL Bug 1124074)
- grub2 wrong sorting (Bug 678840 - fixed)
To determine how a kernel package updates grub.cfg one can display the scripts via:
$ yum whatprovides /boot/vmlinuz-3.10.0-123.9.3.el7.x86_64
kernel-3.10.0-123.9.3.el7.x86_64 : The Linux kernel
[..]
$ rpm -q --scripts kernel-3.10.0-123.9.3.el7.x86_64
This shows that /usr/sbin/new-kernel-pkg is called - which in turn calls grubby.
Workaround
(until it is fixed in RHEL/CentOS)
--- /usr/share/grub/grub-mkconfig_lib.orig 2014-06-30 18:16:11.000000000 +0200
+++ /usr/share/grub/grub-mkconfig_lib 2014-11-26 17:38:57.814000000 +0100
@@ -255,13 +255,24 @@
version_find_latest ()
{
- version_find_latest_a=""
- for i in "$@" ; do
- if version_test_gt "$i" "$version_find_latest_a" ; then
- version_find_latest_a="$i"
- fi
- done
- echo "$version_find_latest_a"
+ # workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1124074
+ # 'grub2-mkconfig wrong sorting'
+ {
+ for i in "$@"; do
+ echo $i
+ done | grep -v rescue | sort -V
+ for i in "$@"; do
+ echo $i
+ done | grep rescue | sort -V
+ } | head -n 1
}