Thursday, April 8, 2010

Shrinking a VirtualBox image

I followed the tutorial "How to Shrink Your VirtualBox VM" and found it's very useful to reduce the image size. Since I'm using the Oracle Enterprise Linux as the guest, I need to get the zerofree rpm package first.

1) Verify the current disk partition of the OEL guest (e.g. /dev/hda3)

2) Assign a OEL Boot into Linux rescue mode (e.g. using OEL or OVM) and mount the file system as read only.
# mount -n -o remount,ro -t ext3 /dev/hda3 /
# zerofree /dev/hda3
3) Shutdown the OEL VM.
# shutdown -h now
# poweroff

4) Shrink the VM (from the host OS)
# vboxmanage modifyhd EnterpriseLinux.vdi compact

For the guest VMs, such as Ubunutu 9.10 where ext4 file system is used, I can not get zerofree to work; but a good workaround is to CloneVDI tool.

No comments:

Post a Comment