I saw that Ross was a little curious about virtualization at the Smurf on Spreadsheets blog, and figured I’d share my reasons, some experiences, and methods for working with this tool. I might even post more on this, as VMWare has some really cool features that can make setting up testing environments very easy.
What is a virtual machine and why use one?
For anyone who doesn’t know what a virtual machine (VM) is, this is a pretty simplistic summary:
You run a “host” operating system, be it Windows XP, Vista, Linux, or whatever. You then install a virtualization software and create a “space” in which you can install a virtual machine. Into this space you install another (“guest”) operating system. It can be the same, or different if you like. Basically, it allows you to run another computer within a window on your machine. The guest virtual machine works just like a standalone PC. It boots up, shuts down, accesses the internet, etc.
There are a few reasons why I use a virtual machine for my desktop at work:
- I had an old desktop with a ton of programs configured on it. Rather than have to reinstall everything, and source out programs whose install disks I may have lost, I can just run the old computer within a window on my new computer.
- We use Novell Groupwise 6.5 for our email systems. It is not supported on Windows Vista. Again, virtualization allows me to still run this on XP.
- It allows a clear separation between my work and personal use of the PC. I can turn off “work” at the end of the day and it is all contained within that space.
What does it take to run a Virtual Machine?
You basically need two things in order to run a VM: software and resources.
The main virtual machine softwares in use right now seem to be VMWare (which comes in a few flavours), or Microsoft’s Virtual PC. Personally, I’d rate VMWare Workstation about five years ahead of Virtual PC. Virtual PC is free, but you can download a trial version of VMWare Workstation, create your VM, then use it in VMWare’s free Player once your workstation trial expires. So cost shouldn’t be too much of a cost unless you feel the need to create new VM’s on a regular basis.
The other thing you need is resources. It should be pretty obvious that you’ll still need enough resources to run your host operating system, as well as the resources to run the guest operating system as well. So assuming that you want to run a Vista host you’ll need the minimum of 512MB of RAM. If you want to run a Vista guest, you’ll need another 512MB of RAM for the guest operating system. Now, this is a bare minimum, of course. You’re going to get way better performance the more resources you have. On my system, I’m running a Core 2 duo processor and 4GB of RAM, with one processor and 1.5GM of RAM dedicated to the guest. The rest is reserved for the host OS, in case I want to run 2 VM’s at the same time.
This is a pretty brief overview, but to put it simply, you should expect that you’ll get best performance if you add more oomph to your host system . You’ll also get better performance running a host OS that doesn’t consume all the resources… in other words… Vista makes a lousy host.
Converting your existing PC to a VM
Now, due to my little disaster the other day, I had to rebuild the Windows XP virtual machine that I use for work. I figured that I would document how I did it, partly so I remember for next time, and partly for anyone else who is interested. Remember that I’m using VMWare, not Virtual PC, so the steps listed are geared towards VMWare.
- The first step was to download VMWare’s Converter program. This utility can be used from a couple of different angles, including allowing you to virtualize (image) your PC from your host PC. The route that worked best for me was to install the converter on the old PC and image it to a USB hard drive.
- I then took the image, copied it onto my new computer and booted it up in VMWare. Make sure when you do this, that you choose the settings you want for processors, RAM, etc… Try not to get too aggressive at this point. Things will be a bit slow in the guest until you tune it, and in my experience, putting in more processors and high RAM doesn’t seem to help too much.
- Next you’ll need to activate windows. Virtualization moves your machine into a hardware agnostic environment, but it does this by replacing all of your “hardware” with generic virtualized hardware. Because Windows activation keys are tied to your hardware, this massive shift requires an immediate reactivation before you can move on.
- Upon booting into windows, I immediately installed VM Tools. This is huge, since it improves performance of the guest OS, affecting the mouse, video, etc…
- If you want to be able to boot up your old PC as well as the new VM based on that machine, you’ll need to change the security identifier of one of the machines.Â There is a tool call NewSID available from Microsoft TechNet to do exactly this.Â It takes a while to run this, but can be well worth it to install.
- I then spent a huge amount of time uninstalling applications that I did not need any more. Many of these were legacy apps that I should have cleaned up on the old PC, others were utilities from the manufacturer of my old PC. I basically hacked and pruned out everything I could, leaving only the programs that I still needed. The reason? So I could compress the image to make it run more quickly and efficiently. As you can imagine, a few reboots were necessary in this process.
- After uninstalling all this stuff and rebooting, I ran my favourite registry cleaner (CCleaner) in the VM a few times. I made sure that I cleaned up all the legacy reg keys, as well as cleaned up all the temp files and other garbage that was left behind.
- Another reboot later, and it was time to do a full defragmentation inside the guest OS. This is an important step in cleaning up, as I had uninstalled a ton of stuff, so the drive was badly fragmented. I have my own tool of choice for this, but you could use the standard defragmenter built into the OS. Personally, I like to run a defragmenter twice, just to make sure it’s all good, but that is probably overkill.
- Once this was done, I shut down the VM and used VMWare’s tools to defragment the virtual disk file. Fragmentation in a VM can actually occur on 3 levels. Inside the guest OS itself, on the actual virtual disk file that contains the VM, and in the host operating systems disk as well.
- You may have guessed the next step already… I defragmented my host machine’s hard disk to make sure that everything was set up nicely to be as efficient as possible.
Now, at this point I went ahead and used it for a day. It worked okay, but I was having a couple of issues. The first was that the performance wasn’t all that I wanted out of it. The second was that I didn’t have my dual monitor support. So I set to fixing both of those.
- With the VM booted up, I decided to “shrink” the virtual hard disk. This is important, since my old PC had a 37.3GB hard drive. After all the other performance tuning and program removal, it didn’t need to be this large. So using the VM Tools from within the guest OS, I did the “shrink”. Essentially, this just scales the disk size down to only use what it needs, allowing it to dynamically grow later if it needs more space. My virtual disk decreased from 37.3 GB to 17.2GB. It now boots WAY faster as well.
- Finally, I upgraded the VM to Workstation v6 from Workstation v5. I’m not sure if this is a problem because I’m using an old version of the converter or not, but all the same it was necessary. v6 supports USB in the guest, as well as adds dual monitor support.
And that’s the end of it. It is a lot of work to set up, sure, but less so that installing a fresh copy of Windows and customizing it to the nth degree to get it just right.
Oh… and one final thing… this time I made a backup of the completed VM image.