Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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...

share|improve this answer
    
maybe, but I do not remember using double space. –  logoff Nov 7 '12 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 '12 at 16:40
    
you are right @laurent. this could be the reason, I have been using this VM during months. –  logoff Nov 7 '12 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”
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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