Shrink a vmdk Virtualbox disk image

I found a solution:

First inside the VM fill all free space with zeros:

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

In your Host, install vmware-vdiskmanager from the VMware Knowledge Base:

cd /tmp/
wget http://kb.vmware.com/selfservice/viewAttachment.do?attachID=1023856-vdiskmanager-linux.7.0.1.zip&documentID=1023856
unp 1023856-vdiskmanager-linux-7.0.1.zip
mv 1023856-vmware-vdiskmanager-linux.7.0.1 /usr/bin/vmware-vdiskmanager
chmod +x /usr/bin/vmware-vdiskmanager

Take care, that you have enough free disk-space before you start, you need the MV grows to double size during the process.

Then compress it with:

/usr/bin/vmware-vdiskmanager -k ~/VirtualBox\ VMs/<virtual disk.vmdk>

Source

Leave a Comment

tech