Skip to content

Instantly share code, notes, and snippets.

@dadatuputi
Last active March 14, 2018 16:38
Show Gist options
  • Save dadatuputi/95a05bfbf81a0582164c1fb53cf94d7b to your computer and use it in GitHub Desktop.
Save dadatuputi/95a05bfbf81a0582164c1fb53cf94d7b to your computer and use it in GitHub Desktop.
Shrink Linux VMDK

Shrinking Linux VMDK

Within Linux VM:

Remove unused dependencies

sudo apt autoremove

Clear apt cache

sudo apt clean

Defragment hard drive

sudo apt install e2fsprogs
sudo e4defrag <mount point (e.g., /dev/sda1) or directory (e.g., /)>

Fill empty space with zeros

cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill

On Windows Host

Use vmware-vdiskmanager.exe to shrink the vmdk

'C:\Program Files (x86)\VMware\VMware Workstation\vmware-vdiskmanager.exe' -k your-vmdk-file.vmdk

Sources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment