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 or 2000 and Ubuntu Linux leaving Windows (NTLDR) in control

Last reviewed: September 2008

On this page:

• About adding Ubuntu
• Summary of Procedure
• Preparation
• Detailed procedure
• Shared Partition
• 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 Windows' boot manager (NTLDR) in charge of the boot menu. The original Windows XP installation will remain intact (but on smaller hard disk space unless you use a second hard disk). No commercial utilities are required.

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 :

Microsoft Windows XP Professional
Ubuntu 8.04

If you prefer to keep the Linux boot manager (GRUB) in charge of the bootup menu instead of NTLDR, 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 both operating systems plus your present and future software and data. 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.

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 Professional (32-bit) installed, and 110 GB free space. You must adjust the partition sizes in this example to suit your own requirements.

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. Run Ubuntu from CD. Open a Terminal. Copy MBR (IPL boot loader only) to Bootsect.wxp with:
    sudo dd if=/dev/hda of=bootsect.wxp bs=446 count=1
  3. Install Ubuntu; allow the Boot Loader to install to (hd0). Do not reboot when install completes.
  4. Open a Terminal. Copy Ubuntu boot sector to Bootsect.lnx with:
    sudo dd if=/dev/hda of=bootsect.lnx bs=512 count=1
    Copy Bootsect.lnx to Windows XP partition or floppy or flash drive.
    Copy the saved 446 bytes back to (hda) with:
    sudo dd if=bootsect.wxp of=/dev/hda bs=446 count=1
  5. Reboot to Windows. Copy Bootsect.lnx to C: if it's not there already.
    Add this line under [operating systems] section of Boot.ini
    C:\BOOTSECT.LNX=" Ubuntu 8.04 "

    Finished! The Windows 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 Boot.ini
      How to Edit Grub's Boot Menu Options

[top of page]

Detailed procedure

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 these numbers are approximates and are for example purposes only.

Reboots are important. Please follow on-screen instructions.

  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.

    Save the MBR (first 446 bytes - the IPL boot loader only).
  3. Bootup from the Ubuntu Live CD and select Try Ubuntu without any change to your computer.
    Open a Terminal (in Applications > Accessories > Terminal).
        At the ubuntu@ubuntu:~$ prompt, type
        sudo dd if=/dev/hda of=bootsect.wxp bs=446 count=1
    Confirm that Bootsect.wxp is in Ubuntu (in Places > Computer > Ubuntu).
    Close any open window(s).
    Do not reboot.

    Install Ubuntu.
  4. Double-click the Install icon on the desktop.
    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.

    Locations 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. Do not change this when using the procedure on this page. 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).

    Click Continue using the live CD when installation is complete.
    Do not click Restart now.

    Create copy of Linux boot sector and return MBR's IPL
  5. Open a Terminal. Type these two lines at the Prompt (press [Enter] after each):
    sudo dd if=/dev/hda of=bootsect.lnx bs=512 count=1
    sudo dd if=bootsect.wxp of=/dev/hda bs=446 count=1
    Close the Terminal.
    Copy Bootsect.lnx to the NTFS drive or to floppy or to flash drive
    (it's in Places > Computer > Ubuntu).
    Restart now, remove the CD when it pops out, and press [Enter].
    Windows will boot.

    Let Windows know about the Ubuntu installation
  6. Copy Bootsect.lnx to C: if it's not already there.
    Edit C:\Boot.ini and add this line to bottom of the [operating systems] section:
    c:\bootsect.lnx=" Ubuntu 8.04 "
    Save Boot.ini and reboot.

Finished! Both operating system will now boot from the Windows-controlled boot menu.

A second boot menu will appear when Ubuntu is selected on startup. Ubuntu's configuration file, Menu.lst, must be edited to remove the Windows boot option (or just set Timeout to 0 if Ubuntu is the Default) so this second menu does not appear in future.

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

[top of page]

Shared Partition

If you wish to have a partition that can be shared between Linux and Windows XP, you need to make more free space early in above procedure. Then you leave more free space when creating the EXT3 partition.

You create an Extended partition instead of a Primary. This Extended partition can now contain two or more Logical partitions, the Swap file partition and another Logical partition for sharing (using FAT/FAT32/ NTFS depending on your needs).

[top of page]

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.

The original MBR is already back in place. Therefore, you just remove the Ubuntu line from the C:\Boot.ini file. This will leave you with your original Windows XP without any boot menu.

In the unlikely event of a serious mishap you can run FDISK /MBR after booting a MS-DOS/Win9x boot disk or run FIXMBR from the Recovery Console after booting from the Windows XP installation CD. Your Windows XP should boot and you can now edit Boot.ini

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.

[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