In addition to ESXi: shrinking a Windows disk, you can shrink any ESXi thin provisioned disk by first exploding it with zero content, then shrinking it like described by [WayBack] How to Shrink a Thin VMDK on ESXi 5.0 | Boerlowie’s Blog.
It comes down to using this command:
vmkfstools --punchzero myVirtualMachineDisk.vmdk
You can replace
--punchzero
with-K
if you like more cryptic arguments.
This works because thin provisioned vmdk disk files are sparse files where zero content can be non-allocated.
The trick requires all empty space to be zeroed out (which usually comes down using a tool like sdelete
on Windows or shred
on Linux), hence the “exploding” in the post title.
For a good explanation on thin, versus thick versus eagerlyZeroedThick, read [WayBack] Thin Provisioning – What’s the scoop? – VMware vSphere Blog.
A few remarks:
- this only works within datastores, so when you transfer your file out, then the file will be the thick size
- an OVF exported virtual machine will benefit from thin provisioned disks
- the
du
command will show the actual storage size (including the savings from think provisioned disks) - the
ls
command will show then “virtual” storage size (excluding any thin provisioning gains) - the difference between
ls
anddu
output is the thin provisioning gain
–jeroen