Configuring GRUB for Linux-Linux Multibooting

There is plenty of info on the net about configuring GRUB's menu.lst to multiboot with Linux and Windows on separate partitions, but hardly any documents on straight Linux-Linux multibooting. This is probably because it's so easy. But for people who have a hard time decoding the man (or in this case, info) page, this document gives a simple annotated example of the requisite menu.lst file.

The reason I had to set up GRUB is because I was trying out several native Chinese versions of Linux, having failed to set up Chinese input on RedHat 8 or 9. Hence the names of the other distros.

# grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/hda7 # initrd /initrd-version.img #boot=/dev/hda # By default boot the first entry default=0 # Fallback to the second entry #fallback=1 # Boot automatically after 10 seconds timeout=10 #splashimage=(hd0,2)/boot/grub/redflag.xpm.g splashimage=(hd0,0)/grub/splash.xpm.gz # Red Hat Linux 9.0 title Red Hat Linux (2.4.20-8) root (hd0,0) kernel /vmlinuz-2.4.20-8 ro root=LABEL=/ hdc=ide-scsi initrd /initrd-2.4.20-8.img # Red Flag Linux 3.2 title Red Flag Linux (3.2) root (hd0,2) kernel (hd0,2)/boot/vmlinuz-2.4.17-1 root=/dev/hda3 hdc=ide-scsi initrd=(hd0,2)/boot/initrd-2.4.17-1.img # XTeam Linux (4.0) title XTeam Linux (4.0) root (hd0,7) kernel (hd0,7)/boot/vmlinuz-2.4.6-3xtm root=/dev/hda8 hdc=ide-scsi initrd=(hd0,7)/boot/initrd-2.4.6-3xtm.img

A few clarifications


This is GRUB's notation for partitions on the hard drive. Apparently, it's not unusual to have several drives in a single computer. For the single hard drive user, hd0 means the first hard drive, and the number after the comma indicates the partition (0 being the first, 1 being the second, and so on). On my hard drive, GRUB's notation and my partitions lined up like this:

GRUB Partition
(h0,0) /dev/hda1
(h0,1) /dev/hda2
(h0,2) /dev/hda3
(h0,3) /dev/hda4
(h0,4) /dev/hda5

A useful command to find out what partitions exist on your hard drive is /sbin/fdisk -l

Disk /dev/hda: 80.0 GB, 80060424192 bytes 255 heads, 63 sectors/track, 9733 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 13 104391 83 Linux /dev/hda2 14 2563 20482875 83 Linux /dev/hda3 2564 2946 3076447+ 83 Linux /dev/hda4 5114 9733 37110150 f Win95 Ext'd (LBA) /dev/hda5 9677 9733 457821 82 Linux swap /dev/hda6 5114 6388 10241374+ 83 Linux /dev/hda7 6389 7663 10241406 83 Linux /dev/hda8 7664 8301 5124703+ 83 Linux Partition table entries are not in disk order


This line tells GRUB what background to use on the startup screen where you choose what OS to boot into. Beware, if this line fails (your image is invalid) then GRUB will bypass the selection process and just boot into your first OS, in the example Red Hat 9. In the example, notice that the the picture is in the grub folder of the first partition.

title Red Hat Linux (2.4.20-8)

The title line tells GRUB what to print on the selection screen for each OS. This can really be whatever you want: Red Hat, Blue Socks, Winblows or The Greatest OS On The Planet.

root (hd0,0)

This line tells GRUB where the bootloader's root directory for each OS exists. In this case, notice that the Red Hat bootloader was installed on its own partition, the very first one on the disk. This corresponds to /dev/hda1. This is where the files needed to load the kernel reside.

Note: on my box, Red Hat set up a separate partition for its bootloader ((hd0,0) or /dev/hda1 and mounted in the root directory as /boot), while the other operating systems put their own bootloader directory on their primary partitions. This was nice, because I could boot into Red Hat, mount the partitions of the other distros, copy their grub.conf entries into the menu.lst on (hd0,0) and reboot. Something like this:

# su Password: $ mkdir /mnt/redflag $ mount /dev/hda3 /mnt/redflag/ $ more /mnt/redflag/boot/grub/grub.conf hiddenmenu timeout=10 splashimage=(hd0,2)/boot/grub/redflag.xpm.gz default=0 title linux root (hd0,2) kernel (hd0,2)/boot/vmlinuz-2.4.17-1 root=/dev/hda3 vga=0x301 console=ttyS0 CONSOLE=/dev/tty2 5 initrd=(hd0,2)/boot/initrd-2.4.17-1.img

However, it was also a little annoying because each new distro would hijack the bootloader, so I had to keep my RH9 discs around and re-install the bootloader each time. There may have been an option to avoid this during the installs, but I may have missed it because my Chinese is not perfect!

kernel /vmlinuz-2.4.20-8 ro root=LABEL=/ hdc=ide-scsi

This line tells GRUB where to find the kernel, and what options to pass to the kernel. Notice that, while the other kernels are located in partition/boot/, since Red Hat put the bootloader on its own partition named boot, the boot directory is already the root directory. I don't know what the ro option does. Also unique to Red Hat is the LABEL=/, which means that the partition slated to be root for Red Hat file system is labelled as /. Finally, the hdc=ide-scsi option was automatically appended by RH, and has something to do with the CD-ROM drive and SCSI emulation.

initrd /initrd-2.4.20-8.img


This line tells the bootloader where the initrd procedure is located. I'm not sure if the equal-sign makes a difference; Red Flag Linux had it and I've left good-enough alone. I'm also not sure if the (hd0,2) was necessary. Another case of good-enough.


In conclusion, GRUB is really not that hard to set up for a basic Linux-Linux(-Linux) multiboot. I'm sure there's a lot more to learn regarding Windows multiboots, kernel versions and such; and I remember one of the Red Hat Certified Engineers at the last OCLUG meeting saying that it's vital to learn your way around GRUB before taking the Red Hat certification tests.

Last updated 2003.5.31