I use Virtual PC extensively, and have lots of virtual machines that I fire up as needed to run specific software. (Charlie Arehart gets the credit for getting me hooked on virtual computers many years ago). Virtual computers use virtual hard drives, essentially a complete hard drive in a single file, a .vhd file. When a virtual hard drive is created you specify a maximum size, and the drive can either grow to that size as needed (dynamic drive) or start off as the specified size (fixed drive).
But what if you need to expand a drive beyond that initially designated size? There is a great little free utility named VHD Resizer, which, as its name suggests, resizes VHD (virtual hard drive) files. It can convert between dynamic and fixed sized virtual drives, and can change the drive size, too. Simple, right? Well, not quite.
Here’s the problem. Expanding the size of virtual drive is simple enough, but expanding the size will not automatically resize partitions on the drive. So, if for example you expanded a 4GB virtual drive to 8GB, your C: drive on the virtual drive will still be 4GB in size, and the extra space will be unassigned waiting for you to create a new drive (perhaps drive D:). Which is great, unless you really do need to expand drive C:, as I just did.
Windows includes a command line utility named diskpart which can extend partitions, but diskpart cannot be used for system or boot volumes, and so if you boot from drive C: (usually the case) you’ll not be able to extend it. There are 3rd party tools which can indeed manipulate partitions, including extending system partitions. But (at 36,000 feet somewhere over CO) I found a workaround.
WARNING: What follows is NOT recommended by Microsoft. It worked for me, but no promises. In other words, if you’re going to attempt this, make sure you’ve backed up your .vhd file. And if it doesn’t work, well, I don’t want to know! 😉
Ok, so here’s what I did:

  1. You’ll need two virtual computers, let’s call the one whose drive you want expanded A, and the second B
  2. Make sure virtual computers A and B are not running
  3. Open the settings for virtual computer B, you’ll likely see a virtual hard drive listed as Hard Disk 1, and Hard Disk 2 through 4 will be empty
  4. Set Hard Disk 2 to point to the .vhd file used by virtual computer A
  5. Save settings and fire up virtual computer B
  6. Once virtual computer B is running you’ll see its own virtual hard drive as drive C:, and virtual computer A’s hard drive as another letter (next available letter)
  7. On virtual computer B, open a command prompt and run diskpart, selecting the volume that is computer A’s virtual hard drive, and extend it (this will be allowed as diskpart won’t recognize it as a system partition as you didn’t actually boot virtual computer B from it)
  8. Shut down virtual computer B, and remove the added hard drive from its settings
  9. Now fire up virtual computer A
  10. With any luck you’ll now have an expanded system volume

This is NOT supposed to work safely. But, I just did it, and it worked perfectly. Great little workaround, but, caveat emptor.

5 thoughts

  1. Your post doesn’t say, but I guess you intended this to apply to Windows XP and Windows 2003. Since Vista and Win 2008 you’ve been able to do this to OS partitions as well, live. Just in case you didn’t check 😉

  2. Steve, I use Virtual PCs any time I need to install something new that I may not want to have on my machine all the time. Also, I have a virtual computer for every DBMS I need to occasionally work with, including 4 for each of Oracle 10, 11, and the express versions of each. It was while working on my Oracle 11 virtual machine that I ran into this issue.
    TomasF, you are correct. And yes, indeed, the virtual machines are running XP. I use those almost exclusively for virtual computers as they tend to be a bit lighter weight.

Leave a Reply