Grub2 setup question

Madison Kelly linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org
Thu Nov 19 21:43:00 UTC 2009


Jamon Camisso wrote:
> 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

Thanks Jamon,

   I am trying to avoid directly editing files unless that is what I am 
supposed to do. The reason being that when a new kernel is released now, 
the grub tools rerun and regenerate the boot.cfg file. I see that there 
is now an '/etc/grub.d/' directory that I think I am supposed to work with.

   After sending the email, I came across a doc that said to run 
'update-grub2'. When I do this with the CentOS drive connected, it shows 
it but when I reboot, the entry isn't in grub:

----------------------------------------------
root at lework:/etc/grub.d# update-grub2
Generating grub.cfg ...
Found Debian background: Windbuchencom.tga
Found linux image: /boot/vmlinuz-2.6.31-14-generic
Found initrd image: /boot/initrd.img-2.6.31-14-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows Vista (loader) on /dev/sda1
Found CentOS release 5.3 (Final) on /dev/sdb3
done
----------------------------------------------

'cat'ing 'grub.cfg' then shows the usual (headers skipped):

----------------------------------------------
### BEGIN /etc/grub.d/10_linux ###
menuentry "Ubuntu, Linux 2.6.31-14-generic" {
         recordfail=1
         if [ -n ${have_grubenv} ]; then save_env recordfail; fi
	set quiet=1
	insmod ext2
	set root=(hd0,3)
	search --no-floppy --fs-uuid --set a5597100-8f9c-4dc6-a023-d67f5a5023e6
	linux	/boot/vmlinuz-2.6.31-14-generic 
root=UUID=a5597100-8f9c-4dc6-a023-d67f5a5023e6 ro   quiet splash
	initrd	/boot/initrd.img-2.6.31-14-generic
}
menuentry "Ubuntu, Linux 2.6.31-14-generic (recovery mode)" {
         recordfail=1
         if [ -n ${have_grubenv} ]; then save_env recordfail; fi
	insmod ext2
	set root=(hd0,3)
	search --no-floppy --fs-uuid --set a5597100-8f9c-4dc6-a023-d67f5a5023e6
	linux	/boot/vmlinuz-2.6.31-14-generic 
root=UUID=a5597100-8f9c-4dc6-a023-d67f5a5023e6 ro single
	initrd	/boot/initrd.img-2.6.31-14-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
	linux16	/boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
	linux16	/boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows Vista (loader) (on /dev/sda1)" {
	insmod ntfs
	set root=(hd0,1)
	search --no-floppy --fs-uuid --set a418a94d18a91ef4
	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.
### END /etc/grub.d/40_custom ###
----------------------------------------------

If I am to add your suggestion directly, where would be safest?

Madi
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list