VHDX file

I have a dynamically expanding virtual server. The VHDX file is 400gb but the actual space used on the machine is only 100gb.. i had cleaned up the server and removed 100's of gb worth of data. My question is how do i now get my VHDX file back down to a smaller size?

Srv 2016
Hyper V
Jack 50Asked:
Who is Participating?
Tom CieslikIT EngineerCommented:
You can convert file from dynamic to Fixed size

All you have to do is shot down VM
Go to Properties, select disk
Click Edit
Select Choose Action
Select Convert
Choose Disk Type and select Fixed Size

If you think that 200GB or less  is enough, click Next and put new information.
Hyper-V manager will convert disk for you

Cliff GaliherCommented:
There isn't a good way to do this. The way NTFS writes data means that there is almost always blocks of data at the end of the file.

There are third party Defrag tools that can move all data to the from of the "disk" and then you can use hyper-v disk tools to shrink the file.  But it has historically been high risk. I would never recommend this path. Leave the white space and let the virtual OS rewrite to it as needed.
Check this document:

First, you should check if the shrinking is available for your volume.
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Philip ElderTechnical Architect - HA/Compute/StorageCommented:
If there is enough free space on the host then create a new Dynamic VHDX file, attach it to the VM, _move_ everything over to the new VHDX file, remove the old VHDX, and change the new VHDX partition's drive letter to the old one. The shares and permissions should all be the same.

Make sure to back things up before, during, and one time just prior to removing the old VHDX. Once complete, delete the old VHDX. Done.
Muhammad BurhanManager I.T.Commented:
Login to your virtual machine and open Computer Management then go to Disk Management and shrink to the possible size then shutdown that VM and open HyperV manager go to edit disk and choose compact
Jack 50Author Commented:
Couldn't shrink, wouldn't let me
Determining if a VHDX is Eligible for Shrinking
Did you check this?
Jack, that's all you have for us, one sentence?
What steps did you follow? If Muhammad Burhan's were followed but did not work (which would surprise me), there's still the possibility to make an image copy of the drive and restore it to a new dynamically expanding VHDX. Only used sectors will be restored, so the result will be a small drive, if the imaging program allows that. You could take the trial of drive snapshot: http://www.drivesnapshot.de/en/down.htm - it allows restoring to a smaller disk.
PberSolutions ArchitectCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

-- Tom Cieslik (https:#a42417126)
-- 8046586 (https:#a42417127)
-- Muhammad Burhan (https:#a42417318)
-- McKnife (https:#a42418535)
-- Cliff Galiher (https:#a42417123)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

Experts-Exchange Cleanup Volunteer
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.