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:
- You’ll need two virtual computers, let’s call the one whose drive you want expanded A, and the second B
- Make sure virtual computers A and B are not running
- 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
- Set Hard Disk 2 to point to the .vhd file used by virtual computer A
- Save settings and fire up virtual computer B
- 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)
- 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)
- Shut down virtual computer B, and remove the added hard drive from its settings
- Now fire up virtual computer A
- 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.
Leave a Reply