Tuesday, May 22, 2007

No more room in my VHD

Hold the phone. A reader just tried the procedure described in the UPDATE section below and found out that when you finally go to convert from the fixed back to a dynamically expanding disk, you never get prompted for a new disk size. If this is true, this handy workaround is pretty much worthless. Has anyone else attempted this that could confirm? Yes, I'm too lazy to do it myself.

The information in the original post is pretty much obsolete, or perhaps more accurately put, incompetent. Thanks to a recent anonymous comment, all I had to do was convert the VHD to a fixed disk and then back to dynamically expanding. Read on if you'd like to learn how to do it the hard way.

So, you may or may not know that I'm a huge fan and user of Virtual PC and Virtual Server. For over two years, I've been using virtualization exclusively for software development. Sure, there's a slight performance hit, but you can't beet the flexibility you gain from having one (or more) isolated development environments. Before using Virtual PC, it was common for me to be wiping my laptop once every 4 to 6 months. Now, since I don't run any development tool software on my host OS, it's rare that I have to rebuild my host machine. And, of course, creating new virtual PC's is a snap.

Virtual PC, Virtual Server, and VMWare all use the concept of virtual hard drives (or VHD's). These are nothing more than files on your physical host OS's drive that represent a virtual drive. They can be fixed in size (like a physical drive) or dynamically expand. The later option is handy in that such a VHD only takes up as much physical space as it needs, gradually growing over time. The benefit is it saves a lot on physical drive space, especially if you manage multiple virtual machines.

When you create a virtually expanding VHD you have to specify its maximum size; for Virtual PC the default max size is 16MB. The kicker is when you're using that VHD and all of the sudden one day you run out of room. It's the same experience you have when you run out of room with a physical drive - you immediately try to free up space by deleting unnecessary files and uninstalling unused apps.

However, I recently ran into a scenario where making more room wasn't enough. I was installing Visual Studio 2005 Service Pack 1, which requires a ton of free disk space (over 2GB I think) and I couldn't make it happen. Since you can't change the max size of an existing VHD, I only had two options:

  1. Rebuild my virtual machine with a larger VHD.
  2. Somehow transfer the contents of my existing VHD to a new empty VHD.
The second option was much more appealing since it would require minimal effort. I just needed a tool that could do it. Transferring or cloning a disk is more involved that simply copying files since you need to transfer boot record, partition, as well as other information.

Doing a little digging, I found there are several utilities out there. Norton Ghost is one. The one I chose was Acronis True Image Server (I installed the Server version since my OS was Windows Server 2003). Neither of these are free, so you have to either buy them or use their trial edition. The process I used was the following:

  1. Create a new empty dynamically expanding VHD (with a more desirable max size) and mount it to the virtual machine.
  2. Install Acronis True Image Server on the virtual machine.
  3. Start True Image and run the Clone Disk wizard.
  4. Unmount the old VHD.
  5. Mount the new VHD as drive 0.
I think there are free disk cloning utilities out there, but I'm not sure how trustworthy they are. Disk cloning isn't something you want to mess up.

Before you perform this operation, make sure you have plenty of room on the physical drive that contains the new VHD. Running out of physical drive space as the new VHD is getting filled (and expanded) can cause the clone to fail. Learned that one the hard way :).

Thursday, May 03, 2007

Back in the saddle

It's been over two weeks since I've biked (to work)!!! I've been slacking and am running out of excuses. Most of it has to do with over-busy-ness. Blah, blah, blah...

Tomorrow I AM biking in and the rest of the blogging world can hold me to it.

Looks like we're going to get some rain too. Perfect.