This may be the wrong topic since I'm working on Windows 7 with VirtualBox and my VM is an Ubuntu 17.

I'm trying to share a directory between my Windows and my Ubuntu.

This works fine with these steps :

  • In VirtualBox > Devices > Shared Folders : I add a share
    • Folder path : my directory on Windows (ie : C:\dev\windows-shared)
    • Folder name : vbox_shared
    • And I check "Auto-mount" and "Make Permanent"
  • Now, in a terminal in Ubuntu, I run :

    sudo mount -t vboxsf vbox_shared /home/osboxes/ubuntu-shared

And it works : I can add a file in Windows and see it in Ubuntu and vice versa.

The problem is if my "ubuntu-shared" directory already contains files : after the mount command, the directory is "empty" (and the directory is now under root:root).

If I umount, files in the directory are back (of course).

So : 1) is there a way to mount on an existing (not empty) directory without "losing" its content ? or 2) less ubuntu relative : is there a better way to share a folder on VirtualBox ?

Thanks !


As found in Error mounting VirtualBox shared folders in an Ubuntu guest, the correct command to run in the terminal should be:

sudo mount -t vboxsf -o uid=1000,gid=1000 vbox_shared /home/osboxes/ubuntu-shared

where the option -o makes sure that you will have access to the mount (that will otherwise be owned by root)."

  • 5
    If you've solved it, put it as an answer – pim Nov 14 '17 at 14:47

You are not losing the content, you are hiding it from your system view, mount will override the system view for the mount path. You are signaling the systen that that path is now served from the shared directory on your virtualbox host, ignoring whatever is placed below the mount point.

No, you can not merge a regular filesystem content from your system, with a a shared mount system. You should automount the shared filesystem, so that every write/read is performed always to the same location, both for your guest, and for your host.

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