I'd been told by a number of IT related people that expanding a Windows 2003 VHD (virtual hard drive) was a complicated process - so I decided to develop a concise set of instructions for others to follow.

Here's the scenario:

We had an older machine the was running a critical application on our network. We needed to retire the hardware and keep the application running. It ran under Windows Server 2003. So - we P2V'd the machine (a utility that creates a virtual computer out of a physical computer) and got that virtual machine up and running.

However - in that process - the original drive sizes were used when the process created the virtual hard drives. The "C" drive on that physical computer was tiny - and close to full (12GB "C" Drive). I was told by folks that "knew more" about HyperV (Microsoft's Virtual Computer solution) - that while I could make the VHD larger - getting Windows 2003 to expand the partition on that drive would not work. I was told I would have to purchase third party applications to expand the partition - and those applications can sometimes "break" VHDs.

Google is my friend! After a few Google searches (literally 3) - I had found several pages/sites that looked like they contained all the info I needed to accomplish this task - NATIVELY. No additional software. So I began piecing together the process - and this is what I came up with:

This is a 2 phase process.

First Phase - Expand the VHD's set size in HyperV

This is accomplished in the following manner:

  1. Login to Host machine (in this case running Win2008 R2 and HyperV Manager)
  2. Launch HyperV Manager
  3. Stop the Guest machine (Win2K3)
  4. Look in the Settings of the Guest machine for the boot drive (normally drive C)
  5. Highlight it in the list and click "Edit"
  6. Choose the option for "Expand" and click "Next"
  7. Set the new size for the drive and click "Next"
  8. Review the changes and click "Finish"

Pretty stright forward thus far.

The Second Phase is a bit more involved - which is expanding the actual partition (volume) contained on the VHD. I pieced together the following process for doing this:

  1. Login to Host machine (Win2k8R2 - HyperV Manager)
  2. Launch HyperV Manager
  3. Stop the guest machine (Win2K3)
  4. Look in Settings of Guest machine to find where VHD file for boot drive (normally Drive C) is stored
  5. Open Windows Explorer - Go to the folder that houses the VHD - make a COPY of the VHD
  6. Open a command prompt
  7. CD to the directory that houses the copy of your VHD
  8. Run DISKPART
  9. Select the VHD file by issuing the command: "select vhd file={full path to copy of the VHD}"
  10. Then attach the VHD with "attach vdisk"
  11. NOTE: If you look in the Disk Manager application - you will now see the drive listed as online and accessible via Windows - in case you wish to move additional files to it
  12. Next - type "list volume" to display a list of volumes
  13. find you VHD in the list
  14. Select the volume by using "select volume X" where X is the number or drive letter of the volume you wish to expand
  15. Type "extend" to make the volume expand to use all available space in the VHD
  16. Now - select the vhd again (same command as in step 9)
  17. and finally detach the vdisk by using the command "detach vdisk"
  18. Go back into HyperV Manager and go into the properties for the guest machine
  19. repoint the Boot drive to the copy of the VHD that you just expanded
  20. apply the change
  21. Start the guest machine
  22. Connect to the guest machine and login to it
  23. Most likely Windows will need to reboot after if detects the "new hardware" (because the VHD will be seen as a new hard drive)
  24. After the reboot - log back into the guest machine and insure all applications function as they should.