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 Dual-boot Windows XP + Ubuntu Linux leaving GRUB in control (XP/2K installed first)

Last reviewed: September 2008

On this page:
• About adding Ubuntu
• Where to Install the GRUB Boot Loader
• Summary of Procedure
• Preparation
• Detailed procedure
• Remove GRUB, undo changes, and return to Windows only
• Restore or reinstall GRUB from a Ubuntu Live CD
• Notes for novices

About adding Ubuntu

This page shows how to correctly install Ubuntu (v8.04) on a computer that already has a Windows XP installed on it. A dual-boot of Windows XP + Ubuntu is created with Linux's boot manager (GRUB) in charge of the boot menu. The original Windows XP installation will remain intact (but on smaller hard disk space). 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 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

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 the two 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.

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.

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 FIXBOOT 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 specific 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 does 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]

Summary of Procedure (Advanced users)

  1. Run Ubuntu from CD. Open its Partition Editor and create Unallocated free space at end of hard disk.
    Reboot to Windows.
  2. Install Ubuntu from CD. Allow the Boot Loader to install on (hd0) by default or on (hd0,Y).

Finished! The GRUB boot loader menu will boot Ubuntu and Windows XP.

[top of page]

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

  • Download the 700 MB Ubuntu, standard or 64-bit version from (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.
  • 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 Grub's Boot Menu Options

Detailed procedure: Install Ubuntu Linux on Windows XP or 2000 (NTFS)

The existing 150 GB Primary partition will be resized to 129 GB leaving 21 GB Unallocated (free space) towards the end of the hard disk. The unused 21 GB space will initially be left Unallocated for the Ubuntu Linux installation partition (20 GB) plus its Swap file partition (1 GB). If you want a shared partition, you should allow for that when creating the partitions. All the numbers are approximates and are for example purposes only.

  1. Prepare as described and read the Summary above.

    Create Unallocated space for Ubuntu at end of disk.
  2. Bootup from the Ubuntu Live CD and select Try Ubuntu without any change to your computer.
    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 /dev/sda1).
        Drag the right-end of the disk space bar leftwards until the New Size is about 130000 MB
        The Free Space Preceding (MB) should show 0.
        Click the Resize/Move button
        (do not make any other changes to your Windows XP partition).
        Close GParted.
    Reboot to Windows. Let Chkdsk run if it starts and reboot again if requested.

    Install Ubuntu.
  3. Bootup from the Ubuntu Live CD and select Install Ubuntu.
    Select your Language, then your Location, and then your Keyboard layout (click Forward button after each).
    GParted now opens automatically.

    Create the Ubuntu partition.
        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 1 GB (for the Swap File)
        In Location for the new partition, select Beginning.
        In Use as:, select EXT3 journaling file system.
        In Mount Point, select / (a forward slash).
        Click the OK button.
    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.
    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.
        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.

    In Who are you? enter and remember your username and password, and click Forward.
    Deal with the Migrate Documents and Settings as suits you, and click Forward.
    Read the content of the Ready to install window.

    Location for the GRUB boot loader.
    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 and you can accept that. However, you can select a different Primary partition (usually the EXT3) and then the MBR will not be overwritten.
    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 wherever you changed it to in Advanced.
    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! Both operating system will now boot from the Linux GRUB-controlled boot menu.

Remember to re-enable Virtual Memory and Hibernation when booted to Windows XP.

[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 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?

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

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

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

  1. Use the GRUB boot menu to boot to 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. 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 the Windows partition.

The aim here is to 'correct' the MBR on the first hard disk.

  1. Skip this if you do not have access to Fdisk.
    When booted to MS-DOS, type and press Y to confirm:
    Reboot. Skip this next part.
  2. Skip this if you have used Fdisk /mbr.
    Boot from your Windows XP installation CD
    and press R (and then C for Windows 2000) to enter the Recovery Console.
    Logon to Windows
    Type, and press Y to confirm:
  3. You will reboot directly to Windows XP/2000 without any boot menu.
    Use the Windows for a period to confirm that all is well.
  4. 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).

[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:
  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.

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