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 Windows (NTLDR) in control (XP/2K installed first)

Last reviewed: September 2008

On this page:
• About adding a Windows XP and Ubuntu
• Note for users wishing to use both 64-bit and 32-bit Windows
• Summary of Procedure
• Preparation
• Detailed procedure
• Undo changes and return to Windows only
• Restore or reinstall GRUB from a Ubuntu Live CD
• Notes for novices

About adding a Windows XP 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 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_1
Microsoft Windows XP Professional_2
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 the page here

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. 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 Professional (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).

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.

If you install a 32-bit version of Windows XP on a computer containing the 64-bit version, you must then copy the 64-bit versions of NTLDR and Ntdetect.com to the root of the 32-bit Windows' partition. The 32-bit versions will not boot the 64-bit Windows but will have over-written the 64-bit versions during the install and these must be replaced. The 64-bit versions can boot all previous versions of NT-type Windows.

[top of page]

Summary of Procedure (Advanced users)

  1. Run Ubuntu from CD. Open its Partition Editor
    Resize to create partition for 2nd XP and leave Unallocated space at end of hard disk for Linux.
    Reboot to Windows and reboot again if requested.
  2. Install 2nd Windows XP as a new installation on new partition.
    Reboot to Windows. Test the XP + XP dual-boot created. Install drivers for new XP if necessary.
    If you installed a 32-bit version of Windows XP on a computer containing the 64-bit version, you must copy the 64-bit versions of NTLDR and Ntdetect.com to the root of the 32-bit Windows' partition.
  3. 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
    Do not reboot.
  4. Install Ubuntu. Allow the Boot Loader to install on (hd0).
    Do not reboot when install completes.
  5. 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 first Windows 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
  6. Reboot to first Windows. Copy Bootsect.lnx to C: if it's not already there.
    Add this line under [operating systems] section of C:\Boot.ini
    C:\BOOTSECT.LNX=" Ubuntu 8.04 "

Finished! The Windows-controlled boot loader menu will boot Ubuntu and both Windows.

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

[top of page]

Detailed procedure

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). All 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:)

    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
    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).
        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.
        Click the Resize/Move button
    (do not make any other changes to your original Windows XP partition).

    Now create the second XP partition (NTFS).
  3. Right-click the new Unallocated (free space) and click New.
    The Create New Partition window will open.
        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.
    Click Apply and confirm when ready, or click Undo to alter your changes.
    Click the Close button when repartitioning is complete
    Close GParted and Shutdown Ubuntu.
    Reboot to Windows. Let Chkdsk run if it starts and/or reboot again if requested.

    Install the second Windows XP.
  4. 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.
    When installation is complete, install any required drivers (don't forget chipset drivers if required!).
    Make the Desktop appearance different from that of Windows XP_1.

    Save the MBR (first 446 bytes - the IPL boot loader only).
  5. 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.
  6. 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 Swap)
        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 900 MB), and select New Partition.
        In Type for the new partition, select Primary (but Logical if you need an extra partition).
        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. 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 the MBR's IPL
  7. 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
    Copy and Paste Bootsect.lnx to root of first Windows (XP_1) or to floppy or to flash drive
    (Confirm it's in Places > Computer > Ubuntu or do it again!).

    Restart now, remove the CD when it pops out, and press [Enter].
    Boot to first installed Windows (on XP_1).

    Let Windows know about the Ubuntu installation
  8. 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! The three operating systems will boot from the Windows-controlled boot menu.

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

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 option so this second menu does not appear in future (or just make the Timeout=0 in Menu.lst). Menu.lst should be in File System > Boot > Grub. The .lst extension is short for list, not first.

"Checking file system on C: ... " (Chkdsk) should run during the first boot of Windows after disk alterations. 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]

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, or dual-booted XP + XP, 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 a Windows XP + XP dual-boot.

If you also wish to remove the second Windows XP (and the dual-boot), you simply remove that Windows XP 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:
    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