Saturday, April 6, 2013

VirtualBox: compact vdi file

In Guest OS
sudo dd if=/dev/zero of=/zero bs=1M 
sudo rm /zero
sudo shutdown now
Check to make sure there is free space. If no free space, then it will fail to reboot. In Host OS
$ cd
$ VBoxManage modifyhd /path/to/disk.vdi --compact
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
In case accidentally forgot to rm /zero and shutdown. Do the following steps to recover it. Boot in safe-mode (Press Left Shift key during boot) Then,
mount -o remount,rw /
sudo rm /zero
reboot
source

No comments:

Post a Comment