When you delete data on thin-provisioned disks, the physical size of the VMDK file for the disk remain the same as before deleting the data, thin-provisioned disks grow in one direction, but doesn’t shrink automatically, and this is a big issue for vSphere admins., lets assume that you have a 5GB thin-provisioned disk with 2GB of data on it, then the actual size for the VMDK file will be 2GB, the VMDK file size will remain 2GB after deleting all of the data on it.
VMware has solved this issue in vSphere 6.5 with a new auto clean feature for think provisioned VMDK, but if you are using older versions of vSphere then the manual method is the only way to accomplish this.
This mechanism is available for both Windows and Linux guest operating systms.
This article is focusing on Windows OS.
- Download SDelete tools. (google it).
- run the tool inside the guest OS in CMD.
- run CMD as administrator.
- Navigate to the sdelete tool folder path.
- run the command against all of the partitions (or select the partitions you need to shrink): sdelete.exe -z x:
- power off the VM once the task is done.
- connect to the ESXi host using SSH.
- navigate to the VMDK file location onthe data store.
- list the vmdk files of the folder >> ls -lh *.vmdk
- run the following command: vmkfstools -K <VMDK file name>.vmdk (the “K” must be capital).
- Power on your VM again.
- you are done.