We seem to have a number of NTFS drives like this where they consume much more space on the virtual disk than they do as files.

Noticed the problem when Windows Server Backup was taking-up much more space than the files themselves.

As am example, we have a small drive with mainly office documents:

  • Size of actual files: 2.78Gb
  • Disk properties used: 6.03Gb
  • Size of compressed .vhdx: 27Gb

It is not the recycle bin, I have deleted that. It is not shadow copied, I have deleted them.

There doesn't seem to be any way of defraging these virtual drives on Server 2012 so nothing we can do there either.

Any other suggestions what is taking up this much space?

  • try: Resize-VHD –Path c:\myvhd.vhdx –ToMinimumSize
    – Jim B
    Mar 31, 2016 at 11:10
  • Are these VHDX files that are simply attached for storage, or are they VMs?
    – Drifter104
    Mar 31, 2016 at 11:14
  • Purely data storage
    – NickC
    Mar 31, 2016 at 15:34
  • > try: Resize-VHD –Path c:\myvhd.vhdx –ToMinimumSize Failed to resize the virtual disk, the virtual disks size cannort be reduced further
    – NickC
    Mar 31, 2016 at 15:39

2 Answers 2


Deleting data inside of the VM doesn't cause the size of the VHDX to decrease. Once the VHDX grows it will remain that size, or grow larger as the amount of data inside the VM increases.

If you want to recover some of the disk space on the host that is being consumed by the VHDX you can compact the VHDX.

Additionally, you could shrink the Windows volume inside the VM and then shrink the VHDX.

  • Can't shrink the volume, it is currently 76,670Mb and will not shrink any further. Interestingly running defrag from the command line shows: volume size: 74.87Gb Free space: 68.82Gb Largest free space size: 53.86Gb
    – NickC
    Mar 31, 2016 at 15:44
  • How can I compact the VHDX?
    – alper
    Dec 20, 2021 at 9:31

To add to joeqwerty's answer, as he's right as the virtual hard disk size will not decrease automaticly when you delete some files from inside the partition.

To compact you could do it with the Hypervisor's menu.

In ESX: Virtual Machine > Virtual Machine Settings->Hardware->Utilities > Compact

In HyperV: Inside the VM in the tool menu for the HHD click Optimise. After that close the VM, in the Hypervisor itself or another Windows VM right click the VHDX, click Mount and click Optimize.

A old method was to mount the VHDX via diskpart, but I do not suggest it now.

To explain the size;

The tool usually fill the HDD partition table where files was before and no longer exist to fill it with zero. The optimize we run after hard delete those 'zero'ed' reference from inside the VHDX. As in the past, pre-2012, we had to run sdelete -z to zero out empty space from inside the VM which was filling to 100% to .VHDX, and after we compacted the VHDX when the VM was close. Now the process is easier.

  • 1
    +1 for Virtual Machine > Virtual Machine Settings->Hardware->Utilities > Compact
    – alper
    Dec 20, 2021 at 9:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .