Detailed instructions for reducing a dynamic VDI size can be found at http://forums.virtualbox.org/viewtopic.php?p=29272 (FAQ entry "How can I reduce the size of a dynamic VDI on disk?").
Reducing the size of a dynamic VDI is mainly a two stage process:
# zerofree -v /dev/sda1 # zerofree -v /dev/sda2 # zerofree -v /dev/sda3 ... ...
You will have to fill any non-Linux partitions, such as NTFS, with zeros as well (refer to the FAQ entry mentioned above).
# VBoxManage modifyhd /full/path/to/xxxx.vdi --compact
For your convenience, I have written a script which takes the absolute path to the VDI as an argument, mounts any Linux (ext2/ext3/ext4) partition it finds in the VDI, fills it with zeroes, and then finally compresses the VDI. I hope you find the script useful. Download the script, extract it (gunzip compact-vdi.sh_.gz && mv compact-vdi.sh_ compact-vdi.sh), and execute it (./compact-vdi.sh vdi-absolute-path).
Attachment | Size |
---|---|
compact-vdi.sh_.gz | 652 bytes |
Add new comment