A new OS experience


Multiboot With Standalone GRUB

Yesterday I came to realize that I needed a simpler way to boot multiple OS-es on my laptop. My requirements were:

  1. Have an independent boot loader on the MBR
  2. Have a partition for swap
  3. Separate data partition for file storage
  4. Partitions for the multiple OS-es
To accomplish this task a simple menu file is created to chainload each respective OS. That way, should I decide to remove a distro, I could just reformat the drive and remove its entry on the main bootloader. Using an Ubuntu live CD, I accessed a terminal console and logged in as root.

First, I wrote zeros all over the drive to make sure there would be no conflicts or previous data read by the various partitions. Of course, I backed up any previous files I had. WARNING: this command will WIPE all the data on the drive!

ubuntu#: dd if=/dev/zero of=/dev/sda

Next I created a 512 byte MBR partition sector, again writing zeros for redundancy:

ubuntu#: dd if=/dev/zero of=/dev/sda bs=512 count=1

Next, I created the necessary partitions by accessing the fdisk utility:

ubuntu#: fdisk /dev/sda

For the first partition I allocated 1GB (1024M) of space to use as swap. The good thing about Linux is that you only need one of these which can be accessed by any distro installed:

  1. n to create a new partition
  2. p to make it a primary partition
  3. 1 to give it a designation number (as in /dev/sda1
  4. to accept beginning sector
  5. +1024M to set size and ending sector
  6. t to select partition type
  7. 1 to select the first partition
  8. 82 to designate it as Linux swap

Second, I created a small 100M partition for the boot loader:

  1. n to create a new partition
  2. p to make it a primary partition
  3. 2 to designate it as the second partition
  4. to accept beginning sector
  5. +100M to set size and ending sector

These first two partitions are primary partitions. The rest are going to be logical partitions, since you cannot have more than 4 primary partitions on a single drive. I want 4 partitions where I can install the OS-es and 1 partition to use as file storage:

  1. n to create a new partition
  2. e to make it an extended partition
  3. 3 to designate it as the third partition. This is just a container for the logical partitions. Also, logical partitions start from 5 and above
  4. to accept beginning sector
  5. to set size and ending sector of the rest of the drive.
  6. n to create a new partition
  7. l to make it a logical partition; it will be designated partition 5 (/dev/sda5)
  8. to accept the beginning sector
  9. +10240M to set the 10GB size
  10. n to create a new partition
  11. l to make it a logical partition
  12. 6 to designate it as the sixth drive
  13. +10240 to set the size of 10GB
  14. Do the same for partitions 7 and 8
  15. For partition 9 do steps 10, 11, and 12 (designate it as 9), but hit <> for beginning and ending sectors.
  16. Once done setting up the partitions, enter w to write changes to the MBR and make them permanent

Now that the partitions are set up it is time to install the OS-es. I chose:

  • Kubuntu 7.10 Gutsy
  • Kubuntu 8.10 Intrepid Ibex
  • Debian Etch
  • Slackware 12.2

With the exception of Debian which uses XFCE, the other three distros use KDE, which I must say looks sweet in its latest version 4.1.

The first thing to do is to get GRUB running. For this a live CD will do. Once the live CD is loaded, I copied the grub section from the boot section of the CD to the second partition, after formatting that partition.

kubuntu#: mkdir /mnt/sda2
kubuntu#: mount /dev/sda2 /mnt/sda2
kubuntu#: mkdir /mnt/sda2/boot
kubuntu#: mkdir /mnt/sda2/boot/grub
kubuntu#: mkfs -V -t ext3 /mnt/sda2
kubuntu#: find / -name stage1
kubuntu#: cp /usr/lib/grub/i386-pc/* /mnt/sda2/boot/grub
kubuntu#: grub
> root (hd0,1)
> setup (hd0)
> quit

After this it's time to create the custom GRUB menu file:

kubuntu#: nano /mnt/sda2/boot/grub/menu.lst
Kubuntu 7.10 Gutsy on /dev/sda5
chainloader +1
Kubuntu 8.10 Ibex on /dev/sda6
root (hd0,5)
chainloader +1
title Debian Etch on /dev/sda7
root (hd0,6)
chainloader +1
title Slackware 12.2 on /dev/sda8
root (hd0,7)
chainloader +1

Important: I had to make sure that during each installation I instructed the installer to install the boot loader on the root directory of the respective partitions and not on the MBR as it will override our above step. For (K)ubuntu go through the installation until the installer asks you if you're ready to install. Before doing so click Advanced, check install boot loader, and enter the GRUB location of the partition [e.g. for /dev/sda5 it's (hd0,4)]. Do the same for Debian and Slackware.

: I got this how to from user saikee in justlinux.com forum.

No comments: