Virtual PC and its arsenal of files - how to manage your MS Virtual PC files.

Tuesday, July 8, 2008

I have blogged about using MS Virtual PC for development purposes and in the few years I've been using this technique, I have convinced many developers to try this it. You can search this BLOG for "Virtual PC" and see what I've said before. I use this very technique still to this day and I use VPCs almost every day. My only consideration these days is weather or not I'll be moving to alternate tools than Microsoft VPC, for instance, Parallels or VMWare, both of which are excellent products in it of themselves. However, that's a topic for another post for sure.

Today I want to talk about a seemingly obvious topic related to MS VPC that apparently is not so obvious to the average VPC user. This topic came from a customer of mine who recently sent an interesting question. This customer has been successfully using virtualization to simulate "TEST" environments before they rollout production updates to a mission critical application. Virtual PC has worked very well for them and it has saved them a bundle in hardware costs and licenses - not to metion the headaches it has saved them from by bing able to test their "new releases" without affecting their core business. Nontheless, his question was along the lines of "How do I backup a Virtual PC" so that I can "drop" any changes to it and start from scratch. It occurred to me that a review of the files that VPC uses was probably the best way to answer his question.

In VPC, there are various files:

.vhd – is the “Virtual Hard Drive”. This is the largest and most important file for VPC. It can be as much as 16GB in size (the MS VPC maximum single drive size). In essence, this is like an IMAGE of a computer’s drive similar (though not compatible with) Acronis Image or Norton Ghost. You may have more than one VHD to suit your needs, with each “mounted” on the VPC as a separate hard drive (this is a way to get around the 16GB limit – to have an operating system drive and also a “data” drive.) By the way, this file can grow to 16GB but only in NTFS drives capable of such a size. In FAT32 drives, files can only grow to 4GB... so, VPC automatically creates numbered files, each of no more than the 4GB limit. In this case, the files are named .vhd for the first file, and .v01, v.02, etc. for the additional files. See the VPC specs from Microsoft for more specifics. For the purposes of this post, though, I will just refer to the .VHD as a single file, but keep in mind it may actually be more than one file.

.vmc – is the “Virtual Machine Configuration”. This is the details of “how” the VHD should run (how much ram, what resolution, on what network, supporting audio, etc). This file is akin to your “computer hardware” but is a throw away and can easily be recreated if you have a good VHD file.

.vsv – is the “Virtual Saved State”. If you have chosen to “suspend” your VPC (similar to the HIBERNATE of a notebook), this is the “hibernation” file which has the contents of RAM and everything else VPC would need to restore your virtual machine in the same exact “state” as you left it – with running programs, logged in, etc. This is also a throw away file (to some extent) except that if you loose it or delete it you’ll have to “turn on” your VPC again (similar to turning on your hardware) and any open documents, etc you may have left in an “unsaved” state would now be lost.

Furthermore, let’s draw a distinction between the “saved running state” and the “hard drive state”.

The first, saved running state, means what programs are loaded into memory and what other operations your computer is “in the middle of” when you choose to suspend it (hibernate). You can save it all you want – BUT – I I’m not sure it’s very useful if the contents of the VHD change much. I suppose if the VHD has changed substantially (like for instance, if you’ve un-installed software) the VSV may not even be “valid” and may cause the VPC to crash. One note, you would literally have to make a copy of the VSV file somewhere other than where your VHD is stored because the minute you “resume” your VPC, this file would be used to recreate the environment and removed!

The second is the hard drive state (as represented by a VHD). This is the data and programs (including the registry) installed on the VM. You can definitely back up this file to “recover” a VPC in a completely different state (with a certain version of software, for instance). As a matter of fact, I have SEVERAL images of VHD files that are ALL the EXACT installation of Windows XP at various states: (1) Windows XP as originally delivered by MS, (2) Windows XP with SP1, (3) Windows XP with SP2. I also have a Windows XP SP2 versions with IE6 and another one with IE7. These are ALL copies of the original VHD file (in separate folders to keep things organized and less confusing) and to which I have used a running VPC to apply different updates and installations of software.

So, to backup a VPC so that one can "go back" to a clean state, you want to make copies of the VHD files, move them around into a folder structure that works for you and then fire away various VPCs as you need to in order to apply (or test) whatever you need to. I often use a “throw away” VHD to test suspect software or items that I’m unsure about.
One final note, just because you are running a Virtual PC does NOT exclude you from properly licensing software. Different software programs and operating systems have different restrictions on how you may use them and install them, including on virtual PCs. Please check with your software vendor to verify that you are complying with any and all licensing requirements.

0 comments