Home   Profile   Fun
#109 Linux  03.04.2007

How to configure grub for several linux installations on one hard drive


For a standard linux installation you may use three primary partitions. One for /boot, one for / and another one for the swap partition. Per hard drive there is a limit of four primary partitions. But for the second installation we need another three partitions at least. So we create an extended partition with three logical partitions on it.

The disk layout (fdisk /dev/hda) now looks similar to this:

/dev/hda1   *           1        1200     9638999+  83  Linux
/dev/hda2            1201        1346     1172745   82  Linux swap / Solaris
/dev/hda3            1347        4346    24097500   83  Linux
/dev/hda4            4347        7296    23695875    5  Extended
/dev/hda5   *        4347        4359      104391   83  Linux
/dev/hda6            4360        4484     1004031   82  Linux swap / Solaris
/dev/hda7            4485        5701     9775521   83  Linux

The configuration for the second linux system in grub.conf is slightly different. After the first two lines there is the configuration for the first installed linux system. This is how it looks for a standard gentoo linux installation. The third part is for the second linux system which resides on /dev/hda5, /dev/hda6 and /dev/hda7.

default 0
timeout 5

title Gentoo hda1-3 genkernel-x86-2.6.17-gentoo-r4
root (hd0,0)
kernel /boot/kernel-genkernel-x86-2.6.17-gentoo-r4 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/hda3 udev vga=791
initrd /boot/initramfs-genkernel-x86-2.6.17-gentoo-r4

title Gentoo hda4,5-7 genkernel-x86-2.6.17-gentoo-r4
rootnoverify (hd0,6)
chainloader +1
root (hd0,4)
kernel /boot/kernel-genkernel-x86-2.6.17-gentoo-r7 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/hda7 udev vga=791
initrd /boot/initramfs-genkernel-x86-2.6.17-gentoo-r7