When you create a Microsoft Virtual Hard Drive either through Virtual PC or Virtual Server, you have to specify the maximum size of the file up front. While you can set the VHD to be a fixed or dynamically sized file, the total size the VHD is determined at the time you create it. Over time, however, you may want to increase the total size of the VHD file as requirements for the system change to allow more space for installed programs and data files.
Increasing the Size of the VHD File
With the help of the freely available VHD Resizer tool, you can expand the size of a VHD using it’s simple wizard interface. When opening VHD Resizer the wizard prompts you for the source VHD file to resize.
After selecting the source, set a destination VHD to a new file.
This new file will be an exact copy of the source, only a larger size.
Once selected, set the new size of the destination VHD file. This will be the capacity of the new VHD. Once set, start the resizing process.
Depending on the size of the source and destination file, this can take some time.
Repeat the process for any additional VHD files.
Resizing the Partition of the VHD Drive
After resizing the VHD file, the extra space is recognized by the respective Windows installation as an unallocated partition. In order to assign this extra space to the system drive, we have to link the new VHD file to an existing VHD file and resize it within the virtual machine.
In an existing VHD file, such as the source, link the new VHD file as a second hard disk. This is done through the the properties of the virtual machine.
Once you have the new VHD linked as a secondary drive, start the respective virtual machine.
When you look at the Disk Management, you can see the additional space is unallocated.
In order to resize the system drive on the new VHD file, you use the Windows tool, Diskpart.
Within Diskpart, set the disk (usually disk 1) and respective partition (usually there is only one) and then issue the ‘extend’ command.
After the extend command of Diskpart has run, the previously unallocated space has been combined with the system drive to form a single larger drive.
Once you have resized the new drive, shut down the virtual machine you used to resize the new drive and then remove the new VHD file as the secondary drive.
The new VHD file is ready to use as it’s own virtual machine, so create a new VM based on the newly created file.
Once created, boot up the new virtual machine.
The new VHD file will now have a single drive with the new space available to use as needed.
The ability to resize VHD files is tremendously useful. Since you can never predict what you may need in the future, you can build your VHD files with the size you know you need and then simply expand the size as needed.
Download VHD Resizer from VM Toolkit (requires registration)
- Published 07/26/10