help-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grub2-mkconfig not sorting correctly?


From: Michael D. Setzer II
Subject: Re: grub2-mkconfig not sorting correctly?
Date: Sun, 23 Dec 2012 00:43:39 +1000

On 22 Dec 2012 at 18:07, Andrey Borzenkov wrote:

Date sent:              Sat, 22 Dec 2012 18:07:53 +0400
From:                   Andrey Borzenkov <address@hidden>
To:                     "Michael D. Setzer II"
<address@hidden>
Copies to:              address@hidden
Subject:                Re: grub2-mkconfig not sorting correctly?

> В Sat, 22 Dec 2012 22:20:18 +1000
> "Michael D. Setzer II" <address@hidden> пишет:
>
> > Saw this some time ago, and then there was a patch, and it
> > worked, and then this was updated. But have not seen it again
> > with 3.6.10 kernel coming later instead of first.
> >
>
> You never explained what exactly is wrong. One can guess that it is
> numeric sort, but it is just guess.
>
> Please show two menu entries, their order and explain why it is wrong.
> And exact grub2 version you are using.
>

Version of Grub
grub2-199-13.fc16.3.x86_64

Grub.cfg with Bad sort order

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  load_env
fi
set default="0"
if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  insmod vbe
  insmod vga
  insmod video_bochs
  insmod video_cirrus
}

insmod part_msdos
insmod ext2
set root='(hd0,msdos2)'
search --no-floppy --fs-uuid --set=root
c0fc90bb-0c7b-41eb-9d04-1b605abd8ef5
if loadfont /grub2/unicode.pf2 ; then
  set gfxmode=1024x768x16
  load_video
  insmod gfxterm
fi
terminal_output gfxterm
insmod part_msdos
insmod ext2
set root='(hd0,msdos2)'
search --no-floppy --fs-uuid --set=root
c0fc90bb-0c7b-41eb-9d04-1b605abd8ef5
insmod png
background_image -m stretch /verne.png
set timeout=45
set superusers="buffy"
password buffy linette
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Fedora Linux, with Linux 3.6.7-4.fc16.x86_64' --class
fedora --class gnu-linux --class gnu --class os {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='(hd0,msdos2)'
        search --no-floppy --fs-uuid --set=root
c0fc90bb-0c7b-41eb-9d04-1b605abd8ef5
        echo    'Loading Linux 3.6.7-4.fc16.x86_64 ...'
        linux   /vmlinuz-3.6.7-4.fc16.x86_64
root=UUID=f6c3fb8d-656a-411f-9375-fd099a73c8a3 ro rd.md=0
rd.lvm=0 rd.dm=0  KEYTABLE=us quiet
SYSFONT=latarcyrheb-sun16 rhgb rd.luks=0
LANG=en_US.UTF-8 nouveau.modeset=0
        echo    'Loading initial ramdisk ...'
        initrd  /initramfs-3.6.7-4.fc16.x86_64.img
}
menuentry 'Fedora Linux, with Linux 3.6.7-4.fc16.x86_64
(recovery mode)' --class fedora --class gnu-linux --class gnu
--class os {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='(hd0,msdos2)'
        search --no-floppy --fs-uuid --set=root
c0fc90bb-0c7b-41eb-9d04-1b605abd8ef5
        echo    'Loading Linux 3.6.7-4.fc16.x86_64 ...'
        linux   /vmlinuz-3.6.7-4.fc16.x86_64
root=UUID=f6c3fb8d-656a-411f-9375-fd099a73c8a3 ro single
rd.md=0 rd.lvm=0 rd.dm=0  KEYTABLE=us quiet
SYSFONT=latarcyrheb-sun16 rhgb rd.luks=0
LANG=en_US.UTF-8 nouveau.modeset=0
        echo    'Loading initial ramdisk ...'
        initrd  /initramfs-3.6.7-4.fc16.x86_64.img
}
menuentry 'Fedora Linux, with Linux 3.6.6-1.fc16.x86_64' --class
fedora --class gnu-linux --class gnu --class os {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='(hd0,msdos2)'
        search --no-floppy --fs-uuid --set=root
c0fc90bb-0c7b-41eb-9d04-1b605abd8ef5
        echo    'Loading Linux 3.6.6-1.fc16.x86_64 ...'
        linux   /vmlinuz-3.6.6-1.fc16.x86_64
root=UUID=f6c3fb8d-656a-411f-9375-fd099a73c8a3 ro rd.md=0
rd.lvm=0 rd.dm=0  KEYTABLE=us quiet
SYSFONT=latarcyrheb-sun16 rhgb rd.luks=0
LANG=en_US.UTF-8 nouveau.modeset=0
        echo    'Loading initial ramdisk ...'
        initrd  /initramfs-3.6.6-1.fc16.x86_64.img
}
menuentry 'Fedora Linux, with Linux 3.6.6-1.fc16.x86_64
(recovery mode)' --class fedora --class gnu-linux --class gnu
--class os {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='(hd0,msdos2)'
        search --no-floppy --fs-uuid --set=root
c0fc90bb-0c7b-41eb-9d04-1b605abd8ef5
        echo    'Loading Linux 3.6.6-1.fc16.x86_64 ...'
        linux   /vmlinuz-3.6.6-1.fc16.x86_64
root=UUID=f6c3fb8d-656a-411f-9375-fd099a73c8a3 ro single
rd.md=0 rd.lvm=0 rd.dm=0  KEYTABLE=us quiet
SYSFONT=latarcyrheb-sun16 rhgb rd.luks=0
LANG=en_US.UTF-8 nouveau.modeset=0
        echo    'Loading initial ramdisk ...'
        initrd  /initramfs-3.6.6-1.fc16.x86_64.img
}
menuentry 'Fedora Linux, with Linux 3.6.10-2.fc16.x86_64' --class
fedora --class gnu-linux --class gnu --class os {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='(hd0,msdos2)'
        search --no-floppy --fs-uuid --set=root
c0fc90bb-0c7b-41eb-9d04-1b605abd8ef5
        echo    'Loading Linux 3.6.10-2.fc16.x86_64 ...'
        linux   /vmlinuz-3.6.10-2.fc16.x86_64
root=UUID=f6c3fb8d-656a-411f-9375-fd099a73c8a3 ro rd.md=0
rd.lvm=0 rd.dm=0  KEYTABLE=us quiet
SYSFONT=latarcyrheb-sun16 rhgb rd.luks=0
LANG=en_US.UTF-8 nouveau.modeset=0
        echo    'Loading initial ramdisk ...'
        initrd  /initramfs-3.6.10-2.fc16.x86_64.img
}
menuentry 'Fedora Linux, with Linux 3.6.10-2.fc16.x86_64
(recovery mode)' --class fedora --class gnu-linux --class gnu
--class os {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='(hd0,msdos2)'
        search --no-floppy --fs-uuid --set=root
c0fc90bb-0c7b-41eb-9d04-1b605abd8ef5
        echo    'Loading Linux 3.6.10-2.fc16.x86_64 ...'
        linux   /vmlinuz-3.6.10-2.fc16.x86_64
root=UUID=f6c3fb8d-656a-411f-9375-fd099a73c8a3 ro single
rd.md=0 rd.lvm=0 rd.dm=0  KEYTABLE=us quiet
SYSFONT=latarcyrheb-sun16 rhgb rd.luks=0
LANG=en_US.UTF-8 nouveau.modeset=0
        echo    'Loading initial ramdisk ...'
        initrd  /initramfs-3.6.10-2.fc16.x86_64.img
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry 'Fedora Memtest memtest86+-4.20' {
        insmod part_msdos
        insmod ext2
        set root='(hd0,msdos2)'
        search --no-floppy --fs-uuid --set=root
c0fc90bb-0c7b-41eb-9d04-1b605abd8ef5
        insmod bsd
        echo    'Loading Fedora Memtest ...Loading memtest86+-4.20
...'
        knetbsd /elf-memtest86+-4.20
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Microsoft Windows XP Professional (on /dev/sda1)"
--class windows --class os {
        insmod part_msdos
        insmod ntfs
        set root='(hd0,msdos1)'
        search --no-floppy --fs-uuid --set=root 8C6C55CB6C55B0A6
        drivemap -s (hd0) ${root}
        chainloader +1
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.
Simply type the
# menu entries you want to add after this comment.  Be careful
not to change
# the 'exec tail' line above.
menuentry "G4L" --users buffy {
        linux /bz3x7.1 ramdisk_size=65536 root=/dev/ram0
telnetd=yes
        initrd /ramdisk.lzma
}
menuentry "G4L Restore XP" {
        linux /bz3x7.1 ramdisk_size=65536 root=/dev/ram0
telnetd=yes run="mount /dev/sda6 /mnt/local ; cd /mnt/local ;
./reimagexp "
        initrd /ramdisk.lzma
}

### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

### BEGIN /etc/grub.d/90_persistent ###
### END /etc/grub.d/90_persistent ###

Grub.good


#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  load_env
fi
set default="0"
if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  insmod vbe
  insmod vga
  insmod video_bochs
  insmod video_cirrus
}

insmod part_msdos
insmod ext2
set root='(hd0,msdos2)'
search --no-floppy --fs-uuid --set=root
c0fc90bb-0c7b-41eb-9d04-1b605abd8ef5
if loadfont /grub2/unicode.pf2 ; then
  set gfxmode=1024x768x16
  load_video
  insmod gfxterm
fi
terminal_output gfxterm
insmod part_msdos
insmod ext2
set root='(hd0,msdos2)'
search --no-floppy --fs-uuid --set=root
c0fc90bb-0c7b-41eb-9d04-1b605abd8ef5
insmod png
background_image -m stretch /verne.png
set timeout=45
set superusers="buffy"
password buffy linette
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Fedora Linux, with Linux 3.6.10-2.fc16.x86_64' --class
fedora --class gnu-linux --class gnu --class os {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='(hd0,msdos2)'
        search --no-floppy --fs-uuid --set=root
c0fc90bb-0c7b-41eb-9d04-1b605abd8ef5
        echo    'Loading Linux 3.6.10-2.fc16.x86_64 ...'
        linux   /vmlinuz-3.6.10-2.fc16.x86_64
root=UUID=f6c3fb8d-656a-411f-9375-fd099a73c8a3 ro rd.md=0
rd.lvm=0 rd.dm=0  KEYTABLE=us quiet
SYSFONT=latarcyrheb-sun16 rhgb rd.luks=0
LANG=en_US.UTF-8 nouveau.modeset=0
        echo    'Loading initial ramdisk ...'
        initrd  /initramfs-3.6.10-2.fc16.x86_64.img
}
menuentry 'Fedora Linux, with Linux 3.6.10-2.fc16.x86_64
(recovery mode)' --class fedora --class gnu-linux --class gnu
--class os {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='(hd0,msdos2)'
        search --no-floppy --fs-uuid --set=root
c0fc90bb-0c7b-41eb-9d04-1b605abd8ef5
        echo    'Loading Linux 3.6.10-2.fc16.x86_64 ...'
        linux   /vmlinuz-3.6.10-2.fc16.x86_64
root=UUID=f6c3fb8d-656a-411f-9375-fd099a73c8a3 ro single
rd.md=0 rd.lvm=0 rd.dm=0  KEYTABLE=us quiet
SYSFONT=latarcyrheb-sun16 rhgb rd.luks=0
LANG=en_US.UTF-8 nouveau.modeset=0
        echo    'Loading initial ramdisk ...'
        initrd  /initramfs-3.6.10-2.fc16.x86_64.img
}
menuentry 'Fedora Linux, with Linux 3.6.7-4.fc16.x86_64' --class
fedora --class gnu-linux --class gnu --class os {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='(hd0,msdos2)'
        search --no-floppy --fs-uuid --set=root
c0fc90bb-0c7b-41eb-9d04-1b605abd8ef5
        echo    'Loading Linux 3.6.7-4.fc16.x86_64 ...'
        linux   /vmlinuz-3.6.7-4.fc16.x86_64
root=UUID=f6c3fb8d-656a-411f-9375-fd099a73c8a3 ro rd.md=0
rd.lvm=0 rd.dm=0  KEYTABLE=us quiet
SYSFONT=latarcyrheb-sun16 rhgb rd.luks=0
LANG=en_US.UTF-8 nouveau.modeset=0
        echo    'Loading initial ramdisk ...'
        initrd  /initramfs-3.6.7-4.fc16.x86_64.img
}
menuentry 'Fedora Linux, with Linux 3.6.7-4.fc16.x86_64
(recovery mode)' --class fedora --class gnu-linux --class gnu
--class os {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='(hd0,msdos2)'
        search --no-floppy --fs-uuid --set=root
c0fc90bb-0c7b-41eb-9d04-1b605abd8ef5
        echo    'Loading Linux 3.6.7-4.fc16.x86_64 ...'
        linux   /vmlinuz-3.6.7-4.fc16.x86_64
root=UUID=f6c3fb8d-656a-411f-9375-fd099a73c8a3 ro single
rd.md=0 rd.lvm=0 rd.dm=0  KEYTABLE=us quiet
SYSFONT=latarcyrheb-sun16 rhgb rd.luks=0
LANG=en_US.UTF-8 nouveau.modeset=0
        echo    'Loading initial ramdisk ...'
        initrd  /initramfs-3.6.7-4.fc16.x86_64.img
}
menuentry 'Fedora Linux, with Linux 3.6.6-1.fc16.x86_64' --class
fedora --class gnu-linux --class gnu --class os {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='(hd0,msdos2)'
        search --no-floppy --fs-uuid --set=root
c0fc90bb-0c7b-41eb-9d04-1b605abd8ef5
        echo    'Loading Linux 3.6.6-1.fc16.x86_64 ...'
        linux   /vmlinuz-3.6.6-1.fc16.x86_64
root=UUID=f6c3fb8d-656a-411f-9375-fd099a73c8a3 ro rd.md=0
rd.lvm=0 rd.dm=0  KEYTABLE=us quiet
SYSFONT=latarcyrheb-sun16 rhgb rd.luks=0
LANG=en_US.UTF-8 nouveau.modeset=0
        echo    'Loading initial ramdisk ...'
        initrd  /initramfs-3.6.6-1.fc16.x86_64.img
}
menuentry 'Fedora Linux, with Linux 3.6.6-1.fc16.x86_64
(recovery mode)' --class fedora --class gnu-linux --class gnu
--class os {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='(hd0,msdos2)'
        search --no-floppy --fs-uuid --set=root
c0fc90bb-0c7b-41eb-9d04-1b605abd8ef5
        echo    'Loading Linux 3.6.6-1.fc16.x86_64 ...'
        linux   /vmlinuz-3.6.6-1.fc16.x86_64
root=UUID=f6c3fb8d-656a-411f-9375-fd099a73c8a3 ro single
rd.md=0 rd.lvm=0 rd.dm=0  KEYTABLE=us quiet
SYSFONT=latarcyrheb-sun16 rhgb rd.luks=0
LANG=en_US.UTF-8 nouveau.modeset=0
        echo    'Loading initial ramdisk ...'
        initrd  /initramfs-3.6.6-1.fc16.x86_64.img
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry 'Fedora Memtest memtest86+-4.20' {
        insmod part_msdos
        insmod ext2
        set root='(hd0,msdos2)'
        search --no-floppy --fs-uuid --set=root
c0fc90bb-0c7b-41eb-9d04-1b605abd8ef5
        insmod bsd
        echo    'Loading Fedora Memtest ...Loading memtest86+-4.20
...'
        knetbsd /elf-memtest86+-4.20
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Microsoft Windows XP Professional (on /dev/sda1)"
--class windows --class os {
        insmod part_msdos
        insmod ntfs
        set root='(hd0,msdos1)'
        search --no-floppy --fs-uuid --set=root 8C6C55CB6C55B0A6
        drivemap -s (hd0) ${root}
        chainloader +1
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.
Simply type the
# menu entries you want to add after this comment.  Be careful
not to change
# the 'exec tail' line above.
menuentry "G4L" --users buffy {
        linux /bz3x7.1 ramdisk_size=65536 root=/dev/ram0
telnetd=yes
        initrd /ramdisk.lzma
}
menuentry "G4L Restore XP" {
        linux /bz3x7.1 ramdisk_size=65536 root=/dev/ram0
telnetd=yes run="mount /dev/sda6 /mnt/local ; cd /mnt/local ;
./reimagexp "
        initrd /ramdisk.lzma
}

### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

### BEGIN /etc/grub.d/90_persistent ###
### END /etc/grub.d/90_persistent ###



> > Did some searching, and found a modification to
> > grub-mkconfig_lib that seems to fix the problem.
> > This is with Fedora 16, but saw one note of this being fixed in
> > Fedora 17, but don't know if it is the same with all version.
> >
> > Then change is the following function.
> > version_find_latest ()
> > {
> >   #patched (whole work is done by sort!):
> >   echo $@ | tr ' ' '\n' | sort -Vr | head -1 | cat
> > #bad code! sorts wrong!
> > #local a=""
> >  # for i in $@ ; do
> >   #  if version_test_gt "$i" "$a" ; then
> >    #   a="$i"
> >     #fi
> >   #done
> >   #echo "$a"
> > }
> >
> > After applying the change,
> > the grub2-mkconfig -o /boot/grub2/grub.cfg
> > Now correctly sorts the kernels with the newest first.
> >
> > May only be an issue with Fedora 16, but might want to check if you
> > run grub2-mkconfig. I believe the yum update did correctly create
> > the grub.cfg, but running the grub2-mkconfig didn't.
> >
> >
> > +----------------------------------------------------------+
> >   Michael D. Setzer II -  Computer Science Instructor
> >   Guam Community College  Computer Center
> >   mailto:address@hidden
> >   mailto:address@hidden
> >   http://www.guam.net/home/mikes
> >   Guam - Where America's Day Begins
> >   G4L Disk Imaging Project maintainer
> >   http://sourceforge.net/projects/g4l/
> > +----------------------------------------------------------+
> >
> > http://setiathome.berkeley.edu (Original)
> > Number of Seti Units Returned:  19,471
> > Processing time:  32 years, 290 days, 12 hours, 58 minutes
> > (Total Hours: 287,489)
> >
> > address@hidden CREDITS
> > SETI        13494271.333531   |   EINSTEIN     9405727.039852
> > ROSETTA      5631451.296598   |   ABC         15600753.474107
> >
> >
> > _______________________________________________
> > Help-grub mailing list
> > address@hidden
> > https://lists.gnu.org/mailman/listinfo/help-grub
>


+----------------------------------------------------------+
  Michael D. Setzer II -  Computer Science Instructor
  Guam Community College  Computer Center
  mailto:address@hidden
  mailto:address@hidden
  http://www.guam.net/home/mikes
  Guam - Where America's Day Begins
  G4L Disk Imaging Project maintainer
  http://sourceforge.net/projects/g4l/
+----------------------------------------------------------+

http://setiathome.berkeley.edu (Original)
Number of Seti Units Returned:  19,471
Processing time:  32 years, 290 days, 12 hours, 58 minutes
(Total Hours: 287,489)

address@hidden CREDITS
SETI        13494271.333531   |   EINSTEIN     9405727.039852
ROSETTA      5631451.296598   |   ABC         15600753.474107




reply via email to

[Prev in Thread] Current Thread [Next in Thread]