How to dual boot Linux and Windows XP (Linux installed first) -- the step-by-step guide with screenshots

James Bannan05 June 2008, 1:59 PM

How to dual-boot Windows XP and Linux. (Now updated for XP SP 3 and Ubuntu 8.04.)

Page 2 - Back up the GRUB boot menu

Regardless of which bootloader you end up using, it's a very good move to first back up the GRUB bootloader. It's easy to lose it and unless you know how to re-write it from scratch then you're generally facing a full reinstallation of Ubuntu.

Firstly, boot into Ubuntu and go to Applications --> Accessories --> Terminal. Then, type in sudo gedit /boot/grub/menu.lst.

This text file contains all the information GRUB uses to configure various boot options. Scroll down and the entries between "## ## End Default Options ##" and "### END DEBIAN AUTOMATIC KERNELS LIST" are the Linux boot options.

Make a backup of the file by going to File, Save As and selecting a different location. Or take a full copy of the contents and place it into a new text file. If you can, create the backup on a removable disk or networked location.

Continue to page 3: Make space for XP
Page 1 Intro
Page 2 Back up the GRUB boot menu
Page 3 Make space for XP
Page 4 Install Windows XP
Page 5 Restore the GRUB boot loader

Post your comment



First 50 Comments

View All Comments (133) RSS feed Email alert

j95:

the line
makeactivechainloader +1

should be:
makeactive
chainloader +1

That's how your instructions worked for me, at least ;)


29 February 2008, 8:32 PM (1 year ago)report abuse Send to a friend reply

Flappz:

Hi Everyone.
I seem to be having a problem. I am using Linux Mint, a dirivitive of Kubuntu, I had GParted and I downloaded Ubuntu, and tried to do this with both, I even installed GParted in my Mint OS to see what I was doing wrong.
I followed the tutorial line by line, I have a 300 Gig ATA drive, I have 120 gig as a fat32 storage part. and I split the Mint Part. into 2 90 gig Parts. so I can install XP along side Mint. When I insert my XP disk, SP1 by the way, it will only reconize the 120 Gig storage Part. The Mint and the new Part for XP will not show up. I have gone with Ubuntu, Mint & GParted to make sure I had the partition formatted as both FAT32 and NTFS and it will not show up.
any Ideas My Friends?
Thanks Flappz

29 February 2008, 8:32 PM (1 year ago)report abuse Send to a friend reply

mathiasv:

To make my dual boot install, I deviated from the guide above by:

* I could not manage flags either in ubuntu-6.06.1-desktop-i386.iso, so I had to use gparted-livecd-0.3.4-10.iso for that.

* After doing: sudo grub, root (hd0,0), setup (hd0), I only got a black screen with an underscore in upper left corner. But I could boot linux when I re-installed grub;
grub-install /dev/hda
before setting it up as described.

* As is already pointed out the lines in menu.lst have to be:
makeactive
chainloader +1

It seems to work just fine now, at last, but my windoze partition is set as bootable according to fdisk -l. But it works:-) Thanks for the guide.

29 February 2008, 8:32 PM (1 year ago)report abuse Send to a friend reply

zoso375:

Can anyone confirm/deny that this guide will work on 7.10 (Gutsy Gibbon)? Will I have to wait and periodically check for the updated article? I miss my ABC/NBC online shows!

29 February 2008, 8:32 PM (1 year ago)report abuse Send to a friend reply

Ciesson:

I've got this to work with Gutsy Gibbon (7.10).
Also for those of you who get the balnk menu.lst files, REBOOT your pc first!

29 February 2008, 8:49 PM (1 year ago)report abuse Send to a friend reply

sjaeger172004:

How do I get the boot loader for Fedora Core 8 to see my Windows XP Pro installation my set up is fedora is separately installed on a 40gb ata hard drive and my windows is on my 200gb sata drive which the drive is partitioned into 2 1 is windows and program and the second partition has my installation files, music and data It will not let give me the choice of booting into windows while the fedora hard drive is connected. PLEASE HELLPPPP!


29 February 2008, 8:32 PM (1 year ago)report abuse Send to a friend reply

Andy:

Good stuff...I have alot of dev experience under my belt, but it's refreshing to come back to something that just works...cheers!!!

29 February 2008, 8:32 PM (1 year ago)report abuse Send to a friend reply

Bohemien:

I have a new 80GB harddrive nothing on it. I want a dual boot system with XP and Linux. What would be best for me to install first?

29 February 2008, 8:33 PM (1 year ago)report abuse Send to a friend reply

mm_vr:

You should definitely install WinXP first. It will be a whole lot easier. Just have a look at the "Dual-booting XP and Linux with XP installed first" guide.

29 February 2008, 8:49 PM (1 year ago)report abuse Send to a friend reply

Manish Singh:

Excellent! This works perfect. I had Ubuntu 7.04 only on my laptop and I was planning to wipe it all up so that I could install Windows XP to play Grand Theft Auto SA.

Since, I had made this system from scratch to a very nice level, it was quite painful to remove it all just for one game. WINE works for most of other windows games on Linux but GTA SA so I had no choice.

Finally, I came across this guide and just followed the directions. To my surprise, it works great. The only thing which I needed to take care about was to install XP on the primary partition as the XP installer didn't allow installing itself on a logical partition.

Yes, it's much easier to have Windows XP installed first and then Linux however, there are quite a large number of folks which have Linux as the primary Operating System on their box and this guide is really a gift for them.

Thanks again. Keep up the good work.

-Mann

29 February 2008, 8:33 PM (1 year ago)report abuse Send to a friend reply

dabar:

Windows boot choice won't work

I have Ubuntu 7.10 installed in sda2 (ext3) into a 9gig partition which was an attempt to not affect the first portion of the disk I had WindowsXP already installed in (which was virused)..I probably overlapped that windowsXP partition which doesn't give me a good feeling about files I was trying to keep (that free space outside, or before of ubunto became unallocated). I installed another version of windows XP over which ended up being /dev/sda1 into 30gigs of space, (there's 50gigs unallocated in the middle of the two).

I followed everything here except after the "find /boot/grub/stage1" returned "(hd0,1). I still had to run "setup (hd0)" because trying to do "setup (hd0,1)" would tell me it failed, I'm not clear all the way as to what I'm doing. Also when I went to boot up Ubuntu, on the menu it was trying to boot "(hd0,2)" So I changed those in the menu.lst and did some experimenting of what "hd" to try to get windows to run under and nothing's worked to get windows to boot up correctly off the list. Any help would be greatly appreciated

29 February 2008, 8:33 PM (1 year ago)report abuse Send to a friend reply

Andrew:

Good guide. Very easy to follow. I got freaked out part way through when I realized that gparted could take hours to shrink my partition. You may want to have mentioned that it takes at least an hour to shrink a 110gb partition to 20gb. Took me 2.5 hours.
Good stuff though, Linux is the future, but I still have programs from the past. I'm chained to XP for the time being.

29 February 2008, 8:33 PM (1 year ago)report abuse Send to a friend reply

Juan:

does this also work with the Eee PC?? Can you do that using an external hardrive??

29 February 2008, 8:33 PM (1 year ago)report abuse Send to a friend reply

rudecam:

i have been able to dual boot XP and linux without any problems. my laptop worked like this for about a week. today i boot up and the grub doesn't give me the option to load windows. i check with gparted and Xp is still there.

any suggestions?
thx
http://img2.freeimagehosting.net/image.php?b9818d50f0.jpg

29 February 2008, 8:33 PM (1 year ago)report abuse Send to a friend reply

Hamza Alhalayqa:

great efforts, thanks .

I've tried that, it works fine with me .

Thanks,



29 February 2008, 8:50 PM (1 year ago)report abuse Send to a friend reply

iand (New user):

After several different attempts, this one works well. I have the Duel-Boot (Linux 7.10/Windows XP) networked to one running Vista, can anyone give me some tips on networking with Linux?

12 April 2008, 1:43 AM (1 year ago)report abuse Send to a friend reply

ryanh (New user):

Thank you very much for such a straightforward and concise article. I got all this done within 2 hours.

Great job!

18 April 2008, 7:57 AM (1 year ago)report abuse Send to a friend reply

steele (New user):

when I type in find /boot/grub/stage1 it says hd0,5 instead of hd0,0 is this just because I have my home partition seperate from my ubuntu system files? Also will I have to change the setup hd to something like hd6?

24 April 2008, 12:02 PM (1 year ago)report abuse Send to a friend reply

steele (New user):

when I type in find /boot/grub/stage1 it says hd0,5 instead of hd0,0 is this just because I have my home partition seperate from my ubuntu system files? Also will I have to change the setup hd to something like hd6?

24 April 2008, 12:09 PM (1 year ago)report abuse Send to a friend reply

steele (New user):

When I type in find /boot/grub/stage1 it comes out to be hd0,5 is this just because my home partition is separate from my ubuntu system files? And also in the next step will I have to change the numbers to say root (hd0,6) and then setup (hd6)?

24 April 2008, 12:09 PM (1 year ago)report abuse Send to a friend reply

B Suh (New user):

One step that I needed to take before the "find /boot/grub/stage1" was "root (hd0,0)"

If I didn't I would get an Error 12 from GRUB ("Invalid device requested.)

Thanks for the article. XP is running well.

24 April 2008, 6:43 PM (1 year ago)report abuse Send to a friend reply

B Suh (New user):

One step that I needed to take before the "find /boot/grub/stage1" was "root (hd0,0)"

If I didn't I would get an Error 12 from GRUB ("Invalid device requested.)

Thanks for the article. XP is running well.

24 April 2008, 6:46 PM (1 year ago)report abuse Send to a friend reply

B Suh (New user):

Hi, in the GRUB step (after booting up with the Ubuntu LiveCD, after completing gparted boot flags and after "sudo grub") I had to type in "root (hd0,0)" or else I got a ERROR 12 before doing "find /boot/grub/stage1"

Thank you for this article. I can run XP for Photoshop CS3 :)

24 April 2008, 6:46 PM (1 year ago)report abuse Send to a friend reply

sinasa2 (New user):

I had windows xp installed first, then installed ubuntu, now i want to install windows xp again. if i do that it'll overwrite my boot. so what shall i do? please contact me at sinasa2@yahoo.com

27 April 2008, 9:36 PM (1 year ago)report abuse Send to a friend reply

free2useemail (New user):

I am going to give this a try, know one said if this works. Anyway, it does look like it is a lot of work, but Ubuntu is not really something I could switch too for good. OH, a question. How much graphic memory do you need to run Ubuntu's eyecandy? I am getting a new graphic card soon, so I am not sure what to get.

28 April 2008, 11:34 PM (1 year ago)report abuse Send to a friend reply

MikeG (New user):

During the XP install, if you create the partition in the blank space and then F3 out of the installation, when you restart the installation the new partition is assigned to drive C.

24 May 2008, 11:11 AM (1 year ago)report abuse Send to a friend reply

scooby (New user):

ATTENTION: ONLY ATTEMPT THIS ON A NEW INSTALLATION OF LINUX, OR ON A SYSTEM THAT YOU HAVE SUFFICIENTLY BACKED UP. Unless, of course you don't care about losing data.
Installing Windows XP after installing Linux had disastrous results for me. I actually installed XP first on a 10GB partition of a 350GB drive. After getting it set up, I installed Mandriva Linux 2007. After some months I tried to get back into XP via GRUB, but couldn't load it back up (don't remember the error). So I thought I would try reinstalling XP. I booted up with the Windows XP installation CD, accepted the license, etc. When I got to the partition screen, XP setup only showed 1 partition of 127GB rather than what should have shown: 10GB(XP),10GB(/),1.5GB(Swap),300GB+(/home). I rebooted to try to get back into Linux, but it was gone. And not only that, but almost all music, videos, pictures, documents, etc. I am still trying to figure out how to get my data back. Yes, shame on me for not having backups, but if I had a large enough disk to back up everything to, I would have just done RAID 1 and had 2 disks unrecoverable.

BOTTOM LINE: Do this only on a new install.

31 May 2008, 4:58 AM (1 year ago)report abuse Send to a friend reply

What? (New user):

Problem...
when i get to the "install xp" step i'm getting a message something like "windows cannot find any installed hdds"...

any suggestions?
thanks!

01 June 2008, 6:44 AM (1 year ago)report abuse Send to a friend reply

What? (New user):

problem...
when i get to the "install xp" step i get a message something like - "windows cannot find any installed hdds"...

any ideas?
thanks!

01 June 2008, 6:51 AM (1 year ago)report abuse Send to a friend reply

theumang (New user):

Hi All!!

any hints about dual booting Ubuntu (Hardy heron) and leopard ?

Leopard worked fine when that was the only operating system on the computer..
after I installed the Ubuntu, leopard was not being recognized by the grub.

I have edited the grub (source - http://www.howtoforge.com/working_with_the_grub_menu) and managed to change the background too, however when I choose Leopard to boot from, it comes up with the error - Error 12 : Invalid device requested.

This is the sudo fdisk -l result..

umang@umang:~$ sudo fdisk -l
[sudo] password for umang:

Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00074fb8

Device Boot Start End Blocks Id System
/dev/sda1 1 2188 17575078+ 83 Linux
/dev/sda2 2189 26511 195374497+ 5 Extended
/dev/sda5 * 2189 26511 195374466 af Unknown

How do I go about fixing this error ?

Thanks
Umang

PS: do not have / want windows on my computer.

04 June 2008, 1:15 AM (1 year ago)report abuse Send to a friend reply

samir (New user):

How can i install windows XP, when I have installed LINUX (Fedora 7) with GRUB bootloader overwriting the windows bootloader. Now I can not boot my Windows XP CD.Now I am totally helpless please help me.
PLEASE HELP...

19 June 2008, 4:08 PM (1 year ago)report abuse Send to a friend reply

Ximpans (New user):

Xp first, no noubt – that will spare you trouble. See the Howto on the matter.

29 August 2008, 3:56 AM (1 year ago)report abuse Send to a friend reply

Felix Rizo Patron (New user):

Hi everybody! I never tried Linux but I now bought a notebook and I would like to try it. The Notebook (Lenovo 3000 n200) has no system at the moment. What is the best to do? I first install Linux, first windows xp? with dual boot, with virtual machine? in the same partition?
Thanks very much for the eventual response, Felix

20 June 2008, 11:32 AM (1 year ago)report abuse Send to a friend reply

toanaruto (New user):

when i type in:
root (hd0,0)
and then
setup (hd0)
it says cannot mount parition


and everytime i press tab when i type root (hd0,1) or any other number for 1 it says selected disc does not exist error 21


24 June 2008, 9:41 PM (1 year ago)report abuse Send to a friend reply

Pavan (New user):

If you have a SATA or SCSI disk, you may have to use sd0 in place of hd0.

28 June 2008, 7:30 AM (1 year ago)report abuse Send to a friend reply

Pavan (New user):

toanaruto, are you trying to boot into Windows or Linux?

if you want to boot into Windows,
on grub prompt, say

rootnoverify (hd0,0)
chainloader +1

If you have a SATA or SCSI disk, you may have to use sd0 in place of hd0.

28 June 2008, 7:21 AM (1 year ago)report abuse Send to a friend reply

Pavan (New user):

I agree that bootloaders shipped with Linux (esp. Grub) are far more powerful than outdated bootloaders shipped with MS Windows.

One more annoying thing about MS Windows installation is, it simply over writes existing MBR. So I decided to setup my box to boot Linux using Windows bootloader itself. A sub-optimal but trouble free solution.

You can read about it at http://bkpavan.wordpress.com/2008/04/02/how-to-boot-linux-using-windows-bootloader-xp/

28 June 2008, 7:23 AM (1 year ago)report abuse Send to a friend reply

andy (New user):

Well, I tried this and once the popped in the XP cd, the installation said "Windows cannot detect any hard drive on your computer" and the only option it gave me was to quit installation by pressing F3. So much for Windows!!

02 July 2008, 3:24 PM (1 year ago)report abuse Send to a friend reply

LesterAr (New user):

Hi! I´m having the same problem. Did you get to solve it? How did you dit it? Thanks!

20 May 2009, 6:04 AM (8 months ago)report abuse Send to a friend reply

LesterAr (New user):

Quoting andy:
Well, I tried this and once the popped in the XP cd, the installation said "Windows cannot detect any hard drive on your computer" and the only option it gave me was to quit installation by pressing F3. So much for Windows!!

Hi Andy! I´m having the same problem. Did you get to solve it? How did you do it? Thanks!




20 May 2009, 6:05 AM (8 months ago)report abuse Send to a friend reply

MartusX (New user):

Hi,

I spent last few nights trying to install Windows XP into a partition on a hard disk populated with my personal data and functional Linux installation. I wanted grub to be my boot loader and Windows and Linux dual booting capability. My populated disk precluded me from wiping the disk and starting with XP installation followed by Linux installation, which seems to be a less tricky way. My way wasn't as straightforward as I had wished but in the end I succeeded so decided to share my experience. I am writing the following text as if you, the reader, were trying to follow my steps.

Problems:
=======
These were the major problems I faced:
1) The Windows XP installation CD would boot but a second later the process would blank the screen and freeze after saying something like "Setup is examining your hardware configuration".
2) The XP overwrote my MBR and partition table and totally screwed it.
3) After XP installation Windows wouldn't boot.

Preparation:
=========
First of all if you want to embark on a similar adventure have your Linux rescure CD handy and print out your partition table on a paper. Basically something like:

# fdisk -l | lp

If you had a working grub in your MBR and want to have it there event after the XP install back it up:

# dd if=/dev/ of=/boot/grubMBR.bin bs=512 count=1

Note that it will include the partition table for the four primary partitions, which will also be restored when restoring the grub MBR.


Solution:
=======
1) The first problem was because there were existing Linux partitions on the HDD where I was installing. The first one was the /boot partition for grub. The second one for XP and there were many more (14 altogether most logical partitions in extended partition). To workaround this I had to hide all the other paritions from the XP installer, even the existing vfat ones as I wanted to be sure that the installed XP sees the second partition as "C:". The hiding trick was to set the partition types to 0 in fdisk during XP install and revert it afterwards.
This allowed the XP install to progress into the next stage where it saw many partitions as Unused or Empty. The next challenge was to pick the right one for the XP installation and avoid overwitting other partitions. I could distunguish it by its size. If I couldn't do it I would set the type of that partition to 7 (HPFS/NTFS) which should let that partition to stand out from the others. It would say Corrup or Unformated or something along these lines. After choosing the partition the installation went smoothly.

2) After the XP installation the system was booting straight into XP. I wanted to restore the vfat and Linux partitions hidden during step 1) and make grub the MBR owner driving the boot process. So I rebooted into Linux Rescue CD and started fdisk only to realise what damage the XP had done to the partition table. It was chaos. There were two extended partitions instead of one, some partitions were duplicated, some missing, some had incorrect and overlapping boundaries. It was totally screwed. But fortunately only the partition table was screwed not the data in the partitions themselves !
But since I had the partition layout and the grub MBR from the Prepearation step I wasn't lost.
I restored the partition table by hand according to the printout I had earlier by using fdisk. I deleted all the partitions in the partition table, and then recreated them to the original specification. This allowed me to mount the /boot partition containing grubMBR.bin and restore the grub MBR:

# dd if=/boot/grubMBR.bin of=/dev/ bs=512 count=1

As I mentioned before this command restores the partition table for the four primary partitions to the state before the XP installation. So next it was time to set the partition type for the XP partition to 7 (HPFS/NTFS) some FAT32 type depending on your choice during the install. The active boot flag on the XP partition should be set also at this point although I am not sure if it is necessary. Grub doesn't seem to need it but I haven't tried if XP boots without it.
At this point grub was back after rebooting and I could choose whether to boot Linux or Windows XP. I had to add the Windows XP entry to the grub.conf file (title WinXP; rootnoverify (hd0,1); chainloader +1) but that was described many times elsewhere.

3) The last hurdle was that the Windows XP wasn't booting. Blank screen followed by freeze. The remedy was simple but it took me a long time to realise what the root cause was. All this hiding partitions business in step one made the XP installer believe it was installing into the first partition (counting from one) whereas in fact it was in the second partition. So I had to update the C:\boot.ini in the XP partition accordingly. Note that unlike disks the partitions in boot.ini count from one so I had to specify two:
multi(0)disk(0)rdisk(0)partition(2)\WINDOWS
To actually be able to edit this file I had to mount the NTFS partition in writeable mode. I used the ntfs-3g package to do it. Please find it described elsewhere.

The quest was over, sigh. I hope some will find my notes useful.

11 July 2008, 8:15 AM (1 year ago)report abuse Send to a friend reply
31 July 2008, 5:53 AM (1 year ago)report abuse Send to a friend reply

bartolomeus (New user):

two small errors on this page:
http://apcmag.com/how_to_dual_boot_linux_and_windows_xp_linux_installed_first.htm?page=5

One of the images have the red squares missplaced, hiding the text instead of circling it.
The line that says "Reboot the system. You'll get the GRUB bootloader but Vista won't be an option - we need to add this to the boot options." should of course say XP not vista in this webpage.

04 August 2008, 9:48 AM (1 year ago)report abuse Send to a friend reply

Moja (New user):

This is an amazing tutorial! Thanks A LOT for your help! :)

15 August 2008, 1:41 PM (1 year ago)report abuse Send to a friend reply

O_Man_RA23 (New user):

Tried this last night. Got to the bit where you install XP, formatted the partition I had left (~75GB) for XP into NTFS, went through the pre-install load (XP killed GRUB as expected), system rebooted itself, let it run through to HDD (rather than CD), and froze. Did not blank the screen, instead filled some segments of screen with coloured rectangles with numbers inserted in the colours and froze.

Has anyone come across anything similar?? Have I missed something (followed the instructions word for word). Am using Ubuntu 8.04 and XP SP2. Downloaded and burnt latest Ubuntu liveCD before embarking. Also made a backup of the MENU.lst file onto a flash disk.

Currently have a 300GB SATAII HDD, 200GB IDE HDD, and was wondering, should I continue with this plight, or re-instate Ubuntu, transfer all personal info onto a new HDD (thinking of buying a 1TB SATAII), then wipe the 300GB clean and install XP then Ubuntu on it?? This would be the 'easy' option, but involves bringing forward some cash outlay that I was putting off till tax came back.

Suggestions??

26 August 2008, 9:51 AM (1 year ago)report abuse Send to a friend reply

aussiemate (New user):

Hi when i try to install xp i keep getting the same message,can not find installed hdd,please can you help

13 September 2008, 5:54 PM (1 year ago)report abuse Send to a friend reply

Fixman (New user):

XP doesn't recognize SATA drives. Download drivers or download Vista, but it has nothing to see with your Linux installation.

20 September 2008, 11:12 AM (1 year ago)report abuse Send to a friend reply

VimFuego (New user):

will this work for an ACER AspireOne notebook with linpus light installed first? - sorry - very new at dual boot and reading around it a LOT first!

08 October 2008, 2:54 AM (1 year ago)report abuse Send to a friend reply

nero60 (New user):

I've already installed Ubuntu 8.04 under Windows XP. During the Boot Sequence Windows XP is the default OS. In order to use Ubuntu, I have to identify it. Is there a way to change the default OS to Ubuntu or is it necessary for me to re-install Ubuntu?

Appreciate any help!

08 October 2008, 8:07 AM (1 year ago)report abuse Send to a friend reply

ebarriosjr (New user):

Tnaks a lot men!!! I just installed Windows xp 64-bits version, and it works like a charm thanks to your guide!!!!
Thanks a lot....

19 October 2008, 6:48 AM (1 year ago)report abuse Send to a friend reply

View all comments (133)  

anonymous user Anonymous user

This month in APC!

Tags