Shrink Oracle VirtualBox Image (and reduce size of Linux)

Note to self only. I just used it to shrink a WebLogic 12.1.2 image from 11 GB to 5GB. NIH, but lovin’ it!

0. If you have done an upgrade of your Linux clean up

e.g. in CentOS run

sudo yum clean all

this often frees several GB.

1. mark the empty space on the guest side (CentOS in my case, could be Oracle Enterprise Linux OEL …)

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

2. use VBoxManager on the host side to shrink the disk image

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe modifyhd --compact "c:\01_work\30 vms\virtbox\WLS12.1.2 STUDENT\WLS12.1.2 STUDENT.vdi"
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

Speak Your Mind

*