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

67 Comments:

Blogger Matt said...

My CD drive is at media/sd0 on Ubuntu Dapper running on a Gateway M305 laptop. I tried tweaking your XP install instructions to substitute /media/sd0 for /dev/cdrom, but I keep getting this error:

could not open hard disk image 'winxp.img'

I did create winxp.img first.

Any suggestions for getting this working?

3:54 am  
Blogger caled said...

I'm no linux guru or anything, but isn't /dev/cdrom a device and /media/sd0 a mount point?

8:30 am  
Blogger Kiyoshi said...

I know your problem, matt. Remember to cd to the winxp directory where the winxp.img lies... I had the problem with my CD being /dev/hdc. But after some fiddling I found out and now it seems to work :D

8:52 am  
Blogger volkan said...

Is ıt fast enough? I`ve tried qemu 3 months ago with my 512MB ram pc but it was too slow to be used. There is something called "kqemu" to accelerate the qemu but ı couldn`t get it worked. So do you need kqemu?

9:12 am  
Blogger El Diablo De Verde said...

Will this work on a PPC Mac?

12:53 pm  
Blogger Lobo Schmidt said...

Congratulations for the blog.

I've just added this to my bookmarks and will try to run WindowsXP on my Dapper Drake in a few minutes.

Keep up the great work.

2:49 pm  
Blogger lcadman said...

Is it worth it having a Ubuntu base and VMing XP for development? Is it fast?

I'm about to redo my system and still have not decided whether I want to do it that way or the dual booting option.

I'm in the same boat as far as needing XP for VS.NET dev.

Thanks

5:09 pm  
Blogger pixie said...

Great Post ! I did it on SuSE 10 because I got the idea from you.
It took alot of time, but now I have WINXP inside my SUSE.
I only need to know How to access the internet from inside WINXP under qemu, and how to acess the cdrom from inside, so I could install VB studio and Office inside.
if any ideas, please tell
10x, Oz.

5:52 pm  
Blogger John said...

For those whoi find this too slow, but have trouble getting kqemu to compile, there's a great automated script and faq at http://www.ubuntuforums.org/showthread.php?t=187413 that downloads, compiles and installs it all for you.

John.

6:24 pm  
Blogger Marc said...

I also use QEMU and find it to be fast enough for my needs. I am using the kqemu kernel module.

Another neat thing about QEMU is that if you make the virtual machine too small, you can easily expand it later by doing a few commands:

http://marc.abramowitz.info/archives/2005/12/18/resizing-a-qemu-virtual-machine-partition-and-filesystem/

7:15 pm  
Blogger Kiyoshi said...

I have a problem. I've installed XP in it alright but after the installation Im greeted with a login screen. When I login as Administrator and no password it say couldnt log in because of limitations in the account. When I login with my full name as specified in the installation it says couldnt log in. WTF?!! I didnt enter any accounts nor passwords!

11:11 pm  
Blogger Kiyoshi said...

XP just installed and the went directly to the login screen.

11:12 pm  
Blogger Kiyoshi said...

Yeah, and another thing. I cant bring up the default log in screen, I get that old skool one where you have to write the account name by hand.

11:12 pm  
Blogger lorenzone92 said...

I haven't a WinXP Cd Image but I've the CD already burned.
Must I create a new Cd Image?

3:44 am  
Blogger Jesús Alberto said...

i did everything u wrote in this blog..but then when win xp starts...it ask me for login and password..and i didnt made one..so i cant log in into xp :(
can u help me with that

8:35 am  
Blogger Mac said...

To get access to the cdrom when you are inside XP, run it with the "-cdrom /dev/cdrom" option.

qemu -boot c -hda winxp.img -cdrom /dev/cdrom -m 256 -localtime

11:38 am  
Blogger Mac said...

lorenzone92. No you don't need the CD image you can boot from the actual cd.

qemu -boot d -hda winxp.img -cdrom /dev/cdrom -m 256 -localtime

11:39 am  
Blogger Mac said...

Yiyoshi / Alberto, you talk about password problems, XP installs have always asked me for a password on setup. I can't help you with an XP install that has not asked you to setup a admin password.

11:41 am  
Blogger Mac said...

Pixie, internet access from XP just worked for me (after boot I ran google and there it was!). I know there are a lot of command line options available in QEMU to do with network access, read the documentation and try some of them.

11:43 am  
Blogger Mac said...

QEMU is not super fast by itself, I recomment trying to get the acceleration program KQEMU working, there is also a program called qvm86, which is an open source accelerator, just google qvm86. I have not got either of these working yet, but will post instructions when I do.

11:46 am  
Blogger Don said...

Thanks. It worked for me on Dapper and a Certera notebook which is very generic. Intel mainboard and Pentium M 1.73 mhz cpu and 512 mb RAM.

2:51 pm  
Blogger 魔法設計師 said...

Hi I am interested.I have a question.I already have a ntfs partition with installed win XP.can QEMU direct launch it without making a image?

3:47 pm  
Blogger Flatline said...

Somewhere (I can't really find the article now) I read that quemu-created images can be read through VMWare Player (which is free altough closed-source). So if you find qemu slow, you could try this solution, many says VMWare is really faster than qemu (I didn't try it myself).
Anyway, how much RAM do you have installed? On my 512MB laptop it's a crawl!

4:43 pm  
Blogger lorenzone92 said...

@Mac: I've changed dev/cdrom with media/cdrom but when I type:

qemu -boot c -hda winxp.img -cdrom /dev/cdrom -m 256 -localtime

It says:
qemu: could not open hard disk image 'media/cdrom'

Why?

6:40 pm  
Blogger lorenzone92 said...

@Mac: I've changed dev/cdrom with media/cdrom but when I type:

qemu -boot c -hda winxp.img -cdrom /dev/cdrom -m 256 -localtime

It says:
qemu: could not open hard disk image 'media/cdrom'

Why?

6:41 pm  
Blogger tenchi39 said...

Hi!

Great blog, but I've got a problem. After installing a hungarian XP professional (SP2), upon restarting, the splah screen came up, but after 1-2 seconds it went away to a blank black screen with the mouse. It later reset and the whole thing started again...

What can I do?

7:30 pm  
Blogger RICH BAE said...

This comment has been removed by a blog administrator.

8:15 pm  
Blogger RICH BAE said...

This comment has been removed by a blog administrator.

8:19 pm  
Blogger Justin said...

i get the same problem as matt did

"could not open hard disk image 'winxp.img'
"
i dunno what to do...and i could not figure it out by what you guys said

11:48 am  
Blogger Chris Richards said...

Great article. I'm going to try it straight away.

Is there a way to access linux files from the WinXP? Also can you access the files created by WinXP from linux? Then it would actually be useful.

Thanks

1:19 am  
Blogger Mac said...

This comment has been removed by a blog administrator.

4:27 pm  
Blogger Mac said...

Chris,

There is a -smb option for qemu that specifies an smb share (you need samba loaded). I've not used it, but just RTFM and you'll find it ! :-) Mac

4:29 pm  
Blogger Jon said...

FOR ERROR "could not open hard disk image 'winxp.img'"

you have to be in the director where the winxp.img image is.

so in terminal type in "cd winxp/" with out the quotes, and THEN type in "qemu -boot c -hda winxp.img -m 256 -localtime" without the quotes

4:34 pm  
Blogger Jon said...

and how can you implement theese two commands into a shortcut?

4:35 pm  
Blogger Pedro said...

Realizo TODOS los pasos que están en el How-To y me tira el mismo error que a varios:

qemu: could not open hard disk image 'winxp.img'

8:35 am  
Blogger Pedro said...

Me respondo a mí mismo, también a los otros con el mismo problema:

El error se da debido a dónde se crea la imagen (en qué disco), la primera vez lo hice fue en un disco tipo vfat y no me funcionó (y me marcaba 0 byte de tamaño)

Luego volví a crear la imagen en mi home (ext3) y lo hizo sin problemas, además de que me marcó el archivo winxp.img del tamaño con el que fue creado...

8:38 am  
Blogger Jesús Alberto said...

maybe chris richard could be interested in this article..as many other people too
The "Ubuntu in Windows" article:
Free Emulation with Qemu
Current version 1.1, June 2006.
español:
http://homepage.sunrise.ch/mysunrise/ekeller00/html/Keller_06_UbuntuEmuladoEnWindows_S.html

Deutsch:
http://homepage.sunrise.ch/mysunrise/ekeller00/html/Keller_06_UbuntuEmuliertesSystemInWindows_D.html

english:
http://homepage.sunrise.ch/mysunrise/ekeller00/html/Keller_06_UbuntuEmulatedInWindows_E.html

francais:
http://homepage.sunrise.ch/mysunrise/ekeller00/html/Keller_06_UbuntuEmuleSurWindows_F.html

saludos pedro de donde eres

1:42 pm  
Blogger sesstreets said...

IF YOU HAVE TWO CDROMS TRY USING /dev/hdc INSTEAD OF USING /dev/cdrom

WORKED FOR ME!!!!

7:07 pm  
Blogger Empire Dave said...

Thank you for this info - it worked a treat :-)
I installed an xp image a while ago but never realised that installing sp2 would fix the problem.

I'm having trouble compiling kqemu though.
I used your script but the module does not exist

6:18 am  
Blogger A Cat in California said...

This post is fantastic! I want to get rid of Windows but, unfortunately, we all know that there are still applications we need to use that run on Windows only.

I recentely heard of Ubuntu and I am definitely going to check this installation out. If it works well enough, I could finally remove Windows from my machine and run it in a Virtual Machine only when I need it.

9:31 am  
Blogger James said...

Hi Matt,
This is off-topic, but did you get the resolution on your GatewayM305 latop to work at 1024x768?? I've been having problems getting it to work for over a year now. Any help would be greatly appreciated.

Thanks.

4:00 pm  
Blogger Wil said...

Also, if you have a DVD drive (or two, in my case), try either /dev/dvd or /dev/dvdrw

7:42 pm  
Blogger Wil said...

Also, if you have a DVD drive (or two, in my case), try either /dev/dvd or /dev/dvdrw

7:42 pm  
Blogger Wil said...

Also, if you have a DVD drive (or two, in my case), try either /dev/dvd or /dev/dvdrw

7:42 pm  
Blogger Richard Colbert said...

While I found this tutorial extremely helpful there are a couple tips I would like to add for everyone else....

Once you install QEMU insert your Windows XP cdrom and make an iso image of the disk. Name it xp.iso and save it in the same directory as your winxp.img file then when you go to start QEMU to install XP use this command:

qemu -boot d -hda winxp.img -cdrom xp.iso -m 256 -localtime

That will start the install from the xp.iso file and will reduce install time by at least half over using the actual cd.

12:29 pm  
Blogger dehumidifier said...

Hello

I like your blog. The articles are amazing.
Thank,s

Joel
songs

4:29 am  
Blogger lotsotrash said...

I had to change "/dev/cdrom" to "dev/hdc". Check "/etc/fstab" to be sure.
ex.:
qemu -boot d -hda XPlite.img -cdrom /dev/hdc -m 512 -localtime

2:14 pm  
Blogger The Monk said...

Well, I did everything that you suggested. It all seemed to work, but when I try and start it up it just freezes. Could be that I used the Gateway restore cd that came with the laptop. I will try a different one an see if I have any better luck. Oh, and if you do find a workaround for the gateway screen res stuff, let me know.

1:58 pm  
Blogger Cristóbal De la Piedra said...

Nice Blog. I can't run my setup's of my drivers , ViaXXX sound , the Ethernet Rine card, Usb 2.0... so i will try with Vmware.Byee

5:41 am  
Blogger Driveby Software said...

Works Great.

Not bad for my first virtualization. I only have three questions? And any help will be greatly appreciated.

1) what command can I type into the Alacarte Menu Editor to run QEMU via a shortcut? (tried: sudo cd winxp/qemu -boot c -hda winxp.img -m 256 -localtime) Didn't work.

2) How can I get a Lexmark Printer (P4350) to print under the host and guest OS?
(Ubuntu 6.06 Host - Windows XP Guest)

3) How can I drag and drop or copy and paste file between the host and guest OS?



2)

3:38 pm  
Blogger ALIENDUDE5300 said...

Ubuntu Running Under Windows
I changed your instructions a little and did the opposite - running Ubuntu Edgy (6.10) under Windows XP. however, I cant get any internet access. Does anyone have an idea how to get it connected to the internet? (I know how to connect Ubuntu to the internet without emulation but it can't detect the access controller.)

12:41 pm  
Blogger Antunovic Mladen said...

I have installed qemu on ubuntu 6.10 ad then I installed windows xp as virtual machine and my really windows xp gone because it was on C: or in linux hda but I also tried to put hda7 like this
qemu -boot d -hda7 winxp.img -cdrom /dev/cdrom -m 256 -localtime and it doesn't work and result is my windows crashed but my linux and windows in qemu still work.

Is there any way to install windows on qemu and to have my real windows because I need both.

I have to make virtual machines because that is my work on faculty

3:23 am  
Blogger Fede said...

Hi, it's very interesting article, I was using, but i have a problem, the virtual machine don't use bridge, so the virtual machine isn't part of the network.

Thanks!

5:39 am  
Blogger Lankan526 said...

why is the qemu windows small? i dont know if it is always small because it is small right now when installing, but is it actually that small? and how can i make it bigger?

1:31 pm  
Blogger Mind In Motion said...

When I failed to start qemu several times with this error:
qemu -boot c -hda hd.img -cdrom /dev/cdrom -m 256 -localtime
qemu: could not open hard disk image '/dev/cdrom'

I found the solution: sudo qemu -boot c -hda hd.img -cdrom /dev/cdrom -m 256 -localtime

9:38 pm  
Blogger Jan said...

ok quick question how well do games work through this because thats really the only thing i miss about windows

6:32 am  
Blogger James said...

does Visual Studio work well ?

2:45 am  
Blogger kirk said...

Hi I have an intel macbook and I eventually plan to run windows through ubuntu as above however I really don't know what I'm doing! I've got as far as backing up all my files and partitioning my hard drive. I've downloaded ubuntu - now I'm stuck. Obviously I can't open the ubuntu files because osx won't read them. What do I do now?

Many thanks for your help in advance

12:19 pm  
Blogger Jonesey said...

It wouldn't let me format the drive as NTFS so had to do FAT32. Other than that, it's installing just fine! I'll post when I have tried VS2005 and Photoshop CS3!

12:44 am  
Blogger Luis Cabellos said...

I have the same problem than jonesey, is it possible to format it in NTFS after the instalation?

7:33 am  
Blogger Faraz said...

Hi!

There is one thing i dont undertand.

Why is it necessary to install windows when you, with other programs like Wine, can import your already installed programs for example Dreamweaver and photoshtop to Linux.

Isnt it possible to just "run" windows in the background (like in your screemshot) by using the already installed windows.

By "reinstalling" windows, one will have to reinstall all the other programs as well ...

I find that a bit problematic and would like to figure out why it cant be possible to execute windows with the one already installed.

I hope someone can reflect upon this and enlighten me about this situation.

Thanks.

Regards,
Faraz

2:28 am  
Blogger elizabeth bernot said...

Tours Costa Rica

Costa Rica Tours

http://www.kingtours.com/

3:57 pm  
Blogger Costa Rica Tours said...


Costa Rica Honeymoon All Inclusive Packages,
Costa Rica Honeymoon Vacation Packages,
Costa Rica Vacations All Inclusive,
Costa Rica All Inclusive Vacations,
Costa Rica Mountain Biking Tours,
Costa Rica Horseback Riding Tours,
Monteverde Cloud Forest Reserve Tours,
Carara National Park Tours,
Costa Rica Surf Lessons Jaco,
Manuel Antonio Beach Tours,
Costa Rica Tours,
Arenal Volcano National Park Tours,
Rincon De La Vieja National Park Tours,
Poas Volcano National Park Tours,
Costa Rica Family Surf Vacation Packages,
Arenal Volcano Overnight And Monteverde Cloud Forest,
Tenorio Volcano National Park Tours,
Tortuga Island Costa Rica Tours,
Costa Rica Canopy Tours Los Suenos,
Irazu Volcano National Park Tours,
Braulio Carrillo National Park Tours,
Manuel Antonio National Park Tours,
Costa Rica Bird Watching Tours Jaco,
Costa Rica Transportation,
Costa Rica Volcano Tours,
Costa Rica Tours,
Costa Rica National Park Tours,
Palo Verde National Park Tours,
Costa Rica Rent A Car

2:22 pm  
Blogger Costa Rica Weddings said...

Costa Rica has some of the best Sport Fishing in the world. The Pacific side
has incredible fishing for Sailfish, Marlin, Dorado, Tuna, Wahoo, Roosterfish,
Snapper, and more. The Caribbean side and Northern regions of Costa Rica are
famous for big Tarpon and big Snook.Costa
Rica Fishing Packages
, Costa
Rica Fishing Boats
, Costa Rica Fishing,
Costa Rica Sport
Fishing Packages
, Costa Rica
Fishing
, Costa Rica
Fishing Packages All Inclusive
, Fishing Trips Costa Rica,
Los Suenos Costa Rica Fishing,
Los Suenos Costa Rica Fishing Charters
, Costa Rica Fishing Vacation Packages,
Costa Rica Fishing Packages All
Inclusive
, Costa Rica Fishing
Trips
, Costa Rica Fishing Trips
All Inclusive
, Sport Fishing
Costa Rica
, Costa Rica Sport
Fishing Charters
, Sportfishing
In Costa Rica
, Jaco Costa Rica
Fishing Charters
, Jaco Costa
Rica Fishing Packages
, Jaco
Costa Rica Sport Fishing


 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

CostaRicaWeddingPlanners is an unforgettable experience. We are the premier
planners, coordinators, officiants, and photographers of Costa Rica weddings and
our site is proof positive of our experience and commitment to weddings in this
beautiful country.Costa Rica
Weddings
, Costa Rica
Wedding Packages
, Costa
Rica Weddings All Inclusive
,Wedding In Jaco Costa Rica,
Costa Rica Wedding Venues,
Costa Rica Wedding Packages All
Inclusive
, Costa Rica
Wedding Planner
, Getting
Married Costa Rica
, Costa
Rica Destination Weddings

Costa Rica fishing los suenos,
sport fishing vacations costa rica,
costa rica fishing vacations,
costa rica tours,
vacation planner costa rica,
costa rica holiday rentals,
costa rica fishing charters,
costa rica beach vacations,

9:08 am  
Blogger Costa Rica Weddings said...

This comment has been removed by the author.

9:55 am  
Blogger Costa Rica Weddings said...

Costa Rica
Weddings
, Costa Rica
Wedding Packages
, Costa
Rica Weddings All Inclusive
,Wedding In Jaco Costa Rica,
Costa Rica Beach Weddings,
Los Suenos Wedding,
Jaco Costa Rica Wedding,
Jaco Wedding Planner,
Costa Rica Married,
Wedding Planning Costa Rica,
Costa Rica Wedding Locations,
Costa Rica Wedding Venues,
Costa Rica Wedding Packages All
Inclusive
, Costa Rica
Wedding Planner
, Getting
Married Costa Rica
, Costa
Rica Destination Weddings


Los Suenos Costa Rica,
Los Suenos Costa Rica Condos For Rent,
Los Suenos Costa Rica Vacation Rentals,
Los Suenos Condos For Rent,
Los Suenos Vacation Rentals,
Los Suenos Condominiums,
Los Suenos Condo Rental

7:54 am  
Blogger Costa Rica Weddings said...

Costa
Rica Fishing Packages
, Costa
Rica Fishing Boats
, Costa Rica Fishing,
Costa Rica Sport
Fishing Packages
, Costa Rica
Fishing
, Costa Rica
Fishing Packages All Inclusive
, Fishing Trips Costa Rica,
Los Suenos Costa Rica Fishing,
Los Suenos Costa Rica Fishing Charters
, Costa Rica Fishing Vacation Packages,
Costa Rica Fishing Packages All
Inclusive
, Costa Rica Fishing
Trips
, Costa Rica Fishing Trips
All Inclusive
, Sport Fishing
Costa Rica
, Costa Rica Sport
Fishing Charters
, Sportfishing
In Costa Rica
, Jaco Costa Rica
Fishing Charters
, Jaco Costa
Rica Fishing Packages
, Jaco
Costa Rica Sport Fishing

11:40 am  

Post a Comment

<< Home