I have one Xubuntu 12.10 64 bit Virtualbox VM on a Windows 7 64 bit host. It has one dynamic allocated hard disk with VDI format with maximum capacity of 20GB.

If I use a command df -h in the VM I get that 5.3GB are in use in th main partition. I have only 2 partitions, one for the ext4 hard disk and another with 512MB of swap. I have no snapshots.

The VDI file of this VM has 10.7GB. It is normal this difference of space? It is caused because the VDI format?

2 Answers 2


You may have used 10,7GB in the past on the VM. The Dynamic VDI file can grow when you use more disk but it won't skrink when you use less. It will grow up to the size you defined for the VM (20GB). I don't know of any way (not saying there is not one) to shrink it other than making a new file and copying everything to it...

  • maybe, but I do not remember using double space.
    – logoff
    Nov 7, 2012 at 16:36
  • When you delete something the space is free for the VM but the file is not shrinked. When you write something new after that, the VM not always uses this freed space so it grows the file and keeps growing until it reaches the limit you configured as maximum.
    – laurent
    Nov 7, 2012 at 16:40
  • you are right @laurent. this could be the reason, I have been using this VM during months.
    – logoff
    Nov 7, 2012 at 16:45

You can shrink a VDI image

Roughly the steps are:

  1. Boot to safe mode (recovery mode) where you can access your root partition (/dev/sda1).
  2. Mount the root partition as read-only (mount -o ro /dev/sda1 /mnt/tmp)
  3. zero out the unused space with dd or zerofree
  4. Shutdown the virtual machine and run “VBoxManage modifyhd –compact /path/to/virtualboximage.vdi”

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.