« Installing and updating applications in Linux (Ubuntu) | Main | Ruby on Rails on Windows! Happy happy joy joy? »

August 13, 2006

Create a Virtual Machine for Windows XP on Ubuntu in five minutes

Five minutes? Whatever, I didnt actually time it, but apparently headlines like 'Do x, y an z in five minutes' are very popular. Since I always craved being one of the cool kids, there you have it.

First, make sure you have plugged in your computer :) and are running Linux (the commands provided here apply to Ubuntu) and have an internet connection etc.

Second, you will actually need to have a valid Windows XP Pro installation disk. You don't have one (good for you!) now pop off to the shops and get one. I'll wait here until you get back.

OK, now we have all the pre-requisites we can start.

We need to install QEMU, and the free VMWare Player. We should make ourselves root before we go any further:

sudo su


Then type your password when prompted. You now have root! (j00 r s() 1337!)

To install Qemu:

apt-get install qemu


Let it do its thing, you may be required to type 'y' to accept the installation. Think long and hard about it, consider the alternatives and the socio-political impact of actually allowing the installation to continue. Hit 'y' anyway.

When that is done install the free VMWare player:

apt-get install vmware-player


You CAN do all this through adept or whatever package manager you use but the vmware player has a couple of ASCII dialog screens that require you to agree to terms and contracts and the like (don't bother reading it, something about your immortal soul and hellfire, nothing to worry about...), but if you DO use Adept you can't (at least I couldn't) access the dialog screens to proceed. When using the command line use the cursor keys and to select the relevant boxes and press Enter to accept them.

VMWare player has a load of stuff to install so it can take a while. Also the first time I did it I got some weird error - but Ubuntu suggested running a command (didn't take note of that...) that cleaned it right up and allowed me to continue/correct the installation by re-entering apt-get install vmware-player.

If you have any other major errors at this point you are on your own I'm afraid as I didnt have to overcome them and don't know what the issue(s) might be. Sorry.Cool. Now you have Qemu and vmplayer installed.

Great. What now?

Now we need to create a Virtual Machine disk (don't know the proper terminology). First of all, create a directory for the virtual machine. I made this in my home folder which I am sure is blasphemy to Linux gurus everywhere, whatever, it works for me.

After some attempts at figuring out Qemu myself I resorted to Google and came up with the following:

qemu-img create -f vmdk WindowsXPPro.vmdk 10G Formating 'WindowsXPPro.vmdk', fmt=vmdk


Which will create a 10 Gig virtual disk for your new virtual machine, I am only going to be usin Windows for browser testing and some basic editing with Fireworks and Photoshop so 10 Gigs should be plenty. Change the '10G' bit in the command to suit your needs.

Next we need to create a configuration/launcher file for the virtual machine. This basically tells the vmware player what it is loading, what ports to use, memory size etc. A good few examples are on line. This worked well for me:

#!/usr/bin/vmware
config.version = "8"
virtualHW.version = "3"
ide0:0.present = "TRUE"
ide0:0.filename = "WindowsXPPro.vmdk"
memsize = "512"
MemAllowAutoScaleDown = "FALSE"
ide1:0.present = "TRUE"
ide1:0.fileName = "auto detect"
ide1:0.deviceType = "cdrom-raw"
ide1:0.autodetect = "TRUE"
floppy0.present = "FALSE"
ethernet0.present = "TRUE"
usb.present = "TRUE"
sound.present = "TRUE"
sound.virtualDev = "es1371"
displayName = "Windows XP Pro"
guestOS = "winxppro"
nvram = "WindowsXPPro.nvram"
MemTrimRate = "-1"
ide0:0.redo = ""
ethernet0.addressType = "generated"
uuid.location = "56 4d 42 8c 5a f6 ad 17-65 74 0c 49 58 38 c4 39"
uuid.bios = "56 4d 42 8c 5a f6 ad 17-65 74 0c 49 58 38 c4 39"
ethernet0.generatedAddress = "00:0c:29:38:c4:39"
ethernet0.generatedAddressOffset = "0"
tools.syncTime = "TRUE"
ide1:0.startConnected = "TRUE"
uuid.action = "create"
checkpoint.vmState = "WindowsXPPro.vmss"
tools.remindInstall = "TRUE"

Save the above into a file called WindowsXPPro.vmx which is the same file name as the virtual machine drive with a different extension (which should be mapped to the vmware player).

The one part of that you might want to change is the memsize. I have a Gig of memory on my laptop so I set it to 512 (Megs) which seems to work fine. You can play around with this a bit as the memory of the virtual machine is determined by this value and is not set in stone when you first install Windows - play with it until you crash something if you like!

Ok, now it's time to insert your WinXP Pro installation disk (are you guys back from the shops yet?) and launch the Virtual Machine. You can use konqueror (or whatever) to navigate to the directory and click on the WindowsXPPro.vmx file or just type:

vmplayer /path/to/winXPvvm/directory/WindowsXPPro.vmx


This should kick off the vmplayer and start the installation process for WindowsXP Pro. You might get an error about the Soundcard not being accessible - I did, no biggie, we'll be using Amarok in Linux to play tunes anyway...

Go through the normal windows installation process - you might choose FAT32 as the format of the drive as it will make it easier to share files with Linux.

Once the installation completes and Windows reboots (inside the Virtual Machine - Linux just keeps on chugging away happily) you will be done!

Install your applications and whatever baseline stuff you want on the Virtual Machine.

Now, make a backup of your Virtual Machine directory and you will be able to restore windows back to its pristine condition whenever you want. So throw away that Windows installation disk now... ;)

Posted by dottie at August 13, 2006 2:54 PM

Comments

Post a comment




Remember Me?

(you may use HTML tags for style)