Shrinking a Dynamic VirtualBox Disk Image


You can shrink a dynamic VirtualBox disk image. This is incredibly helpful if you’ve uninstalled programs or freed up a bunch of space and you want the .vdi image size to reflect that. Otherwise, the dynamic disk image will stay the same size it was before. The process is simple, but can be a bit involved so I’ll just touch on the basics and then refer you to a few guides that were really helpful when I did this for my Ubuntu 9.10 VirtualBox image. These guides can be applied to other guest images as well.
1.) Install “zerofree” on your virtualbox guest machine.
2.) Boot to safe mode (recovery mode) where you can access your root partition (/dev/sda1).
3.) Mount the root partition as read-only (mount -o ro /dev/sda1 /mnt/tmp)
4.) Run “zerofree /dev/sda1″
5.) Shutdown the virtual machine and run “VBoxManage modifyhd –compact /path/to/virtualboximage.vdi”
In-Depth Guides: — Keep in mind that zerofree does in fact support ext4 (I think this article is a tiny bit dated, but it’s a great one). — The all important VirtualBox Users Guide. — Another good reference for VirtualBox

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *