How To: Expand a Virtual PC Disk with VhdResizer and DiskPart

By | May 9, 2009

Question: What does “Dynamically expanding virtual hard disk” mean to you?

For some reason, while setting up a development machine in Virtual PC, I had this thought that “dynamically expanding” meant that the disk would start out at a specified size, and expand as needed. However, it’s the opposite. A “dynamically expanding” disk starts off small, and expands to the specified size. So needless to say, 10Gbs wasn’t enough to install Visual Studio 2008 (90 day trial), SQL Express 2005 and 2008, plus the service packs and Windows’ Updates.

After doing a bit of sleuthing (“Googling“), I discovered how wrong I was, but also discovered a tool called VHD Resizer.

What VHD Resizer does in a nutshell, is it creates a new VHD of the size that you want, and then copies your existing partition into it. However, because it copies the partition itself, and not the files, you’ll have a partition in the new drive that’s exactly the same as the previous one. But, if you look in your Disk Management in the Administrative tools of the Control Panel, you will also see some unpartitioned space.

In some of the forums that I read, the users mentioned getting a 3rd party partitioning tool, such as Partition Magic to resize your partition. There is an easier and cheaper way though.

Windows comes with a tool called DiskPart, which can be ran from the command line, and one of it’s many abilities is to expand a partition.

Step 1: Get VHD Resizer

VHD Resizer is a free tool, which can be found at http://vmtoolkit.com/files/folders/converters/entry87.aspx. Unfortunately, for reasons that make no sense to me, you must register first before you can download. After you download and extract the setup, install and then run it.

Step 2: Resize the VHD

Once you have Resizer running, select the source VHD to resize and the destination. Next, specify the size to resize to, which will be larger than the current size.

Step 3: Run and Wait

It will take a while to create the new VHD, so go do something productive, or take a quick nap.

Step 4: Attach the Drive to your VPC

For some people, the drive that they are expanding will be a second drive in their VPC. For others like myself, the main C drive will the one to expand. DiskPart will not allow you to resize the drive that you used to boot up with. So for either way, you must attach the new drive as a second drive in VPC.

What I did, was use the original source drive as my main boot up drive, and attached the destination drive as my second drive.

Step 5: Using DiskPart

Once you get your VPC up and running, load up the Command Prompt and type in “diskpart”.

If you get an error that says something like “The disk management services could not complete the operation”, wait a few seconds and try again.

Once you get DISKPART>, type in “list volume“, which will list off all of the volumes on your VPC.

Next figure out which is the volume that you want to resize. Since my VPC has a C drive and two DVD drives, the one that I wanted was the F drive, or Volume 3.

Now type in “select volume #“. In my case I typed in “select volume 3“.

If it comes back and tells you that “Volume # is the selected volume“, then type in “extend“.

After it tells you that it successfully extended the volume, type in “list volume” once again. You should now (hopefully) notice that the selected volume is larger.

And there you have it. If you were expanding your boot drive, you will have to shut down and attach the new resized drive as your main drive.

Technorati : ,
Del.icio.us : ,
Zooomr : ,
Flickr : ,

12 thoughts on “How To: Expand a Virtual PC Disk with VhdResizer and DiskPart

  1. Jerry Kurtz

    My boot volume needed resized, but after following these steps several times, I get “A disk read error occurred” when trying to boot from the new volume.

    Bummer.

  2. Daniel

    Thanks! I was wondering where my additional GB had gone and you saved my day :-)

  3. Daniel

    Perhaps we should mention that – at least in Win Server 2003 – you have to assign a drive letter to the attached drive before you can extend it.

  4. Juan

    I’ve got the “The disk management services could not complete the operation”, wait a lot of seconds, and it persists

  5. Mark

    I had a problem extending the partition. Said it wasn’t allowed. Turned out that my virtual originally has 2 disk with the windows page file on the 2nd disk. When I added the new resized disk as the 3rd one, it took over the drive letter of the original 2nd and the 2nd got a new drive letter. The page file was created on my new resized drive so I couldn’t extend. I moved the page file and tried the process again and it all worked perfectly. How this helps someone.

  6. Nelson

    Thank you for posting the tip. I was able to create a new virtual PC with the enlarged vhd file as the only disk. Once the Windows 7 booted up, I was able to expand it to take all the empty space using the Windows 7 graphical disk management tool. I believe that tool was introduced in Vista.

  7. Andrew

    I had to go into Disk Management and turn my duplicated drive to online. It was initially offline due to a signature conflict with another drive (the original). Once done I was able to extend the disk. I was not able to substitute the newly extended disk for the old one however, as Windows refused to boot with the new disk alone. I’m sure bringing the new disk online in Disk Manager gave it a new signature so it was not able to be recognized as the old disk anymore. Any ideas on how to get an extended disk to come online without changing its signature?

  8. James

    Does anyone actually have the tool vhdresizer downloaded because it looks like the page does not exist anymore. thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *