vhdx file - free space at the end. How to decrease the physical size

Hi,

A vhdx file was splited to tree logical disk in the past:
c: <-- approximately 80GB
d: <-- approximately 250GB
e: <-- approximately 250GB
and the total physical size is 537GB

Than the logical disk e: was deleted ("delete logical drive" in disk management).

How to decrease the physical size of the vhdx file ?

Is it possible ?


  • Edited by DimiterS Wednesday, July 22, 2015 8:00 PM
July 22nd, 2015 7:56pm

By creating a new VHDX and copying the contents to it.

If no data, no big deal.  If data, then you have a migration from one disk to the other.

http://itproctology.blogspot.com/2013/01/powershell-for-reducing-size-of-vhd.html

Free Windows Admin Tool Kit Click here and download it now
July 22nd, 2015 8:13pm

Thank you.

Just to clarify - it is a production server, and c: is system disk

July 22nd, 2015 8:23pm

I asume you mean partitions and not logical disks, right? If your VHDX is dynamically expanding the unused storage should be automatically reclaimed, with exceptions with some storage systems. For example, if you use an iSCSI disk to store your VHDX files it needs to support a certain UNMAP command/feature. If yor VHDX is fixed than you need to find other options, like Brian mentioned.
Free Windows Admin Tool Kit Click here and download it now
July 23rd, 2015 8:50am

Thank you,

Hyper-V Server is Win 2012 Standard (not R2). The physical disks are RAID1-arrays based on few SATA disks.
The VM is Win 2003 R2 Std. (And it is written "delete logical drive" in disk management.)

VHD-file Properties:
Format:                   VHDX
Type:                      Dynamically expanding virtual hard disk
Current Size:           512.85 GB
Maximum size:         599.99 GB

Currently I am focused on some auxiliary procedures, to find large free disk space on the Hyper-V server. And than it will be possible to use Brian method.


  • Edited by DimiterS Thursday, July 23, 2015 7:02 PM
July 23rd, 2015 6:43pm

Have you tried to compact the VHDX with Hyper-V Manager?
Free Windows Admin Tool Kit Click here and download it now
July 24th, 2015 5:51am

I tried "Edit/Compact" on VHD file, but the physical size remained the same (only 1MB lower).
I also tried to define a new VM without vhd, then I added a new vhd file and used "Copy the content of the specified virtual hard disk". And again the physical size was the same.

----------------------------

I solved the problem with disk2vhd

(https://technet.microsoft.com/en-us/library/ee656415.aspx?f=255&MSPPError=-2147217396).

I started disk2vhd inside VM and created a new vhd file on a network location.
BINGO !!!
The physical size of the new vhd was decreased from 537GB to 160GB.

Then I replaced the vhd in VM. (I renamed the files only)
Then there was an access problem of the new vhd and the VM didn't start.
I used this to fix this acces problem --> https://support.microsoft.com/en-us/kb/2249906
And BINGO again !!!
The VM with the new small vhd started the OS and was fully operational.

WARNING !!!
As I said, there was an access problem. Read the document first (https://support.microsoft.com/en-us/kb/2249906)
And also, do not use this info directly in case your VM is a domain member. Think twice before starting the VM with the new small vhd. It is possible to be forced to join the VM to the domain again and be sure, you have such rights.

----------------------------

I apologize for my poor English.

  • Edited by DimiterS 9 hours 12 minutes ago
July 24th, 2015 5:50pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics