Shrink VMWare VMDK File

Shrink VMWare VMDK File

This goes over reducing the size of a VMDK file using open-vm-tools and is used often in VMWare environments.

Tools Needed

I’d recommend VMWare Workstation Pro, but you can get away with just using player if you don’t have a license.

Inside the Guest (Virtual Machine) you need to install open-vm-tools on Linux which should be in the base repository for most main distributions.

Shrinking VMDK

On Guest

These are done on the GUEST (Inside Virtual Machine)

vmware-toolbox-cmd disk shrink /

If you are want to shrink a Windows Guest you need to install VMWare-Tools inside the VM. After the tools are installed, simply click the following in VMWare Workstation VM Tab -> Manage -> Clean up Disks (Windows ONLY)

On Host

From inside your VMWare Workstation install you will find the following program vmware-vdiskmanager this is where we finalize the vmdk by defragmenting it and doing the final shrink.

Defrag

vmware-vdiskmanager.exe -d /path/to/shrink.vmdk

Final Shrink

vmware-vdiskmanager.exe -k /path/to/shrink.vmdk

Example

Still Too Big?

If it is still too large, you can simply export the VM to OVF format inside VMWare Workstation. This will create a new vmdk file that will be considerably smaller. OVF is pretty easy to move to VirtualBox and other VM platforms as well.

export to ovf