Dual boot two CentOS 5.7 installations

General support questions including new installations

Dual boot two CentOS 5.7 installations

Postby vtechv » 2011/12/07 16:02:25

How can I modify grub to allow me to dual boot two CentOS 5.7 installs?

I have two hard drives, 80GB and 250 GB. I want two instances of CentOS using part of the 80GB drive for / of each instance, and part of the 250GB drive for /var of each. I loaded CentOS 5.7 twice, but on the second attempt I can't modify grub to allow access to the first. If I reload the first I can't modify grub to allow access to the second. I keep getting a message from the grub cli that says the file can not be found. I can mount the unused partitions and see the files. For example, if I'm using the second instance, which is on /dev/sda3, I can mount /dev/sda1 and see the files and directories I made. From what you see below, I believe the problem lies in the statement that I don't have a /boot partition. Also, notice that the * in the Boot column shows /dev/sda1 even though I'm actually using /dev/sda3 to boot from. I'm a little lost with this one, but have tried a number of grub configs for the last two days with no success. I appreciate any advice you can give. If I wasn't clear, please ask.




An fdisk -l while the second instance is working looks like:
Code: Select all
[root@localhost ~]# fdisk -l

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device    Boot      Start         End         Blocks      Id   System
/dev/sda1   *            1        4590    36864000      83   Linux
/dev/sda2            9328        9730     3227649       5    Extended
/dev/sda3            4591        9327    38049952+   83   Linux
/dev/sda5            9328        9730     3227648      82   Linux swap / Solaris

Partition table entries are not in disk order

Disk /dev/sdb: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start           End          Blocks   Id  System
/dev/sdb1   *           1         15936   128000000   83  Linux
/dev/sdb2           15937       30400   116182080   83  Linux


grub.conf when I have the first instance working
Code: Select all
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,0)
#          kernel /boot/vmlinuz-version ro root=/dev/sda1
#          initrd /boot/initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,2)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS5dot7FPTAst02 (2.6.18-274.el5)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.18-274.el5 ro root=LABEL=/1
        initrd /boot/initrd-2.6.18-274.el5.img


grub.conf when I have the second instance working:
Code: Select all
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,2)
#          kernel /boot/vmlinuz-version ro root=/dev/sda3
#          initrd /boot/initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,2)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS5dot7FPTAst02 (2.6.18-274.el5)
        root (hd0,2)
        kernel /boot/vmlinuz-2.6.18-274.el5 ro root=LABEL=/
        initrd /boot/initrd-2.6.18-274.el5.img


grub.conf when I have the second instance working with modifications to attempt access to the first instance (two attempts that don't work):
Code: Select all
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,2)
#          kernel /boot/vmlinuz-version ro root=/dev/sda3
#          initrd /boot/initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,2)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS02 (2.6.18-274.el5)
        root (hd0,2)
        kernel /boot/vmlinuz-2.6.18-274.el5 ro root=LABEL=/
        initrd /boot/initrd-2.6.18-274.el5.img

title CentOS01 (2.6.18-274.el5)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.18-274.el5 ro root=LABEL=/1
        initrd /boot/initrd-2.6.18-274.el5.img

title CentOS5dot7FPTAst02 (2.6.18-274.el5)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.18-274.el5 ro root=/dev/sda1
        initrd /boot/initrd-2.6.18-274.el5.img
[Moderator edit: Added code tags to preserve formatting.]
vtechv
 
Posts: 1
Joined: 2011/12/07 14:32:49

Dual boot two CentOS 5.7 installations

Postby pschaff » 2011/12/12 20:07:31

For any kind of multi-boot Linux I find it easier to designate one install as the "master" for GRUB and write its bootloader to the MBR, and to write any subsequent boot records to the boot partition[s] (in your case also the root) and chainload the other GRUB instance[s]. This avoids a lot of issues like having to manually update the master grub when new kernels are installed on the other instance[s].

I also note that the splash image is coming from /dev/sda3 regardless of the root device. I'd make the instance on /dev/sda1 the "master" and the one on /dev/sda3 the "slave".

Code: Select all
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,0)
#          kernel /boot/vmlinuz-version ro root=/dev/sda1
#          initrd /boot/initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS5 Master (2.6.18-274.el5)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.18-274.el5 ro root=LABEL=/1
        initrd /boot/initrd-2.6.18-274.el5.img
title CentOS Slave
        root(hd0,2)
        chainload +1


Follow How to re-install bootstrap code (GRUB) to write the bootloader to /dev/sda3.

If more help is needed then please provide more information about your system by running "./getinfo.sh disk" and showing us the output file.

P.S. As an alternative to dual-boot you might want to consider whether Virtualization might satisfy your needs.
pschaff
Retired Moderator
 
Posts: 18277
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America


Return to CentOS 5 - General Support

Who is online

Users browsing this forum: No registered users and 0 guests