Monday, March 29, 2021

How to retrieve disk space consumption in Windows virtual machine

If your virtual machine is running windows, and disk type is "Thin Provision", this type of vm disk only take up the disk space which it is actually using.

But after long time, the space consumption is growing bigger and bigger. It can be much bigger than it actually suing in the system.

The reason causing this problem is because the "Thin Provision" can only grow and never shrink in NTFS file system, the space can't be reuse even the file been deleted after using.

So, this is the soluation about how to retrieve the disk space consumption and help you save the space,  only for the windows vm which is NTFS file system.

1, download the tool from official vmware site which is called SDelete.exe.

2, run it in cmd of your windows vm with the parameter "-z" (need very long time if the disk space is big)

Eg: sdelete.exe -z c:

3, ssh to your esxi and go to vmdk folder which you want to modify.

4, Run "vmkfstools -K VirtualMachine.vmdk", after a while is done.


Below is the result of my vCenter Server.vmdk file which is 96GB at the begging, after the procedure it become to 38GB, and it is the same size in the windows vm.


This is only for windows vm which is NTFS file system. Not for linux and mac.

No comments: