I have Kubuntu as a host system and ubuntu as a guest system on Virtual Box. Virtual hard drive was created with flag "Dynamically allocated storage" so I assumed that size of the storage should grow with system requirements.

Now I'm checking on my virtual system:

$df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        11G  6.5G  3.7G  65% /

But virtual box indicates more than 93% : Virtual box - disk information

and that is real size of virtual disk on host system

$ls -s Ubuntu.vdi -h 
12G Ubuntu.vdi

Two questions:

  1. why?
  2. how to reduce actual size to 65%?



Thanks @JonasC, I was able to reduce it quite easily.

First you need R.I.P.-linux or any other rescue system with zerofree util. Boot this rescue system and run

zerofree -v /dev/sda1

Then stop virtual machine and run on host

vboxmanage modifyhd /path/to/thedisk.vdi --compact

Result is obvious:

$ls -sh Ubuntu.vdi 
12G Ubuntu.vdi

$ vboxmanage modifyhd Ubuntu.vdi  --compact

$ ls -sh Ubuntu.vdi 
8.2G Ubuntu.vdi
| improve this answer | |

The short answer is is that VDI system requires space. More on: https://forums.virtualbox.org/viewtopic.php?t=8046

Why would you want to reduce the the actual size? The actual size is not the "actual" size of the .vdi file, but the actual size of the virtual disk usable inside Virtual Machine. try opening the terminal and type: ls -R ~/VirtualBox VMs you'll see that the actual size is smaller. Or perhaps, you have hidden data.

| improve this answer | |
  • I don't think you are right Virtual Box indicates actual size of virtual disk on host system: ` ls -s Ubuntu.vdi -h 12G Ubuntu.vdi` – rth Jul 7 '16 at 3:30
  • If you're absolutelly sure, you could try making another smaller .vdi and attaching it to the VB system. Then you could do: sudo dd if=/dev/sda1 of=/dev/sdb1 after creating the filesystem – Cloacker Jul 7 '16 at 5:26
  • the drive dinamically allocated has a variable size, but perhaps you had more data and data don't delete merelly with rm and filesystem rezises – Cloacker Jul 7 '16 at 5:28
  • Well @Cloacker there is a golden rule in technical forums - suggest something that you are sure! dd will create 'byte copy' of disk byte-by-byte a whole volume. So new volume will have the same size as the old one. It is very bad Answer! – rth Jul 7 '16 at 11:13
  • ok, dd only copies equals. if the size is different he'll get an error on the end. I was assuming that he just resized the original partition to the size he wanted (lets say 6.6GB for example). Then the new .vdi would be 6.6GB. I thought It was too obvious. Sorry. – Cloacker Jul 7 '16 at 11:21

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.