View Issue Details

IDProjectCategoryView StatusLast Update
0007651CentOS-7grub2public2015-09-26 18:37
ReporterQuesar Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformLinux x86_64OSCentOSOS Version7
Product Version7.0-1406 
Summary0007651: grub2-mkconfig creates boot choices in wrong order
DescriptionSystem had kernel 3.10.0-123.el7.x86_64. Updated to 3.10.0-123.6.3.el7.x86_64. After update, grub.cfg was generated with -123.el7 as the first entry instead of 123.6.3.el7.

The bug is in the logic in grub-mkconfig_lib-fix-order.patch. The version_test_numeric function was doing a gt test on a vs b, but was returning true if b was higher #, instead of false if b was higher.

After correcting this, I found that sort -V would put the rescue version above the others when sorting like this. As such, I added special cases for *rescue* in version_test_gt.
Steps To ReproduceUpdate kernel, see old version as first choice.
Additional InformationAttached patch to fix issue.
TagsNo tags attached.
abrt_hash
URL

Activities

Quesar

Quesar

2014-09-29 19:46

reporter  

grub-mkconfig_lib-fix-order.patch (822 bytes)   
--- share/grub/grub-mkconfig_lib	2014-06-30 12:16:11.000000000 -0400
+++ /tmp/grub-mkconfig_lib	2014-09-29 15:40:04.723864292 -0400
@@ -230,9 +230,9 @@
     version_test_numeric_b="$version_test_numeric_c"
   fi
   if (echo "$version_test_numeric_a" ; echo "$version_test_numeric_b") | version_sort | head -n 1 | grep -qx "$version_test_numeric_b" ; then
-    return 0
-  else
     return 1
+  else
+    return 0
   fi
 }
 
@@ -245,6 +245,8 @@
     return 0
   fi
   case "$version_test_gt_a:$version_test_gt_b" in
+    *:*rescue*) return 0;;
+    *rescue*:*) return 1;;
     *.old:*.old) ;;
     *.old:*) version_test_gt_a="`echo -n "$version_test_gt_a" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=gt ;;
     *:*.old) version_test_gt_b="`echo -n "$version_test_gt_b" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=ge ;;
Quesar

Quesar

2014-10-07 20:42

reporter   ~0021085

My first patch did not fully fix the problem. 3.10.0-123.8.1.el7.x86_64 was released and my fix did not put this version as the 1st choice.

I will need to dig in further to get a better fix, but it is still broken right now.
toracat

toracat

2014-10-07 23:39

manager   ~0021086

Related upstream BZ:

https://bugzilla.redhat.com/show_bug.cgi?id=1124074
toracat

toracat

2014-12-03 17:33

manager   ~0021849

Another related upstream BZ:

https://bugzilla.redhat.com/show_bug.cgi?id=1154430
edgan

edgan

2014-12-09 00:10

reporter   ~0021884

The patch attached to this bug report doesn't work. I have attached a working patch to both of the bugzilla.redhat.com bug reports.
lsparreb

lsparreb

2015-02-04 14:17

reporter   ~0022282

Indeed the sorting order is the cause. I solved it by replacing the function

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"
}

with

version_find_latest ()
{
  { for i in "$@" ; do echo $i ; done | grep -v 'rescue' | sed 's/.el7.x86_64/.000.000000/g' | sort -Vr | sed 's/.000.000000/.el7.x86_64/g'
    for i in "$@" ; do echo $i ; done | grep 'rescue' | sort -Vr
  } | head -n 1
}

However, this solution is tested on a CentOS-7 x86_64 server only. It works for me. Maybe it does for you too.
toracat

toracat

2015-09-15 12:05

manager   ~0024355

The sorting issue has been fixed in grub2-2.02-0.17.el7_1.4 released upstream today:

https://rhn.redhat.com/errata/RHBA-2015-1784.html

(BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1229329 )

Issue History

Date Modified Username Field Change
2014-09-29 19:46 Quesar New Issue
2014-09-29 19:46 Quesar File Added: grub-mkconfig_lib-fix-order.patch
2014-10-07 20:42 Quesar Note Added: 0021085
2014-10-07 23:39 toracat Note Added: 0021086
2014-12-03 17:33 toracat Note Added: 0021849
2014-12-09 00:10 edgan Note Added: 0021884
2015-02-04 14:17 lsparreb Note Added: 0022282
2015-09-15 12:05 toracat Note Added: 0024355
2015-09-26 18:37 toracat Status new => resolved
2015-09-26 18:37 toracat Resolution open => fixed