Grub2 and multiple boot different ubuntu versions

Rashkae ubuntu at tigershaunt.com
Wed Mar 24 15:49:45 UTC 2010


Colin Law wrote:
> Hi
> 
> I had a double boot setup with XP and Karmic.  I installed Lucid Beta
> 1 in a separate partition and on boot it gives me the menu with Lucid
> at the top followed by Karmic kernels and XP, and all works well.  As
> Lucid is just for testing, however, I want it do default to Karmic
> boot so I set GRUB_DEFAULT=5 in /etc/default/grub, run sudo
> update-grub and again all is well.
> Each time the Lucid kernel is updated, however, I need to add two to
> GRUB_DEFAULT as there are new kernels above it.  I wonder whether it
> is possible to rearrange the grub menu so Karmic is at the top and I
> can leave the default at 0.  I have contemplated booting into Karmic
> and running update-grub but I hesitate to do this in case it is a bad
> idea, not really understanding how grub works.
> It would be nice if grub allowed a regex setting for the default boot
> when specifying a string, defaulting to the first matching name, but I
> have not seen this in the docs.  It would seem like a trivial
> extension.
> 
> Colin
> 

This suggestion is a little ugly and very un-elegant, but will probably 
be the easiest...

As super-user (either get a root shell, or use sudo in front of commands)

go into the /etc/grub.d directory.

cp 40_custom 06_karmic-first

Copy the karmic kernel boot entry from /boot/grub/grub.cfg into 
06_karmic-first

Example from my system:

menuentry "Ubuntu, Linux 2.6.31-17-generic" {
         recordfail=1
         if [ -n ${have_grubenv} ]; then save_env recordfail; fi
         set quiet=1
         insmod ext2
         set root=(hd1,2)
         search --no-floppy --fs-uuid --set 
c36d3e92-aa8f-4009-a5f3-cf520f89a8b2
         linux   /boot/vmlinuz-2.6.31-17-generic 
root=UUID=c36d3e92-aa8f-4009-a5f3-cf520f89a8b2 ro   clocksource=acpi_pm
         initrd  /boot/initrd.img-2.6.31-17-generic
}


Be aware that this will cause a duplicate entry for the Karmic kernel on 
your boot menu, but this one will always be on top.  Also, when Karmic 
has a kernel upgrade, you will have to update this file manually, 
otherwise, the system will by default boot into the old kernel.





More information about the ubuntu-users mailing list