My VDI file keeps growing and I don't understand why. VirtualBox support have confirmed this is an Ubuntu Guest OS issue, not a host VB one. (BTW, is this question best answered here, or should I be asking at https://superuser.com ?)
I am running latest VirtualBox (5.1.18) under Windows 7 (Home Premium) 64-bit as Host. Ubuntu 16.04 (latest patches) 64-bit as Guest. VDI file is using dynamically allocate storage up to 100G.
When I used to run Ubuntu 14.04 all seemed reasonable. Recently I have been finding the VDI image keeps growing in size. It has grown from 7G to 14G. (This may not be much to some of you, but with an 8G memory stick for backup it's a problem for me!) I can boot Ubuntu to Unity desktop and then immediately exit, and the image can grow by 0.5G.
In Ubuntu the output from df -h
shows:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 97G 7.7G 84G 9% /
So that is saying there is an extra 6G beyond Used which has been "lost" compared to Avail. du -h -x -s /
confirms 7.6G used.
- What & where is the extra missing storage?
- Are there known problems here between VirtualBox and Ubuntu 16.04 (14.04 did not seem to have this problem)? I am seeing some posts on the net stating that 16.04 is using excessive desktop memory, though nothing amounting to 6G....
In my knowledge, when you or any program writes something to the disk, after removing that file only the related inode to that file will be removed and data (zero and ones) remains on the disk, so while you are using dynamic allocated storage, the VirtualBox has no idea what files are living in your OS, it's just know for example 10G of data has been written to your disk, so it growth your hard disk size to manage that 10G of data.
What you can do?
zero out the free space of hard disk in guest, in Linux distributions you can use
dd
utility to do that:then use
VBoxManage
command with--compact
switch to make your VDI files compact.More infromation about compacting: here
Reserved blocks
And about the size you mentioned, I guess that would be the reserved blocks for ext4 file system. for my home partition which is
sda2
.And because my block size is 4096 byte, so 1408704x4096 makes 5770051584 bye which equals to 5.77 GB reserved space on my home patition.
Had the same problem Ubuntu 16.04 on Win7 VirtulBox 5.2.0:
The following steps solved it (thanks to Ravexina's answer above and this:
Guest Ubuntu:
Host Win7 in cmd (change dir to location of .vdi):
Restarted guest Ubuntu: