TweakHomePC

Dual-booting all versions of Windows and Linux

   Dual-Boot    |    Win 8    |    Win 7    |    Vista    |    Win XP/2K/NT    |    Win9x/Me    |    How to    |    Legacy 9x Tweaks    |    SiteMap   


 

Here: Home > Dual-Boot > Dual-Boot Windows XP. 2000 or NT with other Operating Systems >


How to Multi-boot Windows XP/2K + XP + Ubuntu Linux leaving GRUB in control (one XP/2K installed first)

Last reviewed: September 2008

On this page:
• About adding an extra Windows and Ubuntu
• Where to Install the GRUB Boot Loader
• Note for users wishing to use both 64-bit and 32-bit Windows
• Summary of Procedure
• Detailed procedure
• Shared Partition
• Remove GRUB, undo changes, and return to Windows only
• Restore or reinstall GRUB from a Ubuntu Live CD
• Notes for novices

About adding an extra Windows and Ubuntu

This page shows how to correctly install a second Windows XP and then Ubuntu (v8.04) on a computer that already has a Windows XP installed on it. A triple multi-boot of Ubuntu + XP + XP is created with Linux's boot manager (GRUB) in charge of the boot menu. The original Windows XP installation will remain intact in all regards (but on smaller hard disk space unless you use a second hard disk). No commercial utilities are required. The Master Boot Record (MBR) may, or may not, be overwritten depending on where you install Linux's boot loader (GRUB) but GRUB will still be in control.

This page refers to a computer with Windows XP installed. However the original Windows can be Windows 2000 (2K).

When you then boot your computer you will be presented with a boot menu like this :

Ubuntu 8.04.1, kernel 2.6.24-19-generic
Ubuntu 8.04.1, kernel 2.6.24-19-generic (recovery mode)
Ubuntu 8.04.1, memtest86+
Microsoft Windows XP Professional_1
Microsoft Windows XP Professional_2

If you prefer to keep the existing Windows boot manager (NTLDR) in charge of the bootup menu instead of GRUB, then do not continue here - switch to this page

If you continue here:

A single hard disk can be used if it has sufficient space for all three operating systems plus your present and future software and data. Otherwise a second hard disk must be used. The disk is repartitioned by Ubuntu's own totally-free partition utility, GParted (it's Linux-based but at least as good as the commercial PartitionMagic). You should give serious consideration to the sizes of new partitions before you start. If using two hard disks, the second disk should be in situ before you start.

Each booted Windows XP will appear to be on a C: drive even thought they are actually on different physical partitions. This is quite normal in dual and multi-boots and is desired by the majority of users. Each Windows XP will have its own boot files on its own partition.

In the example shown here, a single 160 GB hard disk was used. Let's call it about 150 GB in total size after Fdisk and Format. It started with a single NTFS partition that used the entire disk, had Windows XP Pro (32-bit) installed, and 110 GB free space. You must adjust the partition sizes in this example to suit your own requirements. The example allows for adding a 32-bit Windows XP to an existing 64-bit Windows XP installation (64-bit has not been actually tested yet by THPC but it will work just fine).

The procedure will be divided into four sections:
PREPARATION: Matters you must or should attend to before you start.
PART 1: Resize the existing hard disk partition without installing anything.
PART 2: Install the second Windows XP.
PART 3: Install Ubuntu Linux.

Where to Install the GRUB Boot Loader

There are two locations where you can install GRUB.

The first (this is the Default) is on (hd0) which is at the start of the first hard disk. This overwrites the existing Master Boot Record (MBR) of the first disk. However, if required at a later time, the original MBR can easily be restored by using Fdisk /mbr from MS-DOS or Fixmbr from the Recovery Console (read below). The MBR on (hd0) is the most natural location for GRUB. This is THPC's preferred choice because of the simplicity of its implementation and the relative ease of rectification. Restoring/reinstall GRUB here is also quite easy.

Your second choice is to put GRUB at the start of a Primary partition; to put it on (hd0,Y) where Y is the partition number as seen by GRUB. In this situation the original MBR remains untouched. This option is available in the Advanced button during Ubuntu installation. Be sure you select a Primary partition and that partition must not contain another bootable operating system. (hd0,Y) must be made the Active partition ('Boot'). However if (hd0) is later made Active, then GRUB will be ignored and the Windows XP will boot again just as before you made any changes. Many users select the EXT2/3 partition and prefer this method as the MBR is not over-written. Restoring/reinstall GRUB here is marginally more difficult.

In both cases, read Remove GRUB, undo changes, and return to Windows only below to learn how to return to your original Windows-controlled system.

[top of page]

Note for users wishing to use both 64-bit and 32-bit Windows

Installing a 64-bit Windows XP on a system already containing a 32-bit Windows XP is never a problem - provided it has 64-bit hardware! Just install the 64-bit on a different partition and a dual-boot will be created automatically.

In the procedure below there should not be any problem installing a 32-bit Windows XP on a system already installed with the 64-bit version and there should not be any need to take precautions. The existing 64-bit Windows XP partition will be hidden prior to installing the second XP and unhidden later. The second Windows XP is installed as a totally separate OS. A Windows XP + XP dual-boot with shared boot files is never created. When installed, GRUB identifies each Windows XP as a distinct OS and then correctly shows each as a separate boot option.

[top of page]

Summary of Procedure (Advanced users)

  1. Run Ubuntu from CD. Open its Partition Editor.
  2. Create sufficient free space at end of hard disk for extra OSs or use second disk.
  3. Create 2nd Primary partition at start of free space and leave free space for Linux at end of disk.
  4. Make new 2nd partition Active ('boot') and hide XP partition. Exit Partition Editor and Ubuntu.
  5. Install 2nd XP on new 2nd partition. Reboot to new XP. Install drivers.
  6. Run Ubuntu from CD and make 1st partition Visible and Active again.
  7. Without rebooting, install Ubuntu on free space allowing boot loader on (hd0) or (hdX,Y).
    If GRUB is put on (hdX,Y), make that Primary partition Active ('Boot').
    Finished! The GRUB menu will boot Ubuntu and both Windows.

[top of page]

Detailed procedure

Preparation: Matters you must or should attend to before you start

  • Download the 700 MB Ubuntu, standard or 64-bit version from www.ubuntu.com (or request the totally free CD). You can use the free and excellent GetRight download manager to help with the large download. Create the Ubuntu Live CD from the downloaded .ISO file.
  • It's routine to backup all important data.
    Also:
  • This might be a good time to run Disk Defragmenter, and run Chkdsk /F from a Command Prompt. Allow plenty of time!
  • Disable Virtual Memory (C:\pagefile.sys) ---> Start > Settings > Control Panel > System > Advanced tab > Settings button (in Performance) > Advanced tab > Change button (in Virtual Memory) > Select "No paging file", press the Set button, press OK.
    Disable Hibernation (C:\hiberfil.sys) if it's in use ---> Power Options in Control Panel > Hibernate tab > uncheck Enable hibernation and click OK.
    i.e. remove those two unmovable hidden files that may prevent resizing of the hard disk.
  • Some users may need to read:
      How to Boot from a bootable CD
      How to Show Hidden Files
      How to Edit Boot.ini
      How to Edit Grub's Boot Menu Options

PART 1: Resize the existing hard disk partition without installing anything

The existing 150 GB Primary partition will be resized to 90 GB leaving 60 GB unallocated (free space) towards the end of the hard disk. A new 40 GB NTFS Primary partition will be created at the beginning of the free space (for the new XP installation). The unused 20 GB space will initially be left Unallocated for the Ubuntu Linux installation partition (19 GB) plus its Swap file partition (1 GB). If you want a shared partition, you should allow for that when creating the partitions - you'll probably need to replace the final Primary partition with an Extended partition (containing two or more Logical partitions). All the numbers are approximates and are for example purposes only.

  1. Prepare as described, and read the Summary, above.
    In My Computer of your installed Windows XP, give C: the Label XP_1 (right-click on C: and select Rename). You'll then see it as XP_1 (C:)
    Skip this edit of Boot.ini if you are unsure of your ability to do it safely - it's not essential.
    Backup Boot.ini in XP_1 (C:) (it's a hidden and read-only file) and name the copy boot.in1.
        Edit Boot.ini and look at the line in the [operating systems] section. It will look like:
        multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /fastdetect
        Add _1 to the end of the description within the quotes (_1 must come just before the right-hand quote). Like:
        multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional _1" /fastdetect
        Note: multi(0) will be replaced by scsi(0) in some computer systems.
        Save and close Boot.ini.

    Create free space at end of disk for second XP and Ubuntu.
  2. Bootup from the Ubuntu Live CD and select Try Ubuntu without any change to your computer
  3. When booted, open GParted (in System > Administration > Partition Editor).
        Right-click the XP partition (it's /dev/hda1 or perhaps /dev/sda1, and uses NTFS)
        and select Resize/Move. The Resize /dev/hda1 window will open (it could be Resize /dev/sda1).
  4. Drag the right-end of the disk space bar leftwards until the New Size is about 90000 MB (=90 GB, in this example).
        The Free Space Preceding (MB) should show 0.
  5. Click the Resize/Move button
        (do not make any other changes to your original Windows XP partition).

    Now create the second XP partition (NTFS).
  6. Right-click the new Unallocated (free space), and click New. The Create New Partition window will open.
  7. Drag the right-end of the disk space bar leftwards until the New Size is about 40000 MB (=40 GB, in this example).
        The Free Space Preceding (MB) should show 0.
        In Create as:, select Primary Partition.
        In Filesystem: select NTFS or FAT32 if that's used by first Windows.
        In Label, enter XP_2
        Click the +Add button.
  8. Click Apply and confirm when ready, or click Undo to alter your changes.
  9. Click the Close button when repartitioning is complete

    Make new partition Active ('boot'), and hide 1st XP's partition, before installing 2nd XP.
    GParted shows XP_1 partition to be the 'boot'.
  10. Right-click the XP_2 partition (40 GB) and select Manage Flags.
        Check (tick) the boot flag and click Close. GParted now shows XP_2 partition to be the 'boot'.
  11. Right-click the XP_1 partition and select Manage Flags.
        Check the Hidden flag, and click Close. GParted now shows XP_1 partition to be 'Hidden'.
  12. Close GParted.

PART 2: Install the second Windows XP

  1. Shutdown Ubuntu, remove the CD when it's ejected, and replace it with your Windows XP installation CD.
        Bootup with the Windows XP installation CD inserted, and press any key to boot from CD.
        Install another Windows XP as a new installation using the recently created 40 GB NTFS partition.
          XP Pro Example:
          Press [Enter] to select To set up Windows XP now, press ENTER.
          Press F8 to agree to the Licence.
          Select the new NTFS partition (it should be"partition2" and is about 40000 MB), and press [Enter]
          (the XP_1 partition1 is "Inactive" - do not use this partition).
          Select Quick format (then press F), and press [Enter].
          Continue with the installation until complete.
  2. When installation is complete, install any required drivers (don't forget chipset drivers if required!).
        Label/rename) C: to XP_2 (right-click on C: and select Rename). You'll then see it as XP_2 (C:).
        Make the Desktop appearance different from that of Windows XP_1.
  3. Skip this edit of Boot.ini if you are unsure of your ability to do it safely - it's not essential.
    Backup Boot.ini in XP_2 (C:) (it's a hidden and read-only file). Name the copy boot.in2.
        Edit Boot.ini and look at the line in the [operating systems] section. It will look like:
        multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="Microsoft Windows XP Professional" /fastdetect
        Add _2 to the end of the description within the quotes (_2 must come just before the right-hand quote). Like:
        multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="Microsoft Windows XP Professional _2" /fastdetect
        Note: multi(0) will be replaced by scsi(0) in some computer systems.
        Save and close Boot.ini.
  4. Insert the Ubuntu Live CD and reboot.

PART 3: Install Ubuntu Linux

  1. Boot from the Ubuntu Live CD and select your Language.
    Select Try Ubuntu without any change to your computer (you will actually install it soon).

    First return the XP_1 partition to its previous state (Visible and Boot).
  2. Open Partition Editor. GParted shows the XP_2 partition is the 'boot' and XP_1 is Hidden.
    Right-click the XP_1 partition and select Manage Flags.
        Uncheck the Hidden flag, and
        Check (tick) the boot flag.
        Click Close. GParted now shows the XP_1 partition to be the 'boot' and none are Hidden.
        Close GParted.

    Install Ubuntu creating its two partitions as you install.
  3. Double-click the Install icon on the desktop.
    Select your Language, then your Location, and then your Keyboard layout (click Forward button after each).
  4. GParted now opens automatically.
        In Prepare disk space, select Manual, and click the Forward button.
        In Prepare partitions, right-click Free space, and select New Partition.
        In Type for the new partition, select Primary
        In New partition size ..., select all available space (for Ubuntu), except 800 MB (for the Swap File)
        In Location for the new partition, select Beginning.
        In Use as:, select EXT3 journaling filesystem.
        In Mount Point, select / (a forward slash).
        Click the OK button.
    Under Device, please note the partition identification allocated to the EXT3/2 partition, like /dev/hda3.
    Make sure the Format box is ticked for the new EXT3 partition.
    Make sure the Mount Point is / (if not, right-click the EXT3 partition, select Edit, and correct it).

    Create the Swap partition.
  5. Now right-click the remaining Free space (about 800 MB), and select New Partition.
        In Type for the new partition, select Logical (but Primary if you prefer).
        In New partition size ..., use all available space (about 1 GB for the Swap File)
        (if you have a total of 4 Primary partitions, any remaining free space would be unusable)
        In Location for the new partition, select Beginning.
        In Use as:, select Swap area.
        A Mount Point is not set for Linux's swap file partition.
        Click the OK button.
    Click Forward when ready, or click Undo changes to partitions to alter your changes.
  6. In Who are you? enter and remember your username and password, and click Forward.
  7. Deal with the Migrate Documents and Settings as suits you, and click Forward.
  8. Read the content of the Ready to install window.
    Click the Advanced button and make sure the Install boot loader box is ticked.
    You'll see the boot loader (GRUB) will be installed, by default, at the start of the first hard disk (hd0) replacing the Windows loader. If you wish to change this, click the down-arrow and select the Linux EXT3 partition (it must be a Primary partition).
    When you're ready, click OK to exit Advanced
        Click Back if you're unhappy with your selections.
        Click Install when you're ready to install Ubuntu.
    Ubuntu Linux will now install itself on the new EXT3 partition
    and will place GRUB at the start of the first disk (hd0) or elsewhere if you changed the Default.
  9. You can skip this if you install GRUB on (hd0).
    If you did not use (hd0) you must make Linux EXT3 partition Active. Before you 'Restart now', open Partition Editor, right-click the EXT3 partition, select Manage Flags, and tick the 'Boot' flag box.
  10. Click Restart now when all is complete, remove the CD when it pops out, and press [Enter].
    Let Ubuntu boot on the first bootup. You'll need your username and password.

Finished!

When booted to Windows XP_1, remember to re-enable Virtual Memory, and also Hibernation if disabled.

"Checking file system on C: ... " (Chkdsk) should run during the first boot of Windows XP_1. Let it do so and be prepared for the inevitable reboot when it's finished. Windows is adjusting itself to the changes in the hard disk geometry and that's important!

"System Settings Change ('Windows has finished installing new devices') may appear the first time either Windows XP boots. Restart when requested for same reason as the previous item.

If the Ubuntu username/password requests annoys some home users, go to 'System > Administration > Login Window' in Ubuntu and enter your password. Click the Security tab, check the Enable Automatic Login box, and don't forget to select your username in the User: dropdown. Now click the Close button. However, remember that a good password will be very importance if you ever start using SSH networking!

[top of page]

Shared Partition

If you wish to have a partition that can be shared between Linux and the Windows XPs or between the two Windows, you need to make more free space early in above procedure. Then you leave more free space when creating the EXT3 partition. Finally, your last (4th) Primary partition is not created.

You create an Extended partition instead of a Primary. This Extended partition can now contain two or more Logical partitions, the Swap (800 MB) partition and another Logical partition for sharing (using FAT/FAT32/ NTFS depending on your needs). Some users use a shared partition for items like My Documents - useful especially if mixing 64-bit and 32-bit Windows!

[top of page]

Remove GRUB, undo changes, and return to Windows only

It's essential that you know how to return to your starting position in the event of a change of mind or perhaps even a mishap. The following procedure will return you to your original Windows XP booting alone with the Windows boot loader (NTLDR) in control again.

Two items may need attention to achieve this.
  1. Does the MBR need replacing?
  2. Is the correct partition marked Active?

Note: If you wish the second Windows to be bootable, then make the second Windows' partition Active.
Note: Creating a dual-boot of the two Windows is extremely easy once GRUB is removed!

THPC suggests you should follow the sequence shown here i.e. first correct the Active flag and the MBR if necessary and later delete/resize partitions.

How to boot directly to Windows XP when GRUB was put on (hdX,Y) and not on the MBR (hd0)

In this situation the Ubuntu partition remains the Active partition irrespective of which was the last booted Windows.

The original MBR remains unchanged. Therefore, you simply need to make a Windows XP partition Active and then only that Windows will boot. There are a variety of ways of achieving this.

  1. Use the GRUB boot menu to boot to a Windows XP. Open Computer Management and select Disk Management. Right-click the target XP partition and select Mark Partition as Active. Click Yes to confirm. You cannot make the Linux partition Active using Disk Management.
    - or -
    Boot from a Windows 9x/MS-DOS boot disk (Startup floppy) or a bootable CD created from a 9x/MS-DOS floppy disk image. Run Fdisk, and select Option 2. The partition currently active is marked with an A under Status. Make the Windows XP partition Active (you can identify it by the Type and the size in Mbytes - it will not necessarily be the first one shown). You can also make a Non-DOS (Linux) partition Active with Fdisk.
    - or -
    Boot from the Ubuntu Live CD and run Partition Editor. Right-click the Windows XP partition, select Manage Flags, and select (tick) the Boot box.
     
  2. Read How to retain a Windows Dual-Boot after Removing GRUB below.
     
  3. At your leisure you can use GParted from the Linux Live CD to delete unwanted partitions and resize others.
    You must 'Switchoff' the Linux swap file partition and Linux partition(s) must be unmounted before you can delete them.

How to boot directly to Windows XP when GRUB was put on the MBR (hd0)

In this situation the Active partition is always that of the last booted Windows irrespective of when Ubuntu was last booted.

The aim here is make the XP_1 partition Active and to 'correct' the MBR on the first hard disk.

  1. Make the XP_1 partition Active (as described in the first part of the last section).
    Note: If you wish XP_2 to be the bootable Windows, then make XP_2 the Active partition.
  2. Skip this if you do not have access to Fdisk.
    When booted to MS-DOS, type and press Y to confirm:
    FDISK /MBR
    Reboot. Skip this next part.
  3. Skip this if you have used Fdisk /mbr.
    Boot from your Windows XP installation CD
    and press R to enter the Recovery Console.
    Logon to Windows
    Type, and press Y to confirm:
    FIXMBR
    exit
  4. You will reboot directly to Windows XP without any boot menu.
    Use the Windows for a period to confirm that all is well.
     
  5. Read How to retain a Windows Dual-Boot after Removing GRUB below.
     
  6. At your leisure you can use GParted from the Linux Live CD to delete unwanted partitions and resize others.
    You must 'Switchoff' the Linux swap file partition and Linux partition(s) must be unmounted before you can delete them.

If the original Boot.ini file has gone 'missing', you can create a new Boot.ini by logging-on in the Recovery Console to the original Windows, and using bootcfg /rebuild at the prompt. When prompted for Load Identifier enter Windows XP 1, and for Load Options you can use /fastdetect (novices can read Bootcfg Command Usage).
 


How to retain a Windows Dual-Boot after Removing GRUB

Some users will wish to retain a Windows dual-boot after they have removed GRUB and Linux.
Skip this if you do wish to retain only the first Windows.

  1. Backup the Boot.ini file that's on the XP_1 partition.
  2. Open the Boot.ini file that's on the XP_2 partition.
    Copy the line in the [operating systems] section. It's like:
      multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="Microsoft Windows XP Professional_2" /fastdetect
  3. Open the Boot.ini file that's on the XP_1 partition.
    Paste the copied line under the similar line in the [operating systems] section of XP_1's Boot.ini
    and Save the file.
  4. Optionally, change the Timeout=30 under [boot loader] to about Timeout=10 (that's 10 seconds).
  5. If the second Windows (XP_2) is a newer version than the first (XP_1),
    you must copy the Hidden files, NTLDR and Ntdetect.com, from XP_2 to XP_1
    (or copy them from the i386 folder on the CD for the latest version of Windows).

Finished. If you retained the second Windows and wish to dual-boot with the first, just reverse the above process.

[top of page]

How to restore or reinstall GRUB from a Ubuntu Live CD

You may for some reason wish to reinstall GRUB. GRUB can be easily returned to its original location with the following commands. It will be assumed that GRUB was installed on the MBR (hd0) of the first hard disk.

  1. Run Linux from your Ubuntu Live CD, and open a Terminal window (it's like a DOS window)
    (Terminal is usually in Applications/Accessories).
  2. First get to a GRUB prompt. Type:
    sudo grub
  3. GRUB extends beyond the very small MBR and has different Stages.
    Find and note the location of GRUB's Stage 1. Type:
    find /boot/grub/stage1
    You will be shown the location of Stage1, like (hd0,4)
    (if more than one Stage1 is located, you must choose which one to use).
  4. Replace the following hd?,? with the location just found. Type:
    root (hd?,?)
  5. hd0 is the GRUB label for the first drive's MBR (that 0 is a zero). Type:
    setup (hd0)
  6. Type:
    quit
    exit
  7. Open Partition Editor and right-click the partition where GRUB is setup - usually (hd0).
    Select Manage Flags and make sure the Boot flag is ticked for this partition.
  8. Exit GParted, and Restart. Remove the CD when it pops out.

When you reboot, you will have the GRUB boot loader menu at startup.

Note:
It's not essential for GRUB to be written to the MBR on the first hard disk (hd0). If you want GRUB on a Primary partition, the setup (hd0) step can be altered to setup (hdX,Y). The X part is the hard disk number (0=first disk, 1=second). The Y part is the Primary partition number (0=first partition, 1=second, etc). This method will leave the MBR on (hd0) unchanged.

Remember GRUB starts counting at 0
(a 0 is the first, 1 is second, ...). That means, for example:

/dev/hda1 in Linux equates to (hd0,0) in GRUB (hd0 = first hard disk and ,0 = first partition)
/dev/hda2 in Linux equates to (hd0,1) in GRUB (hd0 = first hard disk and ,1 = second partition)
/dev/hda3 in Linux equates to (hd0,2) in GRUB (hd0 = first hard disk and ,2 = third partition)
/dev/hdb1 in Linux equates to (hd1,0) in GRUB (hd1 = second hard disk and ,0 = first partition)

/dev/fd0 in Linux equates to (fd0) in GRUB (floppy drive)
/dev/cdrom in Linux equates to (cdrom) in GRUB (CD-Rom drive)

[top of page]

Notes for novices

Always note the sizes of partitions for accurate identification.
Only 4 Primary partitions per hard disk can exist.
A bootable partition must be marked Active and it must be a Primary. This Primary must
be on the disk that the computer gains access to at startup (first disk by default).
A computer can only have one Active partition per disk.
An Extended partition counts as a Primary - with no drive letter allocation by Windows
(but it can contain very many Logical partitions, each with its own drive letter).
Only one Extended partition per disk can exist.
Users with old computers (LBA problem?) should try installing Linux on a Logical partition.

In Boot.ini, scsi() replaces multi() in some computers.
In Boot.ini, rdisk(0)partition(1) = first hard disk, first partition.
In Boot.ini, rdisk(0)partition(2) = first hard disk, second partition.
In Boot.ini, rdisk(1)partition(3) = second hard disk, third partition.

/dev/hda1 = /dev/sda1 (Linux uses /sda instead of /hda in laptops and in some other situations).
hda1, hda2, hda3, hda4 = 4 Primary partitions as seen by Linux on first hard disk.
hda5, hda6, hda7, etc = Logical partitions as seen by Linux in an Extended partition on first disk.
hdb1, hdb2, hdb3, hdb4 = 4 Primary partitions as seen by Linux on second hard disk.
hdb5, hdb6, hdb7, etc = Logical partitions as seen by Linux in an Extended partition on second disk.

[top of page]

Please remember that you alone are responsible for the consequences of any changes you make to your computer hardware or software.

Copyright © LarryM 1998-2015 thpc@mail.com