[Grub] kernel order

Derek Kaser derek.kaser at gmail.com
Sun Aug 3 04:32:29 UTC 2008


On Sat, Aug 2, 2008 at 11:25 PM, NoOp <glgxg at sbcglobal.net> wrote:
>
> Is there a parameter in Grub that I can set to tell grub to put the
> -generic kernel's first?

I don't think that there's a parameter that can do that, but you could
do it by giving -generic kernels a greater weight in
/usr/sbin/update-grub. In the file, you should see the following code
in the CompareVersions function (this is taken from Intrepid, where it
starts at line 544):

# we weight different kernel suffixes here
# ac   = 50
# pre  = -50
# rc   = -40
# test = -60
# others are given 99
v1=$(echo $v1 | sed -e 's! k7! 786 !g' -e 's! ac! 50 !g' -e 's! rc!
-40 !g' -e 's! pre! -50 !g' -e 's! test! -60 !g' -e 's![^ ]*[^-0-9 ][^
]*!99!g')
v2=$(echo $v2 | sed -e 's! k7! 786 !g' -e 's! ac! 50 !g' -e 's! rc!
-40 !g' -e 's! pre! -50 !g' -e 's! test! -60 !g' -e 's![^ ]*[^-0-9 ][^
]*!99!g')

If you change that to:

# we weight different kernel suffixes here
# ac   = 50
# pre  = -50
# rc   = -40
# test = -60
# generic = 101
# others are given 99
v1=$(echo $v1 | sed -e 's! k7! 786 !g' -e 's! ac! 50 !g' -e 's! rc!
-40 !g' -e 's! pre! -50 !g' -e 's! test! -60 !g' -e 's! generic! 100
!g' -e 's![^ ]*[^-0-9 ][^ ]*!99!g')
v2=$(echo $v2 | sed -e 's! k7! 786 !g' -e 's! ac! 50 !g' -e 's! rc!
-40 !g' -e 's! pre! -50 !g' -e 's! test! -60 !g' -e 's! generic! 100
!g' -e 's![^ ]*[^-0-9 ][^ ]*!99!g')

It will assign the generic kernel a weight of 100, and the 386 kernel
will keep the default weight of 99. That will make the generic kernel
appear above the 386 kernel.

This will all get erased, however, if grub updates, and you will need
to edit the file again to get the kernels to appear in the desired
order. Grub doesn't update very frequently, though (basically, it only
does when you upgrade to a newer version of Ubuntu), so that probably
won't be an issue.

Derek




More information about the ubuntu-users mailing list