How To Expand VHD Disk Size in Hyper-V?

VHD (Virtual Hard Disk) files can either have a fixed size or be dynamically expanding. The size of a VHD file can be specified at the time of creation, whether it’s for a virtual PC or a virtual server. In both cases, you can define how much storage the VHD will initially allocate. Furthermore, the size of a VHD file can be increased even after it has been created, making it a flexible solution for managing virtual storage.

If you want to expand the VHD disk size, this article will guide you through the process. By increasing the size of the VHD, you can store more data and applications on your virtual disk, ensuring that your virtual environment remains scalable and efficient.

You can resize the storage of a VHD file using the methods outlined below, whether you’re using it on a virtual machine or a server environment like Hyper-V. These techniques will help you maximize the available storage without disrupting your existing setup.

Expanding VHD Disk File Using DiskPart Command Prompt

There could be a situation when you realize that the size of the VHD file is not enough or more than the storage needed as it is specified. The solution for this could be the dynamic VHD file but you set a limitation as maximum size at the time of the VHD creation. So, to remove this issue you can use the diskpart command.

Open DiskPart

Step 1. Press Win+R and open Run tab.

Step 2. Type diskpart and enter.

Step 3.  UAC will ask you for permission. Hit the Yes button.

Select the VHD File

Step 4. Select the virtual disk using the following command:

select vdisk file="C:\path\to\vdisk.vhd"

Expand the VHD File

Step 5. Now, expand the virtual hard disk using the following command:

expand vdisk maximum=15000

These commands will help you to expand the VHD disk. But, the problem is the partition will remain the same.

Resizing the Partition Inside the VHD

After expanding the VHD, the extra space is not automatically allocated to the existing partition. You must extend the partition to utilize the additional storage.

Steps to Resize the Partition:

Step 1. Attach the VHD File

select vdisk file="C:\path\to\vdisk.vhd"
attach vdisk

Step 2. List and Select the Volume

list volume

This will display all available volumes. Note the number of the volume you want to extend.

Step 3. Select the volume by running:

select volume=<No of volume>

At the place “No of volume”, enter the number of the volume (After watching the output of the “list volume” command).

Step 4. Extend the Partition

extend size=200

This increases the partition size by 200 MB. Adjust the size value based on your requirements.

Step 5. Detach the VHD File

Once done, detach the VHD to apply the changes:

detach vdisk

If still, you are not able to resize your virtual hard drive then there could be several reasons for corruption in your VHD file. You can remove the corruption using the VHD Repair Utility and then you can easily resize the virtual hard drive.

Sum-Up

The above-mentioned method makes it easy to expand the VHD disk and make it suitable for your needs. You can easily install more applications, store more files or can shrink the file size to make it compact. I hope, it helped you out.

If you want to shrink the VHD disk size then read here: How to compact or shrink Hyper-V VHD disk

Leave a Reply

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