Multiple OS Installation

From

These instructions are for installing more than two OS's on your hard drive. If you only need two operating systems (such as a Windows installation and a (K)ubuntu Linux installation), it is easiest to just use the (K)ubuntu installer to do it for you (as detailed on the main page).

Contents

Introduction

The method here involves creating a small partition in which to store the GRUB files. (These files will be copied from the from the GRUB files created by the first Ubuntu Linux OS installation.) The initial GRUB menu will be kept in this small partition and will be edited so that GRUB chainloads the bootloader files for whichever Windows, (K)ubuntu, or other Linux operating systems are installed.

Each operating system then can use the bootloader peculiar to it (which will remain contained within that OS' own partition). If the kernel or a bootloader filesystem for one OS changes, it does not affect the other operating systems or the primary GRUB bootup menu.

This avoids the problem that whenever a new OS (or distribution) is installed, it stores a GRUB configuration menu within its own partition, taking over the bootloader. It then becomes hard to remember in which partition resides the /boot/grub/menu.lst configuration file. With the chainloading method, you don't have to worry about that, anymore. Plus, it is easy to upgrade or replace an OS and not disturb the ability of other OS's to load.

Here is some info about this method:

Partition design

Three primary partitions and one extended partition are allowed on your hard drive. The extended partition can be divided into a very large number of logical partitions. Each Windows installation will need to be installed on a primary partition. All the Linux (including Ubuntu/Kubuntu) installations, though, can (and should) exist in logical partitions, so you can have as many as you want. The swap partition(s), also, can (and should) live on logical partitions.

Use Gparted

The easiest way to do this is to use the GParted Live CD as a partition manager. (See the main page for instructions how to obtain the GParted LiveCD).

  • At the minimum you will need:
  • one primary partition for each Windows OS
  • one primary partition for the small GRUB partition
  • an extended partition for the Linux OSs (must be the last partition on the hard drive)
  • I also usually create an extra small primary partition (which can be resized later, in case I need it). It is usually the third partition (because I always make the extended partition the last partition).
  • In general I make
  • my Windows partition 20 Gb -- filesystem type NTFS (or can be FAT32) and with the boot flag checked
  • my GRUB partition 50 Mb (or even less) -- formatted to filesystem type ext3
  • my "extra" partition 2 Gb -- which I tend to format as filesystem FAT32 (but can be anything, including ext3)
  • the extended partition is the remainder
  • At the end of the hard drive I usually leave a few Gb of free space (to allow for extra logical partition needs that I have not foreseen). This can't be done unless the extended partition is the last partition.
  • I then divide the extended partition into logical partitions:
  • a /swap logical partition that is 2 Gb -- filesystem type linux-swap
  • a logical partition for the / (root) folder of each planned OS (at least 10 Gb each, but 20-50 Gb each is better) -- formatted as ext3 (or ext4 if you are planning to use a cutting edge Linux OS)
  • a logical partition for a specific use, such as for a groupware partition (like Kolab, for example). I make this about 20 Gb and format it as ext3, since most specific uses (like Kolab) will be comfortable with ext3.

Note: If you are re-arranging (re-partitioning and re-formatting) your hard drive after already having a Grub bootloader installed, you will not be able to boot into Windows (or anything else) until you re-install Grub as part of a Linux OS re-installation. Panic not. Just proceed in a calm and orderly fashion. (Make a wish. Count to ten. Come with me, and you'll be...in a world of pure configuration.)

Windows partitions

It is easiest if your Windows partition is the first one installed.

If you have a brand new computer with no OS installed, things are much easier. Create your partitions (using GParted) before installing Windows. Make the first partition NTFS (or the less secure FAT32, if you wish), intending it for the Windows installation. Then divide the remainder of the hard drive (using GParted) using the partitioning scheme outlined above.

Generally, a retail "boxed" version of Windows (instead of an OEM or "backup" copy) installs quite happily to the first pre-configured, pre-sized partition. Go ahead and install it there, then skip on ahead to installing the Linux OSs.

However, OEM and "backup" copies of Windows often have installation peculiarities (including pre-configured spamware, spyware, and specific hardware configurations) that will want to use the entire hard drive. Oh well, if you must, you must.

After doing so, you will then have to shrink the partition down to approximately 20 Gb (or your desired size). See the warning below.

Changing Windows partition sizes

Using Shrink Volume on Vista and Windows 7

Make sure you read the warnings (on the main page) that you should change the size of Windows Vista and Windows 7 partitions from within Windows (after installation is complete) using Computer Management -> Storage -> Disk Management -> Shrink Volume.

You must then reboot those OSs (once or twice) to allow those OS's to adjust themselves to the partition size change (before using GParted for any other tasks). I have ruined several Windows installations by using GParted to resize the partitions for Windows Vista and Windows 7, or by forgetting to reboot Windows prior to using GParted.

Unlike Windows XP (and earlier Windows versions), however, Vista and Windows 7 does not allow you to move the MFT (Master File Table) that controls the NTFS file structure. Inexplicably, Microsoft locates this near the middle (or end) of the partition, limiting the ability to resize (shrink) the partition. You will be able to gain some hard drive from the "Shrink Volume" command (under Computer Management -> Storage -> Disk Management), but not the majority of the hard drive. I currently know of no partition software that will move the MFT to a different place on the hard drive safely.

Reinstalling Vista or Windows 7 on a new partition

The only way to regain a significant amount of your hard drive with Vista/Windows 7 is to re-format and re-partition the hard drive first, then re-install Vista/Windows 7.

For a re-installation, you will either need a retail version of Windows, or a "Recovery" disk provided by your OEM (computer) manufacturer.

For example, my eMachines box gave me the option of creating (burning) a pair of Recovery DVDs using eMachines -> eMachines Recovery Management. If your OEM manufacturer gives you a similar option of burning Recovery disks (instead of supplying Recovery CD/DVDs with your computer), make sure you burn these disks before reformatting/repartitioning your hard drive!

Windows XP (or earlier)

You can use GParted to resize a Windows XP partition directly (without needing re-installation), but it is still best to reboot Windows XP twice after resizing its partition (before taking any other steps with GParted).

Windows bootloaders

The Windows bootloaders store information about how big their partitions are. If you change the partition size, Windows checks the new partition size at the very next reboot (using either chkdsk in XP or a new utility in Vista/Windows 7). It then writes that info to its bootloader file. If you start mucking around with other partitions before it has a chance to reset itself, the Windows bootloader will not be able to read the partition table properly (and will refuse to boot entirely).

Since GRUB boots Windows merely by chainloading the Windows bootloader, if the Windows bootloader doesn't work (i.e. doesn't recognize its own changed partition), then you are sunk.

If you ignore these warnings, I almost guarantee you will fry your Windows partitioning scheme and be unable to boot up Windows.

Install your first Linux OS

I'm going to use (K)ubuntu for the example. (This is a (K)ubuntu-oriented site, after all.)

  • Reboot into the Ubuntu LiveCD (in my example I use the 32-bit Ubuntu Jaunty Server LiveCD).
  • Install Ubuntu server -> (the usual pleasantries about language and mice and keyboards and stuff)

--> "Starting up the partitioner" -> Partition Disks: Manual

  • When you see the list of partitions, you will have to configure them appropriately.
  • You should note the small partition that you will use as the partition for the GRUB chainloader files. In my example it is /dev/sda2. Make a note of what yours is named.
  • Configure the swap partition.
  • This shouldn't need configuring if you set it up properly with GParted.
  • You can make sure that Use as: swap area is set.
  • Configure the root partition for the OS. Choose one of your logical partitions, which in my scheme is #6, is ext3, and has about 30 Gb.
  • Use as: Ext3 journaling file system.
  • Format the partition: Yes, format it
  • Mount point: / - the root file system
  • Bootable flag: off
Note: You should write down which device the / (root) partition is on. You will need this information later for GRUB settings. On mine, it is /dev/sda6.

-> Finish partitioning and write changes to disk -> "Installing the base system" -> ... ->

->"Install the GRUB boot loader to the master boot record?": YES

Copy boot files to the small GRUB partition

  • Boot into your Linux OS. Open a command line terminal if you have installed a desktop.
  • Make a new directory and mount it in your new Ubuntu OS.
sudo mkdir /media/GRUBpartition
sudo mount /dev/sda2 -t ext3 /media/GRUBpartition
sudo mkdir /media/GRUBpartition/boot
sudo mkdir /media/GRUBpartition/boot/grub
Note: Use whatever the device name of your small GRUB partition is (mine is /dev/sda2)
  • Make sure there are full read/write write permissions (this step may be optional).
sudo chmod 777 /media/GRUBpartition/boot/grub
  • Copy all your grub files to the new partition
sudo cp -r /boot/grub/* /media/GRUBpartition/boot/grub
  • Edit the menu.lst
sudo nano /media/GRUBpartition/boot/grub/menu.lst
  • Place a chainloader entry as the first entry:
## ## End Default Options ##
title  First Ubuntu Jaunty Server OS (chainloader)
rootnoverify	(hd0,5)
chainloader	+1
title Second Ubuntu Jaunty Server OS (chainloader)
rootnoverify   (hd0,6)
chainloader    +1

This assumes your first installed OS has its / (root) directory in /dev/hda6 (as in my example above). GRUB counts the first partition as 0, so hda6 becomes (hd0,5), or hard drive 1 (it starts counting at zero), partition 6). If you want to chainload a bootloader on a second hard drive, partition 4 (/dev/hdb4), you would specify (hd1,3), instead, for example.

(I also put it an entry for my second planned OS, even though I haven't installed it yet. That will save me time later.)

  • Return the permissions so that only root can change or execute the files:
sudo chmod 744 /media/GRUBpartition/boot/grub
sudo chmod 744 /media/GRUBpartition/boot/grub/*

Reinstall GRUB to MBR

Now that the files are copied, we need to tell GRUB to look for them there. Do this step from your Linux OS command line terminal.

  • Start GRUB:
sudo grub
grub> find /boot/grub/stage1

You should see the places there are grub configuration files.

(hd0,1)
(hd0,5)

Note that (hd0,1) corresponds to the small GRUB partition (/dev/sda2), according to the counting method outline above. (hd0,5) corresponds to your first Linux OS (in the example /dev/sda6).

  • Make the small GRUB partition the loadable GRUB location.
grub> root (hd0,1)
grub> setup (hd0)
grub> quit

Install your second Linux OS

Again I'm going to use (K)ubuntu for the example.

  • Reboot into the Ubuntu LiveCD (again I use the 32-bit Ubuntu Jaunty Server LiveCD for this example).
  • Install Ubuntu server -> (the usual pleasantries about language and mice and keyboards and stuff)

--> "Starting up the partitioner" -> Partition Disks: Manual

  • When you see the list of partitions, you will have to configure them appropriately.
  • Configure the swap partition.
  • This shouldn't need configuring if you set it up properly with GParted.
  • You can make sure that Use as: swap area is set.
  • Configure the root partition for the OS. Choose one of your logical partitions, which in my scheme is #7, is ext3, and has about 30 Gb.
  • Use as: Ext3 journaling file system.
  • Format the partition: Yes, format it
  • Mount point: / - the root file system
  • Bootable flag: off
Note: You should write down which device the / (root) partition is on. You will need this information later for GRUB settings. On mine, it is /dev/sda7.

-> Finish partitioning and write changes to disk. (It is OK to format the swap and / (root) partitions.) -> "Installing the base system" -> ... ->

  • "Installing GRUB boot loader" ->
  • "Install the GRUB boot loader to the master boot record?": NO
  • "Install the GRUB boot loader on a hard disk": /dev/sda7
Use whichever device that corresponds to your / (root) directory for this OS, of course.
This ensures that the GRUB bootloader is installed to this OS's partition, as well.
  • Finish installation and reboot. This system ought to be selected as the Second Ubuntu Jaunty OS, obviously.
  • Note: Once you have booted into this OS, you can now edit the chainloaded GRUB bootloader's local settings for this OS (at /boot/grub/menu.lst) as usual, as you can for the first installed OS as well.

Changing main GRUB boot menu settings

  • You can change the local (chainloaded) GRUB boot menu for each Linux OS (within the partition in which it is installed):
sudo nano /boot/grub/menu.lst
  • To change the main GRUB boot menu, you will have to change the menu.lst found on the small GRUB partition.
  • If you are doing this from a Linux OS other than the first one you installed, again make a new directory for mounting:
sudo mkdir /media/GRUBpartition
  • Mount the directory
sudo mount /dev/sda2 -t ext3 /media/GRUBpartition
Note: Use whatever the device name of your small GRUB partition is (mine is /dev/sda2)
  • Make sure there are full read/write write permissions (this step may be optional).
sudo chmod 777 /media/GRUBpartition/boot/grub/menu.lst
  • Edit the menu.lst
sudo nano /media/GRUBpartition/boot/grub/menu.lst
  • Edit or add new chainloader entries:
## ## End Default Options ##
title  First Ubuntu Jaunty Server OS (chainloader)
rootnoverify	(hd0,5)
chainloader	+1
title Second Ubuntu Jaunty Server OS (chainloader)
rootnoverify   (hd0,6)
chainloader    +1
title Newest Whizbang OS on second hard drive, partition 4 (chainloader)
rootnoverify   (hd1, 3)
chainloader    +1
GRUB starts counting from 0, so the first hard drive is number 0 and the first partition is also number 0. hda6 (which is hard drive 1, partition 6) becomes (hd0,5). If you want to chainload a bootloader on a second hard drive, partition 4 (/dev/hdb4), you would specify (hd1,3).
  • Return the permissions so that only root can change or execute the files (this step may be optional):
sudo chmod 744 /media/GRUBpartition/boot/grub/menu.lst

Add MacOSX entry

You can add a chainloader entry for a MAC OS that you might have installed on its own partition (installed with its own bootloader on the partition). Here's the entry for a MAC that is on partition /dev/sda9 (equivalent to (hd0,8):

title Mac OS X
root (hd0,8)
makeactive
chainloader +1