Compacting VMware virtual hard disks

Jul 15, 2014 - 1 min read

Using the Compact command in VMware Workstation/Player is supposed to downsize the virtual disk (.vmdk) file to the actual size of data that’s on it. Usually this doesn’t happen; the operation take a long time, and file remains the same size.

Note: The virtual disk must not be pre-allocated for this to work. When creating a virtual disk, you are given the option to allocate the disk space - don’t do it.

How to compact the disk

  1. Turn off the virtual machine

  2. Defragment the disk (VM Settings → Select Drive → Utility → Defragment)

  3. Turn on the virtual machine

  4. Wipe the free space on the disk (this is the key step)

    In order to do this, you need to use a third party tool for your operating system:

    • Windows: CCleaner Free or similar. (Tools → Drive Wiper → Select Drive → Wipe)
    • Linux: secure-delete tool suite or similar.
  5. Turn off the virtual machine

  6. Compact the virtual disk (VM Settings → Select Drive → Utility → Compact)