Solved - Mount on a not empty directory

by pwet84   Last Updated November 14, 2017 15:02 PM

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 !


EDIT - SOLVED :

As find here, 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)."



Answers 1


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.

João Pinto
João Pinto
November 14, 2017 14:29 PM

Related Questions


Ubuntu on VirtualBox no 'vboxsf' user?

Updated December 06, 2016 08:00 AM


Unable to write to folder after mounted as read/write

Updated October 13, 2017 09:02 AM