Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Compact dynamically expanding VirtualBox CentOS image
1. Delete unnecessary files from image
2. sudo yum install zerofree
3. reboot, edit kernel parameters, add 'rescue single ro'
4. remount root read-only:
sudo mount -r -o remount /dev/mapper/vg_centos6generic-lv_root
5. null the free space (-v = verbose, -n = dry run):
sudo zerofree -v /dev/mapper/vg_centos6generic-lv_root
6. turn off VM
7 from host OS:
vboxmanage modifyhd --compact MachineDisk.vdi
Was able to shrink 50GB image to 36GB with only 366MB free space on the host machine.
@xabolcs

This comment has been minimized.

Copy link

@xabolcs xabolcs commented Aug 25, 2016

👍

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