How to shrink a VMDK file
Virtual Disk Trim product page & download
A growable VMware disk gets larger as the virtual machine writes to it and stays that size when files are deleted in the guest. To get the space back on the host, the disk has to be compacted. This guide shows VMware’s own way of compacting in Workstation and Fusion, and a simpler way with Virtual Disk Trim.
Built-in way
VMware removes only the blocks of a disk that are filled with zeros, so there are two steps: zero the free space inside the running guest, then compact on the host.
In a Linux guest with VMware Tools, one command zeroes and shrinks:
In a Windows guest, zero the free space with SDelete from Sysinternals:
After zeroing a Windows guest, shut the VM down and use Compact in the hard disk settings (Clean Up Virtual Machine in Fusion), or:
When a disk image does not shrink
- The free space was not zeroed. Compacting alone releases almost nothing, because the space occupied by deleted files is still treated as data.
- The VM has snapshots. You need to delete the snapshots first.
- The VM is a linked clone. The linked clone has to be turned into a full clone first.
- The disk is preallocated. It always takes its full size; only a growable disk can shrink.
- The host is short of space. Zeroing makes the disk grow towards its full size before it can shrink.
Simpler way: Virtual Disk Trim
Virtual Disk Trim reads the guest file system from the image file itself and rebuilds the image without the unused blocks. The VM stays off, nothing needs to be zeroed, and VMware does not have to be installed.
- Shut the virtual machine down.
- Add the VMDK, or the folder with all your images. For a disk split into pieces, add the small descriptor file without a number. The Savings column shows how much space each image could give back.
- Press Trim. The image is trimmed, verified against the original, and only then replaces it.

Or from the command line:
Which to choose
The built-in VMware tool works and incurs no additional costs, but it needs the guest running, can take a long time, can cause extra SSD wear, and requires spare room on the host. Virtual Disk Trim is the better choice when:
- you cannot start the VM or prefer not to: an archive, a template, an appliance, a lost password;
- the host has no room for the disk to swell first;
- VMware is not installed where the image is located;
- you want the page, swap and hibernation files to be left out as well;
- you have many images, or VHD/VHDX, VDI and qcow2 files alongside the VMDK.
A split disk stays split and keeps its identity, so the VM starts as before. Delete snapshots first: a snapshot disk is declined, but the base disk under it is not recognised as a snapshot base, so it must be left alone. Flat disks of ESXi datastores are not trimmed either, as they are a different kind of VMDK.
Moving to another hypervisor? The vdtrim command line tool can trim and convert the image in one pass; the extension of the output image file determines its format:
Shrink, compact or compress?
VMware uses two terms for the same operation: Compact on the host and Shrink in VMware Tools. In both cases it means dropping the blocks the guest no longer uses. Compressing is different. It packs the data itself, as the disks inside an exported OVA are packed, and such a disk has to be unpacked again before a VM can run from it. Reducing the capacity the guest sees is a third thing: the partition has to be shrunk inside the guest first, and the disk then cloned to a smaller one.