If you’ve used a Windows virtual machine under VMware (Workstation or Fusion, depending on your host OS), then you’d have probably noticed that the host virtualisation software cleans up the virtual machine disk once the virtual machine is shutdown. The clean up activity detects any unused space and reduces the sizes of the virtual machine disk within the host OS without affecting the guest OS.

I have a number of Linux VMs but noticed that there was an increasing discrepency between the size of the used space form within the guest OS (via df -h) and the space consumed by the virtual machine disk. The reason? VMware doesn’t automatically run the clean up task once a virtual machine is shut down.

If you’re running a Linux virtual machine machine, the fix is straight forward: install open-vm-tools within your guest OS via apt or yum — whichever is your applicable to your Linux distribution — and then open the Terminal and run:

vmware-toolbox-cmd disk shrink /

You’ll see the virtual machine begin a clean up operation which is then handled by the host OS. The size of the virtual machine disk should now be of a similar size to that reported by the guest OS.

Thanks to Jake Jarvis for writing the original article from which this is based.

Note: If a virtual machine (either Windows or Linux) uses snapshots, then VMware is unable to shrink the disk. VMware recommends that snapshots are deleted (see VMware support)

Next Post Previous Post