Pages

Monday, April 26, 2010

Building Multiple VMs Easily in Microsoft Virtual PC

I've currently got a couple virtual machines that I use for development purposes.  Why? Because I don't care to clutter up my primary workspace with side-by-side installations of three different versions of Visual Studio, SQL Server, Office, etc...  I set up a VM with the specific software I need for development and testing purposes, and whenever I need that environment, I fire it up.  The benefits for me are a faster and less cluttered "primary" environment, with a completely segregated set of legacy environments.
Creating a Virtual Farm of VMs
Of course, setting up a variety of VMs with different sets of developer tools and services can take a lot of time - and a lot of disk space too.  Unless you make smart use of differencing disks, that is.  I found a great solution courtesy Andrew Connell - and if you have to spin up VMs every once in a while, it ought to work for you too.  There's a little more work up-front, but a lot less later.
Read his full article here: HOWTO: Use Virtual PC's Differencing Disks to your Advantage.
Of course - this is a reference for me, and I can find this post easier than finding his...
Part I: Make a "Base" VHD
  1. Start up a fresh VM, install an OS on it, and whatever "standard" apps/tools you'll want on ALL of your images of that OS.
  2. Defragment the VM filesystem inside the VM.
  3. Mount the Virtual Disk Precompactor ISO inside the VM to zero out the now-consolidated empty space.
  4. Shut down the VM and compact the VHD
  5. Delete the VMC/VMCX file for this VM, and mark the VHD read-only.
Part II: Build Your Real VM Using the "Base" VHD
  1. Create a new VM, but don't create a new disk, or use an existing disk - tell Virtual PC to create a differencing disk from your "base" VHD.
  2. Fire up the VM, make any changes you want!
Repeat from Part II, step 1 whenever you want another VM based on the OS/tools you happen to have in one of your "base" VHDs.
Thanks Andrew!

No comments:

Post a Comment