Vbox Shared Folder Consuming Guest Storage Space

Posted on

Problem :

In Munin, I am getting a critical warning that my virtuabox shared folder for my headless Debian 11 server is consuming 90% of the guest’s disk space.

Via virtualbox, I unmounted the shared folder, which, in reality, held less than 600KB of text files. This solved the immediate problem and removed the warning.

However, might someone be able to tell me how to prevent this from occurring?

Each time I re-mount the shared folder, the guest’s disk usage shoots up.

Thanks

Solution :

Just because you see these numbers on the guest, doesn’t actually mean the mounts are actually consuming space on the guest. VirtualBox shared mounts behave a lot like network filesystems – when you run df on them to check disk usage, you’re really seeing disk usage of the host system where the folder was mounted from.

If your host system’s disk is 98% full, then clients accessing it via SMB or NFS mounts will see the connected share as 98% full – and very similarly, VMs accessing it via VirtualBox will see the VBoxSF shared folder as being 98% full.

(The existing files you see at /media/sf_VBShared are being read from the host; any new files that you put in /media/sf_VBShared would be created on the host; so naturally the “disk usage” of /media/sf_VBShared also represents the space available on the host.)

So the only problem here is that your usage monitoring system is monitoring things that it shouldn’t. I assume it already knows about ignoring NFS and SMB mounts, though, so there should be a place where you can configure what filesystem types it should be ignoring – just add vboxsf to the list and the shared folder should disappear from the graphs.

(Arguably it should not monitor “tmpfs” mounts at /run or /dev/shm, either, as those aren’t actually disk usage but rather RAM usage. It’s still useful to monitor tmpfs sizes in general, but I’d make a separate mini-graph for it.)