Multiple OS Installation Jaunty

From

Jump to: navigation, search

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 boot 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 boot 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 stored in the boot partition.

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.

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 Settings -> Control Panel -> Administrative Tools -> 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), 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, somewhat limiting the ability to resize (shrink) the partition completely. You will be able to gain some hard drive from the "Shrink Volume" command (under Settings -> Control Panel -> Administrative Tools -> Computer Management -> Storage -> Disk Management), but not all of of the hard drive. I knew of no partition software that could move the MFT to a different place on the hard drive safely, but this tutorial suggested that Perfect Disk worked for this purpose. I therefore tried the trial version of Perfect Disk, and it seemed to work for me very nicely. I was able to shrink my Vista partition, using the steps in the tutorial (and Perfect Disk), from 300 Gb to 74 Gb. This was perfect for me.

Reinstalling Vista or Windows 7 on a new partition

A popular way to regain a significant amount of your hard drive with Vista/Windows 7 is to first re-format and re-partition the hard drive, then re-install Vista/Windows 7 second. When this works, you can reinstall Vista in as little as 30 Gb. (Why would I do this? By leaving Windows on a partition, I can test Linux-Windows compatibility/interactions between partitions. Also, if I later give away my computer to someone who insists on using Windows, it will still be installed.)

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

(Note: Not all Recovery disks will allow Windows re-installation to a newly re-sized partition. Although my eMachines, Dell, and Toshiba Recovery disks allowed it, my HP Recovery Disks did not. The HP Recovery disk, for example, erased the entire hard drive and recreated a single Windows partition. Any other partitions (and the data on them) were destroyed in the process. I therefore do not recommend using HP Recovery disks for this method. For HP computers, use the shrink volume method outlined above, instead).

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.

My OEM manufacturer (eMachines) had pre-installed both a primary partition and a recovery partition when I initially bought the computer. It is not necessary, however, to re-create these both of these partitions in order to re-install Vista from the Recovery disks; one partition for the re-installation is sufficient. As outlined below in my partitioning scheme, I reserved the first primary partition area (which you can either leave as free space at the beginning of the drive, or can format as an NTSC partition with the boot flag set, using GParted). Because I have a very large hard drive, I left 60 Gb for this first primary partition area that I planned to use as the Windows partition (although 40 Gb is probably more than enough, since my initial Vista re-install took only 22 Gb). The Recovery disks re-installed without problems, no matter which method I used (NTFS formatted partition or free space at the beginning of the drive), and I didn't have to worry about the MFT problem.

Obviously, this method would take an awful lot of work if you have been using your computer a long time. You would have to back up all your files first, and then re-install your add-on programs (again) after re-installing Vista/Windows 7. Then you would have to restore the files you had backed-up. It's much easier to do it with a new computer.

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 -> Continue

  • GRUB must be installed both on the MBR (master boot record) as well as locally on the partition being installed (in this example /dev/sda6). The local version will be chainloaded by the MBR version. Therefore, install GRUB a second time:

-> Go Back -> Install the GRUB boot loader on a hard disk -> "Install the GRUB boot loader to the master boot record?": NO -> Device for boot loader installation: /dev/sda6 -> Continue

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

Protecting Grub Legacy from cracking

Personal tools