Sunday, June 18, 2006

How to run Windows XP under Ubuntu Dapper


Why?

Because Dapper was just too Damn reliable... nah, seriously, I need to run Microsoft Visual Studio, and doing so under wine was not going to cut it, and dual booting was going to be a pain, VMWare was not open source so....QEMU to the rescue.

Briefly..

There's a program called qemu (http://en.wikipedia.org/wiki/QEMU), by Fabrice Bellard.

Basically it makes a virtual PC within your PC with some standard spec's (NE 2000 network card, Cirrus CLGD 5446 PCI VGA card, etc). The advantage of this is that you're running the actual OS ! (some may say that is not an advantage...)

QEMU keeps this "PC's" partition in one single file, so you can copy that file off somewhere safe and have a "snapshot" of your PC for when the viruses and other nasties get in.

Other neat things in the documentation.

-You can also make that image read only, so that it will never change. (it uses /tmp for a temp file)

-Just like VMWare you can move that image to another machine running QEMU and it should just work.

-QEMU uses a Samba option on the command line to let XP see a samba share, so you can get files in and out of your new OS.

HOW TO...

install qemu
sudo apt-get install qemu

make a directory to put the xp image / iso files etc.
mkdir winxp
cd winxp/

one off creation of the "partition", I used 4.3 gig so I could burn backups to a DVD.
qemu-img create winxp.img 4300M

put in xp cd and type...
qemu -boot d -hda winxp.img -cdrom /dev/cdrom -m 256 -localtime
read this line as "boot -d hda", d=boot from cdrom (c=boot from hdd)
"-cdrom /dev/cdrom" tells qemu where the CD to boot from is
"-m 256" is how much memory this machine has access to
-localtime" tells the new pc's bios to set itself to GMT/UTC from the real PC clock.

now go thru the XP install!

then to boot just make a shortcut to:
qemu -boot c -hda winxp.img -m 256 -localtime
Notice the "c" not makes us boot from the winxp.img file, not the cdrom, as I've left off the -cdrom option here this PC now has no access to the CD drive.

You're all done, log in and try going to google.com ! (it worked for me YMMV)

Note : If you get an error when logging on to XP (after entering password).

If you get an error Error code 0x800703e6 on Product Activation, then your XP is pre sp1 or sp2, follow these instructions....

download sp2
http://www.microsoft.com/downloads/details.aspx?FamilyID=049c9dbe-3b8e-4f30-8245-9e368d3cdb5a&displaylang=en

make an iso of the sp2 exe file.
mkisofs -o sp2.iso WindowsXP-KB835935-SP2-ENU.exe

boot into XP but press F8 immediately to go into safe mode, pointing -cdrom to the iso file of SP2 will mean that the XP machine will have a "cdrom" available when you boot into it.
qemu -boot c -hda winxp.img -cdrom sp2.iso -m 256

Use explorer to get to the cdrom and click the exe file to install SP2. One error will com up about "Invalid Access to Memory Location", no biggy, just hit OK and it will finish.

All done, no more 0x800703e6