How to dual boot Linux and
Windows XP (Linux installed first)
29th May 2007
Linux , Windows
UPDATED 29 May 2007 now uses Ubuntu 7.04 as the Linux distribution rather than Ubuntu 6.10.
Scenario: You want to install XP on your machine alongside your existing Linux installation, on the same
drive. You have installed Ubuntu already. (If you have already have XP installed, check out our tutorial on
how to dualboot Linux with XP, with XP installed first .)
Tutorial Summary: We're going to use the Gnome Partition Editor (Gparted) from the Ubuntu LiveCD
to shrink the main Ubuntu data partition on the hard disk and create enough space for an installation of
We'll then install XP, and, because XP overwrites the master boot record, we'll restore the GRUB boot
loader so that either XP or Linux can be selected at boot time.
This is an updated tutorial from our previous Linux/XP workshop. That version was written using Ubuntu
6.10, whereas this tutorial was written for Ubuntu 7.04.
These steps have been tested in both an ASUS P5AD2based system with an 80GB Seagate SATA drive
and a VMWare 6 virtual machine.
Prepare the Ubuntu System
The assumption is that the Ubuntu system has been installed on a single hard drive which has enough
space to accommodate both operating systems.
The first step is to create enough space on the disk to install Windows XP. The Ubuntu Live CD does
contains GNOME Partition Editor, which can be used to resize Linux partitions, but the Live CD for
Ubuntu 7.04 has an annoying tendency to mount the filesystem while it's checking it. This causes an
partition work to bring up an error. It does work, but it's messy. So instead we'll use the GParted LiveCD,
which acts independently of the OS and doesn't give us any grief.
The GParted LiveCD ISO is available here – burn it to CD and boot the system from the disc. The version
we used was 0.3.47.
Boot the Ubuntu machine from the GParted LiveCD. Depending on your system, you should just need to
select the autoconfiguration boot option.
During boot, press Enter twice when prompted to select the keymap and language settings. When the
main GUI loads, rightclick on the main partition (depending on your setup, probably /dev/sda1) and
Use the slider to create sufficient space to house the XP installation then click Resize/Move.
Once that's done, quit GParted and reboot the machine from the Windows XP CD.
Now, install Windows XP
Once the CD has loaded, press Enter to install Windows XP, then F8 to accept the license agreement.
When the partition screen loads, you can see that Windows Setup can see the two existing Ubuntu
partitions and has interestingly assigned them drive letters (even though it can't read them.)
The space we’ve just created is also there, so select that and hit Enter.
Windows XP Select Partition
Because the primary active partition (/dev/hda1) has been marked as bootable, Windows can’t be installed
until this partition has been marked inactive so that the new partition can take over. This is pretty much
the same as installing Windows Vista. Hit Enter to make this change and then format the new partition.
Windows XP Mark Partition Active
Unfortunately because XP detected the two Ubuntu partitions and assigned them drive letters, the new
partition which Windows is going to be installed on will be assigned drive letter F:, which is definitely a
nonstandard drive letter for Windows.
However, it’s not that much of a problem – at least as far as Windows and therefore most other intelligent
It could be a problem for older apps which don’t look to the Windows settings and make assumptions
about where they can install themselves (for example, apps that are hard coded to install to Drive C).
Reboot the system once Windows is installed and you’ll see that it boots straight into XP. Ubuntu’s GRUB
bootloader in the MBR (Master Boot Record) has been overwritten, so Ubuntu isn’t bootable at this point
There are ways to make the Ubuntu partition bootable while still using XP’s bootloader in the MBR.
However this is fiddly and involves using FAT32 partitions, as FAT32 is readable by both XP and Ubuntu.
Wherever possible I avoid using FAT32 – it’s nowhere near as optimised as NTFS, and you lose out on all
the enhanced security and permissions features.
Reinstating GRUB as the system bootloader is a much better alternative – it handles pretty much any
operating system you care to throw at it, and it’s very easy to administer.
Reinstall GRUB to the MBR
The next step is to reinstate GRUB as the system bootloader. Boot the system using the Ubuntu Live CD.
Go into the GNOME Partition Editor and you can see that the Windows XP Partition is detected as
/dev/hda2 and has been marked as the boot partition.
It can actually stay as the boot partition, but as we’re going to reinstall GRUB it makes sense to change
this – it doesn’t adversely effect XP.
Rightclick the Windows partition and select Manage Flags.
Untick “boot” and select Close.
Then rightclick the primary Ubuntu partition (/dev/hda1), select Manage Flags and tick “boot”, then
GParted Manage Flags
GParted Mark Bootable
Now to reinstall GRUB. Open up Terminal (Applications, Accessories, Terminal) and type in:
This will launch the GRUB application. Now type in:
This will search for where GRUB has been installed, and you should get the result hd(0,0).
Change the active root to this location by typing in:
Now we’re going to reinstall GRUB to the MBR rather than the Ubuntu partition.
If we were going to use the Windows XP bootloader then we’d reinstall GRUB to hd(0,0), but as we’re
not, type in:
This restores GRUB to the MBR. Type in QUIT and then EXIT to get out of GRUB and Terminal
respectively, then reboot the system. Ubuntu will load by default.
Modify the Boot Menu
What we need to do now is modify the GRUB boot menu to allow Windows XP to load. Boot the system
into Ubuntu and go to Terminal. Type in:
sudo gedit /boot/grub/menu.lst
This loads the GRUB menu file (which is basically a text file) within GEdit.
Navigate down to the section which after “## ## End Default Options ##".
These are the individual menu items in the GRUB menu.
Ubuntu & XP GRUB Menu
To create a new entry, navigate down to the end of the list (although it can go anywhere really) and enter
the following lines:
title Windows XP
This places an item in the boot menu to launch Windows XP from its own partition (hd0,1).
If you like, scroll up to the top of MENU.LST and find the line called TIMEOUT.
The numerical value assigned to TIMEOUT dictates how long you’ve got to go into the boot menu (in
seconds) before the default boot item loads.
When configuring a dual/multiboot system I find it better to increase this value.
Just above TIMEOUT is DEF AULT. This specifies which boot entry is the default.
The numbering system starts at 0 and counts upwards, so the DEFAULT = 0 means that Ubuntu is always
the default entry.
If you want Windows XP to be the default, replace the value.
Save MENU.LST and exit from GEdit, then restart the system.
Hit ESC when prompted to bring up the boot menu, and there’s the newlycreated Windows XP entry.
Navigate to this boot item and hit Enter – Windows XP will load.
Uninstalling Windows XP
If you decide after a while that this dualbooting situation is no good and you wish to scrap Windows XP,
it’s actually very easy.
Go through the process outlined above to modify the MENU.LST and remove the Windows boot entry.
Then boot off the Ubuntu Live CD and go into GNOME Partition Editor. Rightclick the Windows
partition (/dev/hda2) and select Delete.
Then rightclick the main Ubuntu partition (/dev/hda1) and select Resize/Move.
Drag the edge of the partition to reclaim the space you’ve just freed up by deleting the Windows XP
partition and click Resize.
There will now be two actions waiting in the Operations window. Hit Apply and these changes are made.
This take your system right back to the start before Windows was installed, and is actually quite a
graceful exit from the dualboot scenario.
Other APC dualbooting tutorials:
The definitive dualbooting guide: Linux, Vista and XP stepbystep