The Usual Tech Ramblings

Microsoft Virtual PC, and Expanding Virtual Disks

I’ve always seem to have some bad luck with Microsoft products. I used to have a rather nice Dell Inspiron 9300, 17” screen, worked great, until I installed Visual Studio… Then whenever I’d open it, BSOD.


I lived with it for a bit, figured it was something I was doing wrong… Then I ended up rebuilding the laptop figuring it was corrupt files, or registry. Shortly after rebuilding the laptop, and reinstalling Visual Studio, the issue cropped back up again.

As I was going to be doing a lot of development work, I decided to upgrade. So with my new laptop in hand, I installed all my usual software, and guess what cropped back up again? Yup, that BSOD.

Over this past weekend, we had a major product release, and it didn’t go so smoothly, so I ended up digging in, and helping the dev team out a bit, and doing some debugging. Unfortunately, 4 BSODs in about an hour was a little too much to handle, so I jumped at another solution. Microsoft’s Virtual PC. What’s cool about this? It’s free. It’s missing some basic features, but otherwise it’s pretty handy.

The Problem

I installed Windows 2003 inside a Virtual PC, setting up a server with the standard drive specs we use for our production web servers, 12GB C:\, and 8GB D:\ . This was great, until it came to installing Visual Studio. It takes up 2GB on its own, and adding in the additional software we use, I was going to quickly run out of disk space. I figured it’d be relatively easy to expand disks, I’ve done it plenty of times using VMWare, so it should be easy with Virtual PC as well.

Unfortunately this is where I was having issues. The disk manager only provided the ability to compress disks, or convert a dynamic disk1 to a fixed disk. This isn’t good, I needed to expand the disks to a larger size (at least 20GB).

The Solution

After googling around a bit, I stumbled across a product called VHD Resizer. From the description on the website:

VhdResize will resize Microsoft’s VHD files and will also convert between Fixed and Dynamic file types. This is a sector by sector copy operation from one size/type to the other and the source file remains unaltered.

Basically, it copies the bits from one image to another, but updates the header information to report a larger size. After skimming through some of the notes on the page, it appeared a few people were having issues with it. Fortunately as this was a relatively clean image, I wasn’t too worried about losing the data, and I was planning on expanding the secondary disk, so if anything went wrong, the OS would still be okay. As I kept scrolling down, I stumbled on a little gem from Torolf Gulstuen with a quick walk through on how to update the disk, and how to use windows diskpart on updating the disk and expanding it to the new volume size.

Now I’ve expanding my 8GB disk to 20GB, and have most of it free, giving me plenty of space to do my development work within the safety of a virtual desktop, and not crashing my laptop every 2 minutes.

  1. A dynamic disk is a disk that has a set size, of say 8GB, but only uses physical disk space of the files on the actual system. So if you defined an 8GB dynamic disk, and only had a 3MB file on it, the physical disk image on your real system would be about 3MB