Request correct sequence to bidirectionally share folders between Win10 Host & Ubuntu16.04 Guest
Posted: 26. Jul 2017, 06:10
This is a Linux Guest question for VirtualBox file and folder sharing between a Windows 10 host and a Ubuntu 16.04 guest.
I finally got bidirectional file sharing working, so, this is just a request to clarify the minimum steps required on both the Windows 10 host and the Ubuntu 16.04 guest in order to effect simple bidirectional file and folder sharing.
Since this is designed to benefit others so that they can just cut and paste the commands, actual folder names are used below (which the user may change before cutting and pasting, as desired). However, the steps below are intended to be guaranteed to work, which is the goal of a well-written tutorial.
STEP 1: Determine the names and location of the desired bidirectional folder sharing:
WINDOWS: C:\tmp\shared\vmsharew (which stands for vm share windows)
LINUX: /home/usr1/vmsharel/ (which stands for vm share linux)
STEP 2: Before you can enable folder sharing, insert & install the Guest CD image:
Look to see if you have the Guest Additions CD image:
C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso
GuestOS: Devices > Insert Guest Additions CD Image...
Allow it to "run" which will unpack and install Linux software.
STEP 3: Create the Windows host directory to be shared:
C:\> mkdir c:\tmp\shared\vmsharew\
STEP 4: Enable the file & folder sharing on the Ubuntu 16.04 Guest OS:
GuestVM: Devices > Shared Folders > Shared Folders Settings...
(Click the "Plus" sign to add a new shared folder setting.)
For a Unbutu guest OS, that opens a Windows Explorer on the host
Select the existing folder, e.g., C:\tmp\shared\vmsharew\
Folder Path: C:\tmp\shared\vmsharew
Folder Name: ubuntu1604x64 (name it whatever you want)
[_] Read-only
[x] Auto-mount (mounts the folder immediately, won't survive reboot)
Default mount point is: /media/sf_ShareName
Default permissions are: 770
Default owner is root & the default group is vboxsf
[x] Make permanent (makes the folder persistent, sticks upon reboot)
Note: Despite documentation to the contrary, using fstab to auto-mount VirtualBox shared folders during boot does not work in recent versions of Ubuntu as VirtualBox services start after the filesystem is mounted.
I think you have to reboot the Ubuntu 16.04 Guest OS for it to actually work but the instructions leave this up in the air.
STEP 5: Change the permissions and group for the user on the Ubuntu 16.04 Guest OS:
$ sudo ls -l /media
drwxrwx--- 1 root vboxsf 0 Jul 21 12:42 sf_ubuntu1604x64
Add the user to the vboxsf group (assume your username is "usr1")
$ sudo usermod -a -G vboxsf usr1
Well, that did nothing useful because you still get permission denied.
So let's try this instead.
$ sudo adduser usr1 vboxsf
Well, that just says you're already there, so, there's something else wrong.
$ id usr1
That shows you're a member of the group.
Maybe you have to reboot again to make VirtualBox accept these commands?
OK. So a Ubuntu Guest OS reboot solved that permission problem (why don't they just say so?).
STEP 6: Link to the desired location on the Ubuntu 16.04 Guest OS:
$ sudo ln -s /media/sf_ubuntu1604x64 /home/usr1/vmsharel
You still get permission denied so let's open it up (but why isn't this described in the documentation?)
$ sudo chown -R x vmsharel
Let's try to manually mount the shared folder:
$ sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) sf_ubuntu1604x64 sf_ubuntu1604x64
Reboot.
Well, whatever I did above, finally worked.
I can now bidirectionally access a file that is in the location:
WINDOWS: C:\tmp\shared\vmsharew
LINUX: /home/usr1/vmsharel/
In the end, this worked to share a file between Windows host and Ubuntu guest, but...
1. Can we simplify the sequence of events (and omit the trial and error?)
2. When do you have to reboot so that the command you ran actually do something?
3. Did I really have to set the permissions wide open just to get it to work?
4. Did I really have to change the ownership just to get it to work?
I finally got bidirectional file sharing working, so, this is just a request to clarify the minimum steps required on both the Windows 10 host and the Ubuntu 16.04 guest in order to effect simple bidirectional file and folder sharing.
Since this is designed to benefit others so that they can just cut and paste the commands, actual folder names are used below (which the user may change before cutting and pasting, as desired). However, the steps below are intended to be guaranteed to work, which is the goal of a well-written tutorial.
STEP 1: Determine the names and location of the desired bidirectional folder sharing:
WINDOWS: C:\tmp\shared\vmsharew (which stands for vm share windows)
LINUX: /home/usr1/vmsharel/ (which stands for vm share linux)
STEP 2: Before you can enable folder sharing, insert & install the Guest CD image:
Look to see if you have the Guest Additions CD image:
C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso
GuestOS: Devices > Insert Guest Additions CD Image...
Allow it to "run" which will unpack and install Linux software.
STEP 3: Create the Windows host directory to be shared:
C:\> mkdir c:\tmp\shared\vmsharew\
STEP 4: Enable the file & folder sharing on the Ubuntu 16.04 Guest OS:
GuestVM: Devices > Shared Folders > Shared Folders Settings...
(Click the "Plus" sign to add a new shared folder setting.)
For a Unbutu guest OS, that opens a Windows Explorer on the host
Select the existing folder, e.g., C:\tmp\shared\vmsharew\
Folder Path: C:\tmp\shared\vmsharew
Folder Name: ubuntu1604x64 (name it whatever you want)
[_] Read-only
[x] Auto-mount (mounts the folder immediately, won't survive reboot)
Default mount point is: /media/sf_ShareName
Default permissions are: 770
Default owner is root & the default group is vboxsf
[x] Make permanent (makes the folder persistent, sticks upon reboot)
Note: Despite documentation to the contrary, using fstab to auto-mount VirtualBox shared folders during boot does not work in recent versions of Ubuntu as VirtualBox services start after the filesystem is mounted.
I think you have to reboot the Ubuntu 16.04 Guest OS for it to actually work but the instructions leave this up in the air.
STEP 5: Change the permissions and group for the user on the Ubuntu 16.04 Guest OS:
$ sudo ls -l /media
drwxrwx--- 1 root vboxsf 0 Jul 21 12:42 sf_ubuntu1604x64
Add the user to the vboxsf group (assume your username is "usr1")
$ sudo usermod -a -G vboxsf usr1
Well, that did nothing useful because you still get permission denied.
So let's try this instead.
$ sudo adduser usr1 vboxsf
Well, that just says you're already there, so, there's something else wrong.
$ id usr1
That shows you're a member of the group.
Maybe you have to reboot again to make VirtualBox accept these commands?
OK. So a Ubuntu Guest OS reboot solved that permission problem (why don't they just say so?).
STEP 6: Link to the desired location on the Ubuntu 16.04 Guest OS:
$ sudo ln -s /media/sf_ubuntu1604x64 /home/usr1/vmsharel
You still get permission denied so let's open it up (but why isn't this described in the documentation?)
$ sudo chown -R x vmsharel
Let's try to manually mount the shared folder:
$ sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) sf_ubuntu1604x64 sf_ubuntu1604x64
Reboot.
Well, whatever I did above, finally worked.
I can now bidirectionally access a file that is in the location:
WINDOWS: C:\tmp\shared\vmsharew
LINUX: /home/usr1/vmsharel/
In the end, this worked to share a file between Windows host and Ubuntu guest, but...
1. Can we simplify the sequence of events (and omit the trial and error?)
2. When do you have to reboot so that the command you ran actually do something?
3. Did I really have to set the permissions wide open just to get it to work?
4. Did I really have to change the ownership just to get it to work?