« July 2006 | Main | September 2006 »

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 2:54 PM | Comments (0)

August 11, 2006

Installing and updating applications in Linux (Ubuntu)

'The Linux Newbie' has a good post about how to pick a Linux distro.

It recommends visiting Zegenie Studios Linux Distribution Center list of questions, which is well put together and easy to use. It gave me a number of suggestions, top of which was Mandriva (formerly Mandrake) and the last of five was Kubuntu, the distro I actually went with in the end.

Linux Newbie went with Kubuntu also. I would have tried Ubuntu but I just don't like Gnome as a desktop, I find KDE to be more configurable and a better fit for me.

One thing that Linux Newbie had an issue with was installing packages. He went to great lengths describing downloading tarred packages, finding dependencies etc. Yes, that sometimes happens and it was one of the issues I used to have with Linux.

Apart from very few applications so far I have found Kubuntu's built-in package (application) management software excellent. It obviates the need to manually satisfy dependencies and the like.

You can run it through a graphical interface called Adept, or through the command line using apt-get.

The one thing you have to look out for is making sure that the sources for repositories of applications are up to date, which can be a little confusing and trying but once you have that set up all should be golden.

If you have been having issues installing applications you can try the following.

Open a command/terminal window. Type sudo su which will switch you to run as root. You will be prompted for the password that you supplied at installation. Once you are root type vi /etc/apt/sources.list. This will allow you to start editing the file that lists the sources of repositories from where you can install your applications.

Scroll down through the file using your cursor keys. You should see some lines resembling:

deb http://ie.archive.ubuntu.com/ubuntu/ dapper main restricted

if any lines that resemble this have a hash sign '#' in front of them, that means they are commented out. This can happen when you are installing if you have no network connection or if the installation couldnt setup the network card/tcp-ip setting correctly. The installation will check to see if it can connect to all the repositories listed and if it can't then it comments out all the entries that are unavailable, which makes sense when installilng but causes issues when you have installed and are looking to get the latest version of OpenOffice or whatever.

So, if you find a line that is commented out you will have to edit it. This is a little tricky, but stick with me. First of all move the cursor to the start of the line that is commented out. Hit 'i' to start editing the file (inserting in vi speak). Stuff like end/home pg up/pg dn may or may not work, so better just to stick to using the standard left/right/up/down cursor keys. Delete the # from the start of the line. When you have done that you will want to check the rest of the file for more commented out lines. HIt the escape (Esc) key to stop editing - this won't exit the file, just stop allowing you to type characters into the file. Find and repeat the process until you have removed all the hashes from the start of any of the lines starting with 'deb'. There are other commented lines in there but they are mainly notes regarding the meat and potatoes and they should have two hashes ## before them any way - ignore them.

When you are happy with your changes and you have hit Esc to stop editing (inserting) it is time to save the file.

Hit Esc again, this will put vi into a state where it wil accept commands. Next type the characters between the single quotes - ' :wq! '. This basically tells vi to save and exit.

By the way if you get yourself into trouble while editing (easy enough to do with vi), don't panic. Just bring yourself to command enter mode by hitting Esc a couple of times and enter ' :q! ' which will tell vi just to quit. Then start editing the file again by typeing vi /etc/apt/sources.list. If you keep getting yourself into trouble then you might try editing one line at a time, then saving and quit before re-opening the file and editing the next line.

Assuming you have completed editing all the commented lines you will next have to tell apt-get to update its locally held list of applications and their versions.

Type apt-get update.

Stuff will happen for a while - let it finish, it will only take a short while. If you are asked anything it is fine to just type Y to say yes, continue, whatever it takes.

Once that is done, you are best running Adept. This is found under the KDE equivalent of the 'Start' button, found in the lower left of the window on the taskbar. Find the system menu, click on 'Adept'. It will ask you for your password and then display lists of applications that you can install. Play with a while and you will soon see it is quite easy to use.

I prefer to use the command line for most things. In the example that Linux Newbie gave installing or updating OpenOffice is simple:

apt-get install openoffice.org

Stuff will happen and when it is done you can be sure that you have the latest, stable version of Open Office on your machine. Compare that with windows - open your browser, navigate to OpenOffice.org, find the download page, go through the screens to get to your download, download it, find it on your drive, double-click, yadda yadda....

I think you can see that apt-get is a much easier solution all round :)

As an extra bonus you can do the following

apt-get upgrade

Which will check ALL your installed applications and OS components etc. and update the whole lot automatically while you go off and get a cup of tea.

Posted by dottie at 12:56 AM | Comments (0) | TrackBack