Virtualbox, mounting guest directory on host computer

distributed-filesystemfilesystemsvirtual machinevirtualbox

Is there a way to mount a directory residing on my VB guest (linux) on my host (linux)? I know I can do it the other way around with the shared folders feature on Virtualbox, but is there a way to do it this way?

I'd really like to actually mount the directory. Not use samba, or something similar to that.

Best Answer

The short answer is that you can't.

When you mount a directory from the host inside the guest, here's what happens. VirtualBox comes with a filesystem driver for the guest OS that stores files by going through a special VM interface rather than directly accessing a storage device. The VirtualBox process on the host interprets the requests that come through the interface by making garden-variety user-level filesystem accesses.

Now consider the symmetric situation. You want to access files on the guest. Ok, then VirtualBox should come with a driver for the guest that handles filesystem queries coming through a VM interface. There would have to be a kernel component (because a VM interface looks like hardware to the guest OS) and optionally a user-land component to actually access the files (not necessarily, this is similar to an server NFS which can be done in the kernel or in userland (an NFS server's front end goes through the network, so that bit is doable in userland)). Then, on the host side, you would need a filesystem driver that communicates through the VM interface. Filesystems are normally handled by the kernel, but they can be mediated to a user process (that's what FUSE does). So a special-purpose filesystem would be possible, but more involved than in the symmetric case. There's also a lot less demand for it. As far as I know, there's no such special-purpose filesystem for any of the major VM implementations.

I'm afraid you'll have to use a networked filesystem such as NFS, Samba or SSHFS.

Related Question