I have a Windows Server 2008 R2 with Hyper V installed.

One of the virtual machines is a 150GB dynamically expanding virtual hard disk (Windows). I would like to shrink this to 100GB, however I can't seem to achieve this.

What I have tried so far;

  • opened disk management on guest machine and shrunk the HDD by 50GB, this is now displaying as 'unallocated' in the guest.
  • ensured there are no snapshots of the guest OS
  • defragmented the guest machine
  • selected the guest machine in Hyper V and ran 'compact'

However whenever I inspect the disk in Hyper V it's still showing as 150GB, there's no change.

I have also tried the diskpart tool, using the following commands on the guest OS however same result;

select vdisk File=”I:\path\to\your.vhd”
attach vdisk readonly
compact vdisk
detach vdisk

Am I missing something?

Few questions;

I've read that it's not possible to shrink dynamically expanding virtual hard disks- is this true? If I simply delete the VM in Hyper V, where will the 150GB be reallocated to?

I'm unable to export the VM and create a new one as my host machine is very low on space.


According to this article;

The VHD virtual disk format doesn’t support shrinking..

I tried the exact same steps for a long time and never had any success. Best to recreate the virtual disk if possible, save some time.


You can shrink Dynamically expanding virtual hard disks. you've shrunk the volume in the guest already so from PowerShell try:

Resize-VHD –Path c:\BaseVHDX.vhdx –SizeBytes 1TB (1TB is just an example)


Resize-VHD –Path c:\BaseVHDX.vhdx –ToMinimumSize

if it is a .VHD then use .VHD instead of .VHDX

  • This Cmdlet should be part of the Hyper-v Powershell tools, are you running it on a hyper-V machine? Jul 3 '17 at 13:19
  • I have hyper-v installed on a win server 2008 R2 machine. I ran the command in powershell (v2) as administrator. Jul 3 '17 at 13:28
  • in that case id recommend installing the latest WMF version in order to upgrade PowerShell. you can find it here powershellgallery.com ill keep looking to see if there is an alternative to the Resize-VHD command for PowerShell V2 Jul 3 '17 at 13:53

The Resize-VHD cmdlet doesn't exist in 2008 R2's version of PowerShell, BUT there is a way. In Hyper-V Manager GUI, if you power down the VM which uses the VHD, you can then use the "Edit Disk..." Function available in the Actions panel on the right hand side to specify a larger size.

New contributor
user4560259 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.