How to retrieve unused space from Ubuntu VM using vmware player
Steps to retrieve unused space
-
Defragment (no need to un/remount anything). Ignore any errors. Some files like symlinks and device files can’t be defragmented.
sudo e4defrag / -
Zero-fill all unused space so VMware knows it’s indeed unused:
dd if=/dev/zero of=wipefile bs=1M; sync; rm wipefile -
Run the shrink operation:
sudo vmware-toolbox-cmd disk shrinkonly