Dual Booting Howto

Multi OS Booting

Recently my brother Robert wanted to have the ability to boot to different Operating Systems, normally I would never entertain such a practice with something so alien, but he is my brother so I conceded to his request reluctantly. There are many ways with which you can accomplish Multi Boot, not least directly from the Installation/LiveCD itself. After installation of any alternative Operating System and before installation of Ubuntu please ensure you "defragment" your OS partition or OS partitions.

Method One

  • Partition the drive as desired using "fdisk" (Linux version) or other suitable partition manager the dos or Windoz version whilst being able to partition a drive will not allow for the setting of file types for any given written partition.
  • Install alternative OS to use a single partition previously defined
  • Boot Ubuntu LiveCD
  • Run install icon from Desktop
  • Configure Ubuntu for automatic installation

With an alternative OS installed to a pre-partitioned drive, boot off the LiveCD and run the install icon on the desktop.

The above is the least complex of possible methods such installation is in the 'lap of the Gods' though as you have zero control, however that said Ubuntu should find you alternative OS and Install Ubuntu to a vacant partition on your Hard disk.

Method Two

I believe it possible that Ubuntu will resize your partition and install Ubuntu automatically this is something I have not tried so make sure you have backups and have the means to re-install your OS if it fails, use one of the other alternatives if necessary.

Method Three

My preferred installation method allows you to control where your OS or various OS's will boot from. Imagine if you will a disk with many Operating systems to its name and you want to be able to boot from each of them, hopefully you will choose Linux flavours but this is not essential. The first problem to overcome from is the partition limit of the hard disk. You may need or want to increase the number of partitions you use from its default of four (4) partitions.

Use any suitable partition manager you like, all will only have a maximum of four (4) primary partitions this is due to the limitation of the Hard Disk itself. All partition managers however come with a means to overcome this limitation using Extended partition sizing to use this feature you must first create all your primary partitions first leaving at least one for the partition for which you wish to extend, an extended partition can then be created with as many extended partitions as you wish within that primary partition just determine it size. You may be unfamiliar with the console version of partition manager but from my point of view it is still the best.

  • Open a console session
  • Type in console the following command "sudo fdisk /dev/sda" or "sudo fdisk /dev/hda"
    • Notice that no partition number has been specified this is because we will address the entire drive not just a portion of it.
    • Scsi (Small Computer System Interface) and Sata (Serial Advanced Technology Attachment) disks use the "sda" notation
    • Ide (Intergrated Drive Electronics) disks use the "hda" notation
    • You can use "sudo fdisk -l" (minus ell) this detects and list all attached and identified drives using this infromation
    • WARNING!! fdisk is an extremely powerful tool, it can destroy all your data and contents of any writable attached drive, for this reason be aware that no change takes place until you commit and write your changes to the disk itself.

fdisk

  • run fdisk in a console session

fdisk -l

"fdisk" uses the following commands which comprise of a single letter followed by the enter key

  • m <enter> list all available commands
  • p <enter> lists to the display all partition for selected drive
  • n <enter> create a new partition <primary> or <extended> only available in create (n)
    • <primary> followed by partition Number, limit four partitions only
    • <extended> followed by <enter> next available number used unlimited partitions
  • d <enter> followed by <number> <enter> deletes selected partition
  • a <enter> followed by <number> <enter> select a boot flag for given partition
  • t <enter> followed by <number> partition number followed by hex number <hex code> press l (ell) <enter> for list

For a list of available options view the image bellow

fdisk m option | fdisk (p option) | fdisk (t option) | fdisk (t then l option)

Deleting existing partitions using "fdisk" couldn't be much simpler when in fdisk press d for delete and the partition number you wish deleted. If you were to look at the display image marked fdisk (p option) you will see the disk partitions which has four (4) partitions defined all are primary, I personally have no need for more because I have no need to dual boot. However that said I do separate my data from my OS so I can always recover the data and anything else that might corrupt with it.

  • /dev/sda1 partition (this is /boot) and will be between 512Mb to 1024Mb
  • /dev/sda2 partition nearly always (swap) about 512Mb no need for more
  • /dev/sda3 partition varies but will be no more than 10Gb for (/) or "root"
  • /dev/sda4 partition is always (/home)

All these can be deleted in favour of your new disk partition management which for multi boot could look like this.

  • /dev/sda1 between 512Mb & 1Gb (/boot)
  • /dev/sda2 512Mb more than enough for (swap)
  • /dev/sda3 here we begin to hit a problem we are on the third primary partition at least one of which needs to be extended to coupe with other OS so decide on your size for (/home) in Gb and set this here.
  • /dev/sda4 all of the remainder of the disk will be set for your other OS's which you then need to define as extended setting the size for each subsequent partition not the partition number, this is automatically incremented. from 5 onwards until partition 4 is full.
  • /dev/sda5 first alternative OS size preset
  • /dev/sda6 second alternative OS size preset
  • /dev/sda7 Ubuntu OS size preset

It should not matter in the slightest which partition your chosen OS is installed to, and certainly not Ubuntu just commit your changes to favour your new disk partition settings and install the new OS to the selected partition and not where the OS wants to install to. I other words select manual installation for all given OS's.

Something else that may help you is the command to set the size of each partition you create.

  • First cylinder (1-7296, default 1):<enter> accept default
  • Last cylinder or +size or +sizeM or +sizeK (1-7296, default 7296): +1G <enter>
    • You will notice "+1G" this is what you type if it was 10 Gig then you would use "+10G" for the swap you need to specify additional parameters for Linux to understand it is swap but setting it size is done by using "+512M" repeat the sequence for each given partition.
  • To use the extended partition select a partition number not used and accept all defaults, all extended partitions created in the extended partition will use up segments of the full extended partition consecutively.

e
Selected partition 4
First cylinder (2620-7296, default 2620):
Using default value 2620
Last cylinder or +size or +sizeM or +sizeK (2620-7296, default 7296):
Using default value 7296

Command (m for help): n
First cylinder (2620-7296, default 2620):

Look above "e" has been selected so partition 4 being the last remaining partition is now exclusively set as an extended partition, accept the default values presented. Pressing n <enter>(new) from this point all we need do is determine the size of each new partition thus:

First cylinder (2620-7296, default 2620):
Using default value 2620
Last cylinder or +size or +sizeM or +sizeK (2620-7296, default 7296): +10G

First cylinder (3837-7296, default 3837):
Using default value 3837
Last cylinder or +size or +sizeM or +sizeK (3837-7296, default 7296): +10G

First cylinder (5054-7296, default 5054):
Using default value 5054
Last cylinder or +size or +sizeM or +sizeK (5054-7296, default 7296): +10G

First cylinder (6271-7296, default 6271):
Using default value 6271
Last cylinder or +size or +sizeM or +sizeK (6271-7296, default 7296): +10G
Value out of range.
Last cylinder or +size or +sizeM or +sizeK (6271-7296, default 7296):

Here we have hit the limit and no further +10G partitions can be created, so all you can do is accept the default with <enter>

Press "p" and <enter> to display the table you have created

Command (m for help): p

Disk /dev/sda: 60.0 GB, 60011642880 bytes
255 heads, 63 sectors/track, 7296 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xf95c674c

   Device Boot      Start         End      Blocks   Id  System<br />
/dev/sda1 1 123 987966 83 Linux
/dev/sda2 124 186 506047+ 83 Linux
/dev/sda3 187 2619 19543072+ 83 Linux
/dev/sda4 2620 7296 37568002+ 5 Extended
/dev/sda5 2620 3836 9775521 83 Linux
/dev/sda6 3837 5053 9775521 83 Linux
/dev/sda7 5054 6270 9775521 83 Linux
/dev/sda8 6271 7296 8241313+ 83 Linux

Command (m for help):

Now remember /dev/sda3 is now the /home so having this as Linux partition is ok, it also means all other linux Operating Systems can see mount and share this partition which might be useful with Multi booting between OS's. However some of the other partitions are not set with the correct file system you will need to use the "t" option select a partition number and define its file system via a unique hex number you want used. For instance I would normally select the swap partition with swap file system to do this in fdisk (Linux version fdisk not dos) I would do the following.

  • t <enter> partition <number> <enter>
  • l <enter> displays the available hex codes for each file system find the swap label its hex code is 82

Now repeat the same sequence for any given OS you want to install, find its label and enter the corresponding hex code associated with that label.

One remaining thing to do is to set the boot flag on the boot partition this being /dev/sda1 or (/boot)

  • Select "a" <enter> partition <number> <enter> define which partition to boot from as we are booting using grub this will always be the first partition of the drive /dev/sda1 grub then boots to whichever OS you want to use via a menu.

Command (m for help): p

Disk /dev/sda: 60.0 GB, 60011642880 bytes
255 heads, 63 sectors/track, 7296 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xf95c674c

   Device Boot      Start         End      Blocks   Id  System<br />
/dev/sda1 * 1 123 987966 83 Linux
/dev/sda2 124 186 506047+ 82 Swap
/dev/sda3 187 2619 19543072+ 83 Linux
/dev/sda4 2620 7296 37568002+ 5 Extended
/dev/sda5 2620 3836 9775521 52 CP/M
/dev/sda6 3837 5053 9775521 7 HPFS/NTFS
/dev/sda7 5054 6270 9775521 83 Linux
/dev/sda8 6271 7296 8241313+ 83 Linux

Command (m for help):

The table now looks like this, sda5 and sda6 are for windoz variants 95 and NT or XP, respectively in order to commit these changes where it is waiting for a command select "w" <enter> this will write the changes to the disk. Complete the initial setup to install each of the alternative OS or OS's required by rebooting the PC and begin installation to the specified partition ie manual setup for each OS to install if you can't do that you will not be able to do the rest of it. Which now follows :-

You now have each Operating System installed including Ubuntu to each of its respective partitions previously defined. You have by now booted into Ubuntu and found in the process all is not well as Ubuntu has not detected the other Operating Systems, no matter this is how we accomplish this.

With Ubuntu installed and running edit the following file after you have successfully logged onto it.

#> sudo vim /boot/grub/menu.lst

You must initiate this from the command line because you are not root user you must "sudo" you can replace vim with any editor you like even a graphical one but this must be called from the command line with "sudo". If you don't although you will be able to open it you will not be able to save the changes made.

Anyways edit the above mentioned file near the very top as you open this file you should find a command "timeout" with a value beside it alter the value to something suitable before booting into the default setting Linux whatever. You can also change the default value for default booting starting from 0 this is the first of the menu option followed by 1 which is the second menu option and so on.

Now look within this file for Examples tabled here are examples of other OS booting copy the corresponding section into the clipboard buffer for now I will tell you what to do with it later.

Move down the file using the cursor keys if using vim it should look something like this:-

## ## End Default Options ##

title Ubuntu 7.10, kernel 2.6.22-14-generic
root (hd0,0)
kernel /vmlinuz-2.6.22-14-generic root=UUID=baf942d0-bec4-4873-8f4f-7c763264570d ro quiet splash
initrd /initrd.img-2.6.22-14-generic
quiet

title Ubuntu 7.10, kernel 2.6.22-14-generic (recovery mode)
root (hd0,0)
kernel /vmlinuz-2.6.22-14-generic root=UUID=baf942d0-bec4-4873-8f4f-7c763264570d ro single
initrd /initrd.img-2.6.22-14-generic

title Ubuntu 7.10, memtest86+
root (hd0,0)
kernel /memtest86+.bin
quiet

### END DEBIAN AUTOMAGIC KERNELS LIST

Paste the section after the Linux ones any vacant space will do

## ## End Default Options ##

title Ubuntu 7.10, kernel 2.6.22-14-generic
root (hd0,6)
kernel /vmlinuz-2.6.22-14-generic root=UUID=baf942d0-bec4-4873-8f4f-7c763264570d ro quiet splash
initrd /initrd.img-2.6.22-14-generic
quiet

title Ubuntu 7.10, kernel 2.6.22-14-generic (recovery mode)
root (hd0,6)
kernel /vmlinuz-2.6.22-14-generic root=UUID=baf942d0-bec4-4873-8f4f-7c763264570d ro single
initrd /initrd.img-2.6.22-14-generic

# title Windows 95/98/NT/2000
# root (hd0,0)
# makeactive
# chainloader +1

title Ubuntu 7.10, memtest86+
root (hd0,0)
kernel /memtest86+.bin
quiet

### END DEBIAN AUTOMAGIC KERNELS LIST

You will notice the section pasted due to the fact it still has the hashes in front of them edit the hashes and spaces out so it looks like this.

## ## End Default Options ##

title Ubuntu 7.10, kernel 2.6.22-14-generic
root (hd0,6)
kernel /vmlinuz-2.6.22-14-generic root=UUID=baf942d0-bec4-4873-8f4f-7c763264570d ro quiet splash
initrd /initrd.img-2.6.22-14-generic
quiet

title Ubuntu 7.10, kernel 2.6.22-14-generic (recovery mode)
root (hd0,6)
kernel /vmlinuz-2.6.22-14-generic root=UUID=baf942d0-bec4-4873-8f4f-7c763264570d ro single
initrd /initrd.img-2.6.22-14-generic

title Windows 95/98/NT/2000
root (hd0,0)
makeactive
chainloader +1

title Ubuntu 7.10, memtest86+
root (hd0,0)
kernel /memtest86+.bin
quiet

### END DEBIAN AUTOMAGIC KERNELS LIST

Unfortunately things get a little confusing here, using the hd notation ie (hd0,0) from which grub boots from the first value is the first drive in this case drive 0 the second part refers to the partition on which the file system resides therefore the drive we have set up our partitions start from zero not one as in sda1-7. Well take heart it confuses the hell out of me to.

/dev/sda1 * 1 123 987966 83 Linux (hd0,0)
/dev/sda2 124 186 506047+ 82 Swap(hd0,1)Can not be used
/dev/sda3 187 2619 19543072+ 83 Linux (hd0,2)
/dev/sda4 2620 7296 37568002+ 5 Extended(hd0,3)Can not be used
/dev/sda5 2620 3836 9775521 52 CP/M (hd0,4)
/dev/sda6 3837 5053 9775521 7 HPFS/NTFS (hd0,5)
/dev/sda7 5054 6270 9775521 83 Linux (hd0,6)
/dev/sda8 6271 7296 8241313+ 83 Linux (hd0,7)

Now then if we wanted to boot an OS in /dev/sda5 its corresponding hd notation would be (hd0,4) so the above menu.lst file will now look like this.

## ## End Default Options ##

title Ubuntu 7.10, kernel 2.6.22-14-generic
root (hd0,6)
kernel /vmlinuz-2.6.22-14-generic root=UUID=baf942d0-bec4-4873-8f4f-7c763264570d ro quiet splash
initrd /initrd.img-2.6.22-14-generic
quiet

title Ubuntu 7.10, kernel 2.6.22-14-generic (recovery mode)
root (hd0,6)
kernel /vmlinuz-2.6.22-14-generic root=UUID=baf942d0-bec4-4873-8f4f-7c763264570d ro single
initrd /initrd.img-2.6.22-14-generic

title Windows 95/98/NT/2000
root (hd0,4)
makeactive
chainloader +1

title Ubuntu 7.10, memtest86+
root (hd0,0)
kernel /memtest86+.bin
quiet

###END DEBIAN AUTOMAGIC KERNELS LIST

Write these changes back to the disk first press escape key if using vim followed by colon (double dot) to enter command mode and wq the bottom of the terminal window should look like this before pressing enter.

wq<enter>

This will save your file provided you have followed my instructions carefully all should work, make sure each one works before preceding to the next OS to boot from, that way you avoid compounding your problems.