Grub2 setup question

Jamon Camisso jamon.camisso-H217xnMUJC0sA/PxXw9srA at
Thu Nov 19 03:37:48 UTC 2009

Madison Kelly wrote:
> Hi all,
>   So I'm back to square one in my understanding of grub with v2. I'm 
> hoping someone can help me out and/or point me to a decent tutorial on 
> the new system.
>   I've picked up an eSATA drive that I've installed CentOS5 on. I did 
> this with my main Ubuntu 9.10 hard drive unplugged just to be sure that 
> I didn't accidentally muck it up. So now I am finished the install and 
> back under Ubuntu.
>   I've trying to sort out how to add the CentOS install to my Ubuntu's 
> grub. I dare not randomly try things as I normally would, given the 
> potential of an unbootable system.
>  So, given:
> /dev/sda (hd0,x) = Ubuntu
> /dev/sdb (hd1,x) = CentOS
>   What is the safe way of setting up grub with an option to boot off the 
> second drive?

The annoying part is that with grub2, partitions start at 1 instead of 0 
now, e.g. I have a /boot partition that used to be hd0,0 and is now 
hd0,1 with grub2. Take a bit of getting used to.

With a /boot partition on /dev/sdb that is the first partition on a 
disk, entries would look like this (use UUID or LABEL for root= devices 
to be sure you are using the right disk(s)):

menuentry "Ubuntu foo" {
    insmod ext2
    set root=(hd0,1)
    linux   /boot/vmlinuz-foo root=/dev/sda1
    initrd  /boot/initrd.img-foo
menuentry "Centos foo" {
    insmod ext2
    set root=(hd1,1)
    linux   /boot/vmlinuz-foo root=/dev/sdb1
    initrd  /boot/initrd-foo.img

This assumes you have the whole installation on one partition which is 
likely not the case? If you have a separate /boot partition, each 
linux/initrd entry doesn't need the leading /boot part. And like I said, 
use UUIDs or LABELs to keep from getting partitions confused.

I'd expect your Centos install is using LVM whereas Ubuntu is not, so 
you'd probably just end up with a busybox shell once the Centos initrd 
got to the point of switchroot failing :) But it is easy to avoid that 
problem entirely.

HTH, Jamon
The Toronto Linux Users Group.      Meetings:
TLUG requests: Linux topics, No HTML, wrap text below 80 columns

More information about the Legacy mailing list