Saturday, 16 August 2008

Multi Boot Linux and OpenSolaris

In this post I'll describe how I set up my laptop to be a multi boot environment with OpenSolaris, Ubuntu, Fedora and OpenSUSE.

UPDATE: This guide was created when almost all Linux distro's were using GRUB as their boot loader. Recently there has been a big move to GRUB2 and the following article needs to be updated.

First of all we need to know some things

1. You can only have up to 4 primary partitions on a hard drive
2. A linux swap partition has the same identifying code as a Solaris partition. This means that linux systems will see the partition as a swap partition. It also means that in order to install OpenSolaris any linux swap partitions should come after the Solaris partition.
3. Due to using ZFS, OpenSolaris uses a modified version of GRUB.

Preparing Partitions:
The way I set up my partitions is as follows

The first partition is very small and will be used at boot time to show a menu selecting which OS to boot. The second partition is the OpenSolaris partition, its being recognised as a swap partition by gparted. Then we have one large extended partition, which holds a partition for swap and then seperate partitions for each flavour of linux. The 20Gb partition at the end of the extended partition holds data which needs to be accessible by all OS's and I have left some free space on the extended partition, in case the data partition needs to grow or I feel like adding another OS.

After setting up the disk like this, go ahead and install OpenSolaris on the second partition. Solaris will write to the MBR (Master Boot Record) of the drive and point it to the grub install on its partition. Next install Ubuntu and make sure that when it comes to the partitioner stage of the install choose to do a manual setup. Choose to use the smaller swap partition on the extended partition as the swap, do not use the OpenSolaris partition as swap. Also use the first ext3 partition on the extended partition as the root partition i.e. '/'. Also you must specify to the Ubuntu install to install grub to the root partition, not to alter the MBR. At this point when you reboot your computer you will still only get the OpenSolaris grub menu, because we haven't altered the MBR.

Next we have to pop in a linux live cd, copy over the /boot/grub directory from the Ubuntu partition onto the first partition on the disk, modify the menu.lst file and then set up the MBR to point to it. This is called setting up a dedicated grub partition and is described better here. For the Linux partitions I used the 'configfile' directive in grub's menu.lst, however because grub can't see the OpenSolaris partition, for the OpenSolaris entry you have to use the 'chainloader' directive i.e.

title OpenSolaris 2008.05
rootnoverify (hd0,3)

chainloader +

Installing Fedora and OpenSUSE, we follow the install, making sure that we install them to the correct partitions, and specify that they shouldn't use the OpenSolaris partition as swap, but instead use the other one and that they don't install grub to the disk MBR, but only install it to the local partition. Then we have to modify the menu.lst file on the dedicated grub partition to point to the new OS's we've just installed.

And that's it. We now have a multi boot computer consisting of OpenSolaris and three different flavours of linux.