Manage Virtual Hard Disks (VHD)

by Jane / Thu Aug 09 2018

Table of Content

We already covered how to create vhd in Disk Management, we haven’t gone very deep in how to resize vhd disk partitions, extend or shrink them, we’ll do that in this page

Check VHD in Disk Management

Open Disk Management and check the disk map, if you can see the blue disk icon, then the VHD is listed, otherwise, click Active and Attach VHD

check vhd

Shrink a partition in VHD

  • In Disk Manager, right-click on the partition you’d like to shrink
  • Click Shrink Volume and specify the target size or use the recommended number
  • Click Shrink
shrink vhd partition

I create a 10M VHD, it becomes 9M after initialized and turns to 7M when creating a partition, so I can't shrink this volume, I'll make it to 1G in the extending volume example

BTW, creating 1G VHD takes me 1 min, 10 G takes about 5 mins

Extend a partition in VHD

Virtual disks are widely used on the Server side, mostly a VHD means a single user and an individual system, so it’s likely to get some partition running out of space, extend volume in Disk Management can be a helper, do the followings to enlarge a VHD partition:

  1. Check if there’s contiguous unallocated space to the drive you’d like to extend
  2. If it’s Yes, right-click on the target drive
  3. Click Extend Volume and follow the extend volume wizard
extend vhd partition

Or if it’s No, or there’s no such space, we can delete the adjacent partition and make that space available, so do this instead:

  1. Right-click on a partition we had to delete
  2. Click Delete Volume and click Yes to the warning message
  3. Click on the target drive and Extend Volume on it
delete vhd partition

Backup the about-to-delete partition first to other partition or other external storage media before we proceed to delete, and don’t forget to create this partition again when we have left enough unallocated space after extending the other drive

Partition Expert extend VHD drive

We don’t really have to delete any partition to extend another volume, we can simply resize the small volume without data loss, I mean, without formatting or deleting.

In Partition Expert we can perform operations below:

  1. Right-click on the large partition
  2. Click on Resize/Move Volume
  3. Drag the header handle to the right
  4. Click on the smaller partition
  5. Repeat step 2
  6. Drag the footer handle to the right
  7. Click OK and Commit
shrink partition in partition expert
extend partition in partition expert

If the large partition is not right next to the small partition, don’t worry, use the Resize/Move Volume function to move unallocated space ahead and next to the small partition

Let’s assume the small partition is C: Drive and the large partition is D: Drive, we can easily enlarge C Drive without data loss in D Drive

Partition Extender increase VHD volume size

The above-mentioned method is to create unallocated space first and then merge that space to the small partition, or C: Drive, i.e., easy to understand but a little bit troublesome, can we just make it simpler?

Sure thing, we can use Partition Extender instead.

In Partition Extender, steps are easy to follow:

  1. Directly click on the small-sized partition
  2. Click Next
  3. Drag the handle and click OK
extend partition in partition extender

Then you increased the small partition size and decrease the other partition at the same, one step for two operations

Detach VHD

Detach the VHD so that it doesn’t show in Disk Management and File Explorer

Detach won’t delete partitions and data in it

But we can still access the disk by directly navigating to the folder that contains this file, the .vhd format file, once you double-click the file, the VHD attaches itself automatically in Disk Management

detach VHD

Offline VHD

If you don’t want to any user to check the files on a detach VHD, you can make the disk offline

  1. Right-click on the VHD in Disk Management
  2. Click Offline
  3. Click Yes to confirm
offline VHD

Then when you try to access this .vhd file, you’ll get an error

Errors prompted when managing VHD

  • The disk image isn’t initialized
  • Can’t delete VHD

This disk image isn’t initialized

When you directly access this file (double-click) right after creating, you’ll get this error message

vhd warning

Steps to fix this issue, we’ll:

  1. Right-click on the disk or the red arrow in Disk Management
  2. In the pop up window choose MBR or GPT and click OK
new simple volume vhd
new simple volume vhd

Then the disk becomes unallocated space, right-click on it and choose New Simple Volume and follow the wizard to create a new partition, and finally, you can access the volume, it will auto pop up after it finishes formatting

new simple volume vhd

Next time you run Disk Management, it will auto pop up the initialize window if you forget the VHD disk after creating

Can’t delete VHD

When you try to delete the VHD and you don’t detach it from Disk Management, you’ll get this message

can't delete this volume

To fix this, we try to:

  1. Right-click on the disk
  2. Click Detach VHD
  3. Click OK
detach vhd

Now you can delete the .vhd file like the way deleting other files, press the Delete button and it will go to recycle bin, press Shift + Delete and it gone, can’t be restored from recycle bin

restore vhd

MicroSoft Guide on VHD

TOP