What is the correct way to share directories with Ubuntu running in a Virtual Box VM with correct...












22














In VirtualBox, what is the best way to share a directory between an OS X host and Ubuntu
guest?




  • Host: Mac OS X 10.7.3

  • Guest: Ubuntu 12.04

  • Guest has a shared directory mounted via VirtualBox settings with
    Access=Full and Auto-Mount=Yes.


The problem with this setup is illustrated below. In my shared directory, I
can't change the permissions at all (not a permissions denied error, but they
just don't take effect).



Ubuntu 12.04 (guest):



% ls -l
total 0
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 1
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 10
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 2
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 3
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 4
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 5
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 6
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 7
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 8
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 9


Mac OS X 10.7.3 (host):



$ ls -l
total 0
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 1
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 10
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 2
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 3
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 4
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 5
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 6
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 7
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 8
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 9


If I chmod on the guest, nothing changes:



% chmod +x 1 | ls -l 1 # guest
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 1


If I chmod on the host, it changes on the host but not on the guest:



$ chmod +x 1 | ls -l 1 # host
-rwxrwx--x 1 <my-mac-user> staff 0 Apr 17 21:56 1

% ls -l 1 # guest
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 1









share|improve this question
























  • Ah, I figured it out, but I can't post the answer for another 8 hours (not enough points). The solution is to do sudo mount.vboxsf -o umask=002,gid=1000,uid=1000 src /media/sf_src, where the umask is the value of umask of the user, uid and gid are from id <user>, src is the name of the VBox share, and /meida/sf_src is the desired mount point.
    – jmdeldin
    Apr 18 '12 at 4:56
















22














In VirtualBox, what is the best way to share a directory between an OS X host and Ubuntu
guest?




  • Host: Mac OS X 10.7.3

  • Guest: Ubuntu 12.04

  • Guest has a shared directory mounted via VirtualBox settings with
    Access=Full and Auto-Mount=Yes.


The problem with this setup is illustrated below. In my shared directory, I
can't change the permissions at all (not a permissions denied error, but they
just don't take effect).



Ubuntu 12.04 (guest):



% ls -l
total 0
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 1
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 10
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 2
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 3
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 4
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 5
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 6
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 7
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 8
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 9


Mac OS X 10.7.3 (host):



$ ls -l
total 0
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 1
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 10
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 2
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 3
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 4
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 5
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 6
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 7
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 8
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 9


If I chmod on the guest, nothing changes:



% chmod +x 1 | ls -l 1 # guest
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 1


If I chmod on the host, it changes on the host but not on the guest:



$ chmod +x 1 | ls -l 1 # host
-rwxrwx--x 1 <my-mac-user> staff 0 Apr 17 21:56 1

% ls -l 1 # guest
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 1









share|improve this question
























  • Ah, I figured it out, but I can't post the answer for another 8 hours (not enough points). The solution is to do sudo mount.vboxsf -o umask=002,gid=1000,uid=1000 src /media/sf_src, where the umask is the value of umask of the user, uid and gid are from id <user>, src is the name of the VBox share, and /meida/sf_src is the desired mount point.
    – jmdeldin
    Apr 18 '12 at 4:56














22












22








22


12





In VirtualBox, what is the best way to share a directory between an OS X host and Ubuntu
guest?




  • Host: Mac OS X 10.7.3

  • Guest: Ubuntu 12.04

  • Guest has a shared directory mounted via VirtualBox settings with
    Access=Full and Auto-Mount=Yes.


The problem with this setup is illustrated below. In my shared directory, I
can't change the permissions at all (not a permissions denied error, but they
just don't take effect).



Ubuntu 12.04 (guest):



% ls -l
total 0
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 1
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 10
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 2
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 3
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 4
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 5
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 6
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 7
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 8
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 9


Mac OS X 10.7.3 (host):



$ ls -l
total 0
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 1
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 10
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 2
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 3
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 4
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 5
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 6
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 7
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 8
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 9


If I chmod on the guest, nothing changes:



% chmod +x 1 | ls -l 1 # guest
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 1


If I chmod on the host, it changes on the host but not on the guest:



$ chmod +x 1 | ls -l 1 # host
-rwxrwx--x 1 <my-mac-user> staff 0 Apr 17 21:56 1

% ls -l 1 # guest
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 1









share|improve this question















In VirtualBox, what is the best way to share a directory between an OS X host and Ubuntu
guest?




  • Host: Mac OS X 10.7.3

  • Guest: Ubuntu 12.04

  • Guest has a shared directory mounted via VirtualBox settings with
    Access=Full and Auto-Mount=Yes.


The problem with this setup is illustrated below. In my shared directory, I
can't change the permissions at all (not a permissions denied error, but they
just don't take effect).



Ubuntu 12.04 (guest):



% ls -l
total 0
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 1
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 10
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 2
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 3
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 4
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 5
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 6
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 7
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 8
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 9


Mac OS X 10.7.3 (host):



$ ls -l
total 0
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 1
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 10
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 2
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 3
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 4
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 5
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 6
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 7
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 8
-rw-r--r-- 1 <my-mac-user> staff 0 Apr 17 21:56 9


If I chmod on the guest, nothing changes:



% chmod +x 1 | ls -l 1 # guest
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 1


If I chmod on the host, it changes on the host but not on the guest:



$ chmod +x 1 | ls -l 1 # host
-rwxrwx--x 1 <my-mac-user> staff 0 Apr 17 21:56 1

% ls -l 1 # guest
-rwxrwx--- 1 root vboxsf 0 Apr 17 21:56 1






virtualbox permissions mac






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 18 '18 at 4:46









muru

1




1










asked Apr 18 '12 at 4:11









jmdeldinjmdeldin

421139




421139












  • Ah, I figured it out, but I can't post the answer for another 8 hours (not enough points). The solution is to do sudo mount.vboxsf -o umask=002,gid=1000,uid=1000 src /media/sf_src, where the umask is the value of umask of the user, uid and gid are from id <user>, src is the name of the VBox share, and /meida/sf_src is the desired mount point.
    – jmdeldin
    Apr 18 '12 at 4:56


















  • Ah, I figured it out, but I can't post the answer for another 8 hours (not enough points). The solution is to do sudo mount.vboxsf -o umask=002,gid=1000,uid=1000 src /media/sf_src, where the umask is the value of umask of the user, uid and gid are from id <user>, src is the name of the VBox share, and /meida/sf_src is the desired mount point.
    – jmdeldin
    Apr 18 '12 at 4:56
















Ah, I figured it out, but I can't post the answer for another 8 hours (not enough points). The solution is to do sudo mount.vboxsf -o umask=002,gid=1000,uid=1000 src /media/sf_src, where the umask is the value of umask of the user, uid and gid are from id <user>, src is the name of the VBox share, and /meida/sf_src is the desired mount point.
– jmdeldin
Apr 18 '12 at 4:56




Ah, I figured it out, but I can't post the answer for another 8 hours (not enough points). The solution is to do sudo mount.vboxsf -o umask=002,gid=1000,uid=1000 src /media/sf_src, where the umask is the value of umask of the user, uid and gid are from id <user>, src is the name of the VBox share, and /meida/sf_src is the desired mount point.
– jmdeldin
Apr 18 '12 at 4:56










8 Answers
8






active

oldest

votes


















21














I've figured it out!



To reproduce:




  1. Shutdown the VM, add shared folders in VBox's settings (Permanent=Yes, Auto-Mount=No)

  2. Start the VM


  3. From a terminal, run umask && id as the normal user to get something like this:



    002 # this is your umask
    uid=1000(luser) gid=1000(luser) groups=1000(luser),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare),125(vboxsf)


  4. sudo mkdir -p /media/sf_src # src is the shared directory


To mount the src directory as a test:



sudo mount.vboxsf -o umask=002,gid=1000,uid=1000 src /media/sf_src 
| | | | |-> where to mount
| | | | the file
| | | |-> name of the shared dir
| | | (in VBox settings)
| | |
| /
from the `id` command


To automatically mount it on login, edit /etc/fstab and add the following:



src /media/sf_src vboxsf umask=002,gid=1000,uid=1000





share|improve this answer























  • This is EXACTLY what I was looking for! I ended up creating a shared user group for apache2 and my users that have access to the mounted folder. serverfault.com/questions/6895/…
    – thesmart
    May 29 '12 at 2:15












  • Thanks! Note that I had big problems until I discovered that /sbin/mount.vboxsf was a dangling symlink! Erasing it and then ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf solved the problem! The guest additions install probably wasn't able to symlink it. I spent far too much time figuring this out!
    – csl
    May 1 '14 at 14:00






  • 2




    ... now the only problem seems to be that vboxsf doesn't handle symlinks! As in, you can't create symlinks in the shared folder from the VM! (At least on OSX, VirtualBox 4.3.10
    – csl
    May 1 '14 at 14:06










  • This procedure certainly is one of a few to get you there. In my case though, when I change to the shared directory and try issuing an ls command, the terminal hangs
    – demongolem
    Oct 13 '15 at 21:20



















4














The problem -- permission issues in vbox/ubuntu accessing a OSX shared drive



joe_public@joe_public-ubuntu-VirtualBox:/$ ls /media/sf_shared
ls: cannot open directory /media/sf_shared: Permission denied


The goal is a simple way to to share directories between Mac and Ubuntu environments. Unfortunately the examples that I have seen so far seem to be a bit more complex than they actual need to be, and don't really explain what the real problem that needs to be solved. I'll attempt to to handle both of those issues here.



The environment here is a Mac running OSX 10.9.5, with Virtual Box 4.3.16 executing Ubuntu-14.04.1 with Guest extensions installed. September 2014 stuff.



I think that the entire problem here is that the uid of the directories on the Mac, and in Ubuntu must match — The default gid’s assigned for user and groups are different between OSX and Ubuntu, and that’s where the trouble lies.



To access a file, one must either own it, or be a member of the group that owns it. And as access is actually based on the id number of the group, not the group name, all that is necessary is to create a common group number on both sides, that the users belong to.



That’s exactly what the solution below does. Don’t be mislead by the length of what’s written, it’s actually very simple. There are just lots and lots of examples of what’s going on.



I’m going to be flipping between OSX and VBOX consoles here (mac and virtual-box/ubuntu) within this doc — make sure you understand which window your in.



Final note: The solution shown below is based on establishing a common group id between the OSX and Ubuntu environments, so that the file permissions work. There may be other, more modern solutions. This one is really simple and understandable, and runs on bare bones basic unadorned installations.



OSX: —————



Note that is was done on a fresh out of the box 10.9.5 Mac, with nothing on it, not connected to a corporate network, nothing fancy running on it other than stock software. This is as simple as it gets.



When I did the default install on the Mac, joe_public is the admin user, and his uid was set to 501.



Joes-MacBook-Pro:/ joe_public$ id
uid=501(joe_public) gid=20(staff) groups=20(staff),999(vboxsf),401(com.apple.sharepoint.group.1),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),501(access_bpf),33(_appstore),100(_lpoperator),204(_developer),398(com.apple.access_screensharing),399(com.apple.access_ssh)


Notice that the uid is 501 — this is the default first account id on OSX — nothing special



I created a few directories that I want to share on the Mac side — Note that I did not put them under my user directory for backup reasons.



Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk
Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk/shared
Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk/public
Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk/images

Joes-MacBook-Pro:vdisk joe_public$ ls -al
total 0
drwxr-xr-x 5 joe_public admin 170 Oct 8 01:08 .
drwxrwxr-t 36 root admin 1292 Oct 6 02:26 ..
drwxrwxrwx 2 joe_public admin 68 Oct 6 01:08 images
drwxr-xr-x 3 joe_public admin 102 Oct 8 01:07 public
drwxrwxrwx 4 joe_public admin 136 Oct 8 00:45 shared


VBOX: ——————



Simple default virtual box and ubuntu installation - again, joe_public is the default admin created when I installed ubuntu.



Please note once again, that the name space between the OSX and Ubuntu is completely different. There is absolutely no relationship between the two names here.



joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ id
uid=1000(joe_public) gid=1000(joe_public) groups=1000(joe_public),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),124(sambashare)


Created three mount points, using Virtual Box's Setting -> Shared Folders gui.



Name      Path              Auto-mount  Access
images /vdisk/images Yes Full
public /vdisk/pubic Yes Read-only
shared /vdisk/shared Yes Full


NOTE: I actually had to reboot my session for all these mount points to come up.



joe_public@joe_public-ubuntu-VirtualBox:~$ mount | grep vboxsf
shared on /media/sf_shared type vboxsf (gid=999,rw)
public on /media/sf_public type vboxsf (gid=999,rw)
images on /media/sf_images type vboxsf (gid=999,rw)


Notice that the gid for these is 999 — this is the vboxsf group.



joe_public@joe_public-ubuntu-VirtualBox:~$ grep 999 /etc/group
vboxsf:x:999


This was assigned automagicly by Virtual Box version 4.3.16 for us. The vbox documentation shows ways how to change this if you mount the path manually through the command line, but who’s going to remember that — Simply take the defaults that the GUI forces on us..



But it doesn't work (expected at this point -- that's what we are trying to solve)



joe_public@joe_public-ubuntu-VirtualBox:/$ ls /media/sf_shared
ls: cannot open directory /media/sf_shared: Permission denied


Note that at this point joe_public is not a member of that vboxsf group — and that’s going to be a problem until we fix it. FYI: These are the default groups assigned to the account when it is created.



joe_public@joe_public-ubuntu-VirtualBox:/media$ grep joe_public /etc/group
adm:x:4:syslog,joe_public
cdrom:x:24:joe_public
sudo:x:27:joe_public
dip:x:30:joe_public
plugdev:x:46:joe_public
lpadmin:x:108:joe_public
joe_public:x:1000:
sambashare:x:124:joe_public


So what we have at this point (we haven’t done anything yet to fix it)



•   On mac,   joe_public gid is 501
• On linux, joe_public gid is 1000
• On linux, vboxfs gid is 999
• On mac, vboxsf does not exist


We don’t want to change the gid of the user joe_public on either side, as that’s a pain in the ass on already installed systems, and doesn’t solve this for other users. The simplest solution is to make a matching group id — vboxsf — on the mac side, and make sure that joe_public is a member of it on both sides.



So, still on vbox/ubuntu, make joe_public a member of the 999 vboxsf group



joe_public@joe_public-ubuntu-VirtualBox:/$ sudo usermod -a -G vboxsf joe_public
joe_public@joe_public-ubuntu-VirtualBox:/$ grep 999 /etc/group
vboxsf:x:999:joe_public


I think I logged out of my account and back in again here after I did this.



OSX: —————



Now we need to create a vboxsf group on the mac. I doubt that the name actually makes a difference here — it’s the 999 group id that’s important. Please remember that the directory system name spaces (as well as user names) are different between the host and the VM operating systems. But just to make life sane, we all call it vboxsf on the mac. Same reasoning why joe_public is used a user name on both sides.



OSX doesn’t have a simple add group command like linux does — so use the dscl command to do this in multiple steps. Please see the mac os documentation for more details on this. Notice that we create the vboxsf group, and add joe_public to that group here.



sudo dscl . -create /Groups/vboxsf
sudo dscl . -create /Groups/vboxsf name vboxsf
sudo dscl . -create /Groups/vboxsf passwd "*”
sudo dscl . -create /Groups/vboxsf gid 999
sudo dscl . -create /Groups/vboxsf GroupMembership joe_public


So, at this point, we should have



•   On mac, joe_public gid is 501
• On linux, joe_public gid is 1000
• On linux, vboxfs gid is 999
• On mac, vboxsf gid is 999
• On linux, joe_public is member of vboxsf
• On mac, joe_public is member of vboxsf


The proof here is if it works — so that’s the next step



VBOX: ——————



cd into our directory and touch a file



joe_public@joe_public-ubuntu-VirtualBox:/$ cd /media/sf_shared
joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ touch foo


Check that we created a file successfully.



joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ ls -al
total 4
drwxrwx--- 1 root vboxsf 102 Oct 8 00:44 .
drwxr-xr-x 5 root root 4096 Oct 8 00:30 ..
-rwxrwx--- 1 root vboxsf 0 Oct 8 00:44 foo


OSX: —————



Joes-MacBook-Pro:shared joe_public$ cd /vdisk/shared
Joes-MacBook-Pro:shared joe_public$ ls -al
total 0
drwxrwxrwx 3 joe_public vboxsf 102 Oct 8 00:44 .
drwxr-xr-x 6 joe_public admin 204 Oct 8 00:17 ..
-rw-r--r-- 1 joe_public vboxsf 0 Oct 8 00:44 foo

Joes-MacBook-Pro:shared joe_public$ touch bar
Joes-MacBook-Pro:shared joe_public$ ls -al
total 0
drwxrwxrwx 4 joe_public vboxsf 136 Oct 8 00:45 .
drwxr-xr-x 6 joe_public admin 204 Oct 8 00:17 ..
-rw-r--r-- 1 joe_public vboxsf 0 Oct 8 00:45 bar


VBOX: ——————



joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ ls -al
total 4
drwxrwx--- 1 root vboxsf 136 Oct 8 00:45 .
drwxr-xr-x 5 root root 4096 Oct 8 00:30 ..
-rwxrwx--- 1 root vboxsf 0 Oct 8 00:45 bar
-rwxrwx--- 1 root vboxsf 0 Oct 8 00:44 foo


It all appears to be working..



VBOX: —————— FINAL VERIFICATION



What we are checking out here is that this whole thing depend upon the user joe_public being a member of the vboxsf group — and the simplest way is simply removing joe_public from the group



Removing user joe_public from group vboxsf



joe_public@joe_public-ubuntu-VirtualBox:~$ sudo gpasswd -d joe_public vboxsf
log out/in ubuntu


Seeing if we can access it our directory -- and we can't, and this proves that is a group permission problem



joe_public@joe_public-ubuntu-VirtualBox:/$ ls /media/sf_shared
ls: cannot open directory /media/sf_shared: Permission denied


Add user back into vboxsf



joe_public@joe_public-ubuntu-VirtualBox:/$ sudo usermod -a -G vboxsf joe_public
log out/in ubuntu


It works again !



joe_public@joe_public-ubuntu-VirtualBox:~$ ls -al /media/sf_shared
total 4
drwxrwx--- 1 root vboxsf 170 Oct 8 01:48 .
drwxr-xr-x 6 root root 4096 Oct 8 01:25 ..
-rwxrwx--- 1 root vboxsf 0 Oct 8 00:45 bar
-rwxrwx--- 1 root vboxsf 0 Oct 8 00:44 foo


VBOX: -- ONE MORE PROBLEM -- symbolic links in vbox -------



If you go into /media/sf_shared, you will find that symbolic links in shared directories simply don't work. This is a really big problem if you are trying to set up a full linux development environment on a shared drive.



joe_public@joe_public-ubuntu-VirtualBox:/media$ cd sf_images
joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ ls
joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ mkdir test
joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ ln -s test test2
ln: failed to create symbolic link ‘test2’: Read-only file system


By default, symbolic links aren't supported on virtual box shares. See below for explanations. Basically as I understand it, symbolic links are a security hole that were "fixed" in Virtual Box by disabling support for them in the 4.1.8 time frame (2011). I'm running 4.3.16 here...



https://www.virtualbox.org/ticket/10085



http://ahtik.com/blog/fixing-your-virtualbox-shared-folder-symlink-error/



Fortunately there is a back door to re-enable it, via the Host's VBoxManage command. Like always, please understand the security holes here that you may be opening. I'm on a stand-alone development machine, so this doesn't appear to be a problem.



OSX: ------------



Joes-MacBook-Pro:shared pbradstr$ VBoxManage setextradata Ubuntu VBoxInternal2/SharedFoldersEnableSymlinksCreate/shared 1   


Note: Ubuntu is my vm's name, and shared is the shared directory name.



You can get the vm name like this:



Joes-MacBook-Pro:shared pbradstr$ VBoxManage list vms
"Ubuntu" {8461045a-1cee-4d44-8148-05920a47cee0}
Joes-MacBook-Pro:shared pbradstr$


And the shared folders name, either via the Virtual Box gui, or



Joes-MacBook-Pro:shared pbradstr$ VBoxManage showvminfo Ubuntu | grep -A 5 "Shared folders"
Shared folders:

Name: 'shared', Host path: '/vdisk/shared' (machine mapping), writable
Name: 'public', Host path: '/vdisk/public' (machine mapping), readonly
Name: 'images', Host path: '/vdisk/images' (machine mapping), writable


I rebooted the entire virtual box system here, I didn't figure out the minimum requirement for it to take.



Anyway, to test this, go back to you vbox window



VBOX: ---------



joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ ln -s test test2


No error -- and to verify



joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ ls -ald test*
drwxrwx--- 1 root vboxsf 102 Oct 8 11:33 test
lrwxrwx--- 1 root vboxsf 4 Oct 8 13:10 test2 -> test


OSX: ----------



And back on the mac side -- just to prove it all works



Joes-MacBook-Pro:shared pbradstr$ ln -s test test3
Joes-MacBook-Pro:shared pbradstr$ ls -ald test*
drwxr-xr-x 4 joe_public admin 136 Oct 8 13:20 test
lrwxr-xr-x 1 joe_public admin 4 Oct 8 13:10 test2 -> test
lrwxr-xr-x 1 joe_public admin 4 Oct 8 13:21 test3 -> test


Please note, I have only tested this on a OSX host, and Ubuntu virtual box client. The references that I listed above seemed to indicate that there might be an issue running a Windows based host.



EXERCISE LEFT FOR THE STUDENT ———————



The benefit of the method listed above is that it can run on a stand-along machine, with no network access. But if you think about this, this name-verses-id issue has got to be a common problem between any heterogeneous computing environments.



What other solutions are available where solutions to that problem are available? — Things like Active Directory (a Microsoft product) and the like might be able to solve this. It would be interesting to obtain a collection of those solutions and compare there various features and tradeoffs.






share|improve this answer































    3














    For me all I needed to do was:



    sudo adduser [username] vboxsf


    That was enough for me to get access to the shared folders. The folder has a group of vboxsf, user only needs to be assigned to that group to get access.
    If you need to set more strict access or more controllable access, you might need to go through the steps of mounting it manually with right userid-s.



    For me the fstab solution didn't work and caused the machine not to boot correctly.






    share|improve this answer





























      3














      After you create a shared folder in Virtualbox settings, Ubuntu will automatically mount it for you next time you boot up the system (you will see an icon on your desktop).



      enter image description here



      But if you are not using root account, you will not have permission to access it. What you need to do is to add your user account to a user group called 'vboxsf':



      sudo usermod -G vboxsf -a $USER


      Then logout and login again. You can access the shared folder now.






      share|improve this answer































        3














        Ever since VirtualBox v4.0, it's easy to solve these permissions issues! You don't need to worry about mkdir, mount, chmod, umask, etc. To access your auto-mounted shared folders (which appear in /media with sf_ prefixes by default), there's only one thing you need to do: Add your username to the vboxsf group via sudo usermod -a -G vboxsf [username].



        For convenience, you may also want to create symbolic links to those shared folders within your home folder (e.g., ln -s /media/sf_Stuff ~/Stuff).



        Source: http://www.virtualbox.org/manual/ch04.html#sf_mount_auto






        share|improve this answer























        • Nice point about the symbolic link.
          – Shaun Dychko
          Nov 25 '16 at 9:24



















        0














        I found this, I tested and it worked in Ubuntu and Xubuntu, just the automount feature didn't worked for me



        I. Install Guest Additions



        Firstly, it is necessary to install the VirtualBox’s Guest Additions to the host system:



        Choose in the VitualBox’s menu: Devices -> Install Guest Additions…



        It mounts a new ISO for the host system.
        A new CD appears in Ubuntu (or mount it). Run as root the VBoxLinuxAdditions-x86.run installation script (because it is an Intel based Mac) in a Terminal window:



        cd /media/cdrom
        sudo VBoxLinuxAdditions-x86.run


        Probably you will be asked to restart Ubuntu.



        Installing the Guest Additions has many advantages such as adopting screen resolution (your window size is the system resolution, i.e. no scrollbars), easy mouse mode (no need to press the left command button to release the mouse cursor) and, what we are looking for, shared folders.



        II. Create Shared Folder



        The goal is to access a shared folder, what is an easier way than to use sshd or Samba.



        Choose in the VitualBox’s menu: Devices -> Shared Folders...




        • Click on the Add new shared folder button.

        • Choose a Folder Path - a folder on your Mac harddrive, e.g. /Users/ondrej/Pictures.

        • Choose a Folder Name - a name that identifies this shared folder in Ubuntu (as a host system), e.g. pictures.

        • Select Make Permanent - if you would like to persist this shared folder definition.

        • Click on OK.

        • Click OK to close the list of shared folders.


        III. Mount Shared Folder



        Mount the created shared folder into a folder with permissions for your user. Let’s open a Terminal window on Ubuntu and:



        Create a folder where will be the shared folder mounted. (Skip this step if have already a folder for this.)



        mkdir DIR


        e.g. (in /tmp)



        mkdir share


        Get your user uid:



        id


        The result will be something like:



        uid=1000(ondrej)gid=1000(ondrej)groups=4(adm),20(dialout),24(cdrom),
        46(plugdev),112(lpadmin),119(admin),120(sambashare),1000(ondrej)


        so uid of my user is 1000.
        Mount the shared folder SHARED_FOLDER_NAME into folder MOUNTED_FOLDER with ownership for user with uid USER_ID as root:



        sudo mount -t vboxsf -o uid=USER_ID SHARED_FOLDER_NAME MOUNTED_FOLDER


        e.g.



        sudo mount -t vboxsf -o uid=1000 pictures /tmp/share


        Specifying the uid parameter enables writing to the shared folder for your user.
        The mounted folder MOUNTED_FOLDER (e.g. /tmp/share) contains files from the shared folder on your Mac harddrive. It is possible to write to the share folder as well.
        Optionally, a shared folder can be automatically mounted on the virtual machine start.
        Add the following line to the /etc/fstab file (as root, e.g. sudo vim /etc/fstab):



        SHARED_FOLDER_NAME /PATH/TO/MOUNTED/FOLDER vboxsf uid=1000,gid=1000 0 0


        e.g.



        pictures /tmp/share vboxsf uid=1000,gid=1000 0 0


        where the uid and gid values can be find in the output of the id command (see the step 2 for detailed example).
        The shared folder will be available also after a restart of the virtual machine.



        Source: http://www.valibuk.net/2009/03/accessing-mac-os-x-harddrive-from-ubuntu-in-virtualbox-via-shared-folders/






        share|improve this answer





























          0














          Host OS: macOS
          VM (guest) OS: Ubuntu Server 16.04.5 LTS
          VirtualBox v5.2.18

          Both host OS and guest OS must have same user (further in the text: username).



          Stage 1: Install VirtualBox Guest Additions:



          1.1. Locate the VirtualBox Guest Additions,



          $ cd /Applications/VirtualBox.app/Contents/MacOS/
          $ cp VBoxGuestAdditions.iso ~/Downloads/


          1.2. Start the VM



          1.3. Click the CD icon in the bottom right task bar



          1.4. Select "Choose disk image..."" and search for the VBoxGuestAdditions.iso



          1.5. In the guest terminal type (you can also do this from the host terminal if you SSH into it):



          $ sudo su
          $ apt update
          $ apt upgrade
          $ apt-get install dkms build-essential linux-headers-generic gcc make
          $ mount /dev/cdrom /mnt
          $ cd /mnt
          $ sh ./VBoxLinuxAdditions.run
          $ reboot


          Stage 2: Shared Folders Setup:



          2.1. Create rules in VM:




          • Stop the VM

          • Go to Settings > Shared Folders

          • Click in the Add new port forwarding rule green button in the top right of the window.

          • Search and select the folder you would like to share (e.g.: /path/to/shared/host_folder)

          • Select the Auto-mount and Make Permanent options

          • Start the VM


          2.2. To mount shared folder on /opt you must create shared_folder_dir subfolder and set appropriate permissions to it:



          $ sudo mkdir -p /opt/shared_folder_dir
          $ sudo chmod ug+w -Rv /opt/shared_folder_dir
          $ sudo chown username:username -Rv /opt/shared_folder_dir


          2.3. Add username to the vboxsf group:



          $ sudo adduser username vboxsf
          $ sudo usermod -a -G vboxsf username


          2.4. Reboot VM to apply changes:



          $ sudo reboot


          Stage 3: Auto mounting host_folder into /opt/shared_folder_dir:



          3.1. Change VM's /etc/rc.local:



          $ sudo nano /etc/rc.local


          and place following right above exit 0:



          # 'folder_name' = given in the shared folders configuration
          # 'path/to/shared/folders' = guest path to access the shared folders from
          # 'id' = prints uid/gid
          # sudo mount -t vboxsf -o uid={uid},gid={gid} {shared_folder_name} {path/to/shared/folder}
          sleep 5
          sudo mount -t vboxsf -o uid=1000,gid=1000 host_folder /opt/shared_folder_dir
          exit 0
          <<< EOF >>>



          Note:
          I've added sleep 5 to execute mount operation after VirtualBox Guest Additions has started. You can check that by journalctl -b command.




          3.2. Reboot VM to apply changes:



          $ sudo reboot


          See also






          share|improve this answer





























            -1














            From https://askubuntu.com/a/171357/476506



            # usermod -aG vboxsf user


            Above command will give access to shared folder for "user".






            share|improve this answer






















              protected by N0rbert Oct 28 '18 at 12:32



              Thank you for your interest in this question.
              Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



              Would you like to answer one of these unanswered questions instead?














              8 Answers
              8






              active

              oldest

              votes








              8 Answers
              8






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              21














              I've figured it out!



              To reproduce:




              1. Shutdown the VM, add shared folders in VBox's settings (Permanent=Yes, Auto-Mount=No)

              2. Start the VM


              3. From a terminal, run umask && id as the normal user to get something like this:



                002 # this is your umask
                uid=1000(luser) gid=1000(luser) groups=1000(luser),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare),125(vboxsf)


              4. sudo mkdir -p /media/sf_src # src is the shared directory


              To mount the src directory as a test:



              sudo mount.vboxsf -o umask=002,gid=1000,uid=1000 src /media/sf_src 
              | | | | |-> where to mount
              | | | | the file
              | | | |-> name of the shared dir
              | | | (in VBox settings)
              | | |
              | /
              from the `id` command


              To automatically mount it on login, edit /etc/fstab and add the following:



              src /media/sf_src vboxsf umask=002,gid=1000,uid=1000





              share|improve this answer























              • This is EXACTLY what I was looking for! I ended up creating a shared user group for apache2 and my users that have access to the mounted folder. serverfault.com/questions/6895/…
                – thesmart
                May 29 '12 at 2:15












              • Thanks! Note that I had big problems until I discovered that /sbin/mount.vboxsf was a dangling symlink! Erasing it and then ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf solved the problem! The guest additions install probably wasn't able to symlink it. I spent far too much time figuring this out!
                – csl
                May 1 '14 at 14:00






              • 2




                ... now the only problem seems to be that vboxsf doesn't handle symlinks! As in, you can't create symlinks in the shared folder from the VM! (At least on OSX, VirtualBox 4.3.10
                – csl
                May 1 '14 at 14:06










              • This procedure certainly is one of a few to get you there. In my case though, when I change to the shared directory and try issuing an ls command, the terminal hangs
                – demongolem
                Oct 13 '15 at 21:20
















              21














              I've figured it out!



              To reproduce:




              1. Shutdown the VM, add shared folders in VBox's settings (Permanent=Yes, Auto-Mount=No)

              2. Start the VM


              3. From a terminal, run umask && id as the normal user to get something like this:



                002 # this is your umask
                uid=1000(luser) gid=1000(luser) groups=1000(luser),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare),125(vboxsf)


              4. sudo mkdir -p /media/sf_src # src is the shared directory


              To mount the src directory as a test:



              sudo mount.vboxsf -o umask=002,gid=1000,uid=1000 src /media/sf_src 
              | | | | |-> where to mount
              | | | | the file
              | | | |-> name of the shared dir
              | | | (in VBox settings)
              | | |
              | /
              from the `id` command


              To automatically mount it on login, edit /etc/fstab and add the following:



              src /media/sf_src vboxsf umask=002,gid=1000,uid=1000





              share|improve this answer























              • This is EXACTLY what I was looking for! I ended up creating a shared user group for apache2 and my users that have access to the mounted folder. serverfault.com/questions/6895/…
                – thesmart
                May 29 '12 at 2:15












              • Thanks! Note that I had big problems until I discovered that /sbin/mount.vboxsf was a dangling symlink! Erasing it and then ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf solved the problem! The guest additions install probably wasn't able to symlink it. I spent far too much time figuring this out!
                – csl
                May 1 '14 at 14:00






              • 2




                ... now the only problem seems to be that vboxsf doesn't handle symlinks! As in, you can't create symlinks in the shared folder from the VM! (At least on OSX, VirtualBox 4.3.10
                – csl
                May 1 '14 at 14:06










              • This procedure certainly is one of a few to get you there. In my case though, when I change to the shared directory and try issuing an ls command, the terminal hangs
                – demongolem
                Oct 13 '15 at 21:20














              21












              21








              21






              I've figured it out!



              To reproduce:




              1. Shutdown the VM, add shared folders in VBox's settings (Permanent=Yes, Auto-Mount=No)

              2. Start the VM


              3. From a terminal, run umask && id as the normal user to get something like this:



                002 # this is your umask
                uid=1000(luser) gid=1000(luser) groups=1000(luser),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare),125(vboxsf)


              4. sudo mkdir -p /media/sf_src # src is the shared directory


              To mount the src directory as a test:



              sudo mount.vboxsf -o umask=002,gid=1000,uid=1000 src /media/sf_src 
              | | | | |-> where to mount
              | | | | the file
              | | | |-> name of the shared dir
              | | | (in VBox settings)
              | | |
              | /
              from the `id` command


              To automatically mount it on login, edit /etc/fstab and add the following:



              src /media/sf_src vboxsf umask=002,gid=1000,uid=1000





              share|improve this answer














              I've figured it out!



              To reproduce:




              1. Shutdown the VM, add shared folders in VBox's settings (Permanent=Yes, Auto-Mount=No)

              2. Start the VM


              3. From a terminal, run umask && id as the normal user to get something like this:



                002 # this is your umask
                uid=1000(luser) gid=1000(luser) groups=1000(luser),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare),125(vboxsf)


              4. sudo mkdir -p /media/sf_src # src is the shared directory


              To mount the src directory as a test:



              sudo mount.vboxsf -o umask=002,gid=1000,uid=1000 src /media/sf_src 
              | | | | |-> where to mount
              | | | | the file
              | | | |-> name of the shared dir
              | | | (in VBox settings)
              | | |
              | /
              from the `id` command


              To automatically mount it on login, edit /etc/fstab and add the following:



              src /media/sf_src vboxsf umask=002,gid=1000,uid=1000






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited May 18 '18 at 4:50









              muru

              1




              1










              answered Apr 18 '12 at 15:17









              jmdeldinjmdeldin

              421139




              421139












              • This is EXACTLY what I was looking for! I ended up creating a shared user group for apache2 and my users that have access to the mounted folder. serverfault.com/questions/6895/…
                – thesmart
                May 29 '12 at 2:15












              • Thanks! Note that I had big problems until I discovered that /sbin/mount.vboxsf was a dangling symlink! Erasing it and then ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf solved the problem! The guest additions install probably wasn't able to symlink it. I spent far too much time figuring this out!
                – csl
                May 1 '14 at 14:00






              • 2




                ... now the only problem seems to be that vboxsf doesn't handle symlinks! As in, you can't create symlinks in the shared folder from the VM! (At least on OSX, VirtualBox 4.3.10
                – csl
                May 1 '14 at 14:06










              • This procedure certainly is one of a few to get you there. In my case though, when I change to the shared directory and try issuing an ls command, the terminal hangs
                – demongolem
                Oct 13 '15 at 21:20


















              • This is EXACTLY what I was looking for! I ended up creating a shared user group for apache2 and my users that have access to the mounted folder. serverfault.com/questions/6895/…
                – thesmart
                May 29 '12 at 2:15












              • Thanks! Note that I had big problems until I discovered that /sbin/mount.vboxsf was a dangling symlink! Erasing it and then ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf solved the problem! The guest additions install probably wasn't able to symlink it. I spent far too much time figuring this out!
                – csl
                May 1 '14 at 14:00






              • 2




                ... now the only problem seems to be that vboxsf doesn't handle symlinks! As in, you can't create symlinks in the shared folder from the VM! (At least on OSX, VirtualBox 4.3.10
                – csl
                May 1 '14 at 14:06










              • This procedure certainly is one of a few to get you there. In my case though, when I change to the shared directory and try issuing an ls command, the terminal hangs
                – demongolem
                Oct 13 '15 at 21:20
















              This is EXACTLY what I was looking for! I ended up creating a shared user group for apache2 and my users that have access to the mounted folder. serverfault.com/questions/6895/…
              – thesmart
              May 29 '12 at 2:15






              This is EXACTLY what I was looking for! I ended up creating a shared user group for apache2 and my users that have access to the mounted folder. serverfault.com/questions/6895/…
              – thesmart
              May 29 '12 at 2:15














              Thanks! Note that I had big problems until I discovered that /sbin/mount.vboxsf was a dangling symlink! Erasing it and then ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf solved the problem! The guest additions install probably wasn't able to symlink it. I spent far too much time figuring this out!
              – csl
              May 1 '14 at 14:00




              Thanks! Note that I had big problems until I discovered that /sbin/mount.vboxsf was a dangling symlink! Erasing it and then ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf solved the problem! The guest additions install probably wasn't able to symlink it. I spent far too much time figuring this out!
              – csl
              May 1 '14 at 14:00




              2




              2




              ... now the only problem seems to be that vboxsf doesn't handle symlinks! As in, you can't create symlinks in the shared folder from the VM! (At least on OSX, VirtualBox 4.3.10
              – csl
              May 1 '14 at 14:06




              ... now the only problem seems to be that vboxsf doesn't handle symlinks! As in, you can't create symlinks in the shared folder from the VM! (At least on OSX, VirtualBox 4.3.10
              – csl
              May 1 '14 at 14:06












              This procedure certainly is one of a few to get you there. In my case though, when I change to the shared directory and try issuing an ls command, the terminal hangs
              – demongolem
              Oct 13 '15 at 21:20




              This procedure certainly is one of a few to get you there. In my case though, when I change to the shared directory and try issuing an ls command, the terminal hangs
              – demongolem
              Oct 13 '15 at 21:20













              4














              The problem -- permission issues in vbox/ubuntu accessing a OSX shared drive



              joe_public@joe_public-ubuntu-VirtualBox:/$ ls /media/sf_shared
              ls: cannot open directory /media/sf_shared: Permission denied


              The goal is a simple way to to share directories between Mac and Ubuntu environments. Unfortunately the examples that I have seen so far seem to be a bit more complex than they actual need to be, and don't really explain what the real problem that needs to be solved. I'll attempt to to handle both of those issues here.



              The environment here is a Mac running OSX 10.9.5, with Virtual Box 4.3.16 executing Ubuntu-14.04.1 with Guest extensions installed. September 2014 stuff.



              I think that the entire problem here is that the uid of the directories on the Mac, and in Ubuntu must match — The default gid’s assigned for user and groups are different between OSX and Ubuntu, and that’s where the trouble lies.



              To access a file, one must either own it, or be a member of the group that owns it. And as access is actually based on the id number of the group, not the group name, all that is necessary is to create a common group number on both sides, that the users belong to.



              That’s exactly what the solution below does. Don’t be mislead by the length of what’s written, it’s actually very simple. There are just lots and lots of examples of what’s going on.



              I’m going to be flipping between OSX and VBOX consoles here (mac and virtual-box/ubuntu) within this doc — make sure you understand which window your in.



              Final note: The solution shown below is based on establishing a common group id between the OSX and Ubuntu environments, so that the file permissions work. There may be other, more modern solutions. This one is really simple and understandable, and runs on bare bones basic unadorned installations.



              OSX: —————



              Note that is was done on a fresh out of the box 10.9.5 Mac, with nothing on it, not connected to a corporate network, nothing fancy running on it other than stock software. This is as simple as it gets.



              When I did the default install on the Mac, joe_public is the admin user, and his uid was set to 501.



              Joes-MacBook-Pro:/ joe_public$ id
              uid=501(joe_public) gid=20(staff) groups=20(staff),999(vboxsf),401(com.apple.sharepoint.group.1),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),501(access_bpf),33(_appstore),100(_lpoperator),204(_developer),398(com.apple.access_screensharing),399(com.apple.access_ssh)


              Notice that the uid is 501 — this is the default first account id on OSX — nothing special



              I created a few directories that I want to share on the Mac side — Note that I did not put them under my user directory for backup reasons.



              Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk
              Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk/shared
              Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk/public
              Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk/images

              Joes-MacBook-Pro:vdisk joe_public$ ls -al
              total 0
              drwxr-xr-x 5 joe_public admin 170 Oct 8 01:08 .
              drwxrwxr-t 36 root admin 1292 Oct 6 02:26 ..
              drwxrwxrwx 2 joe_public admin 68 Oct 6 01:08 images
              drwxr-xr-x 3 joe_public admin 102 Oct 8 01:07 public
              drwxrwxrwx 4 joe_public admin 136 Oct 8 00:45 shared


              VBOX: ——————



              Simple default virtual box and ubuntu installation - again, joe_public is the default admin created when I installed ubuntu.



              Please note once again, that the name space between the OSX and Ubuntu is completely different. There is absolutely no relationship between the two names here.



              joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ id
              uid=1000(joe_public) gid=1000(joe_public) groups=1000(joe_public),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),124(sambashare)


              Created three mount points, using Virtual Box's Setting -> Shared Folders gui.



              Name      Path              Auto-mount  Access
              images /vdisk/images Yes Full
              public /vdisk/pubic Yes Read-only
              shared /vdisk/shared Yes Full


              NOTE: I actually had to reboot my session for all these mount points to come up.



              joe_public@joe_public-ubuntu-VirtualBox:~$ mount | grep vboxsf
              shared on /media/sf_shared type vboxsf (gid=999,rw)
              public on /media/sf_public type vboxsf (gid=999,rw)
              images on /media/sf_images type vboxsf (gid=999,rw)


              Notice that the gid for these is 999 — this is the vboxsf group.



              joe_public@joe_public-ubuntu-VirtualBox:~$ grep 999 /etc/group
              vboxsf:x:999


              This was assigned automagicly by Virtual Box version 4.3.16 for us. The vbox documentation shows ways how to change this if you mount the path manually through the command line, but who’s going to remember that — Simply take the defaults that the GUI forces on us..



              But it doesn't work (expected at this point -- that's what we are trying to solve)



              joe_public@joe_public-ubuntu-VirtualBox:/$ ls /media/sf_shared
              ls: cannot open directory /media/sf_shared: Permission denied


              Note that at this point joe_public is not a member of that vboxsf group — and that’s going to be a problem until we fix it. FYI: These are the default groups assigned to the account when it is created.



              joe_public@joe_public-ubuntu-VirtualBox:/media$ grep joe_public /etc/group
              adm:x:4:syslog,joe_public
              cdrom:x:24:joe_public
              sudo:x:27:joe_public
              dip:x:30:joe_public
              plugdev:x:46:joe_public
              lpadmin:x:108:joe_public
              joe_public:x:1000:
              sambashare:x:124:joe_public


              So what we have at this point (we haven’t done anything yet to fix it)



              •   On mac,   joe_public gid is 501
              • On linux, joe_public gid is 1000
              • On linux, vboxfs gid is 999
              • On mac, vboxsf does not exist


              We don’t want to change the gid of the user joe_public on either side, as that’s a pain in the ass on already installed systems, and doesn’t solve this for other users. The simplest solution is to make a matching group id — vboxsf — on the mac side, and make sure that joe_public is a member of it on both sides.



              So, still on vbox/ubuntu, make joe_public a member of the 999 vboxsf group



              joe_public@joe_public-ubuntu-VirtualBox:/$ sudo usermod -a -G vboxsf joe_public
              joe_public@joe_public-ubuntu-VirtualBox:/$ grep 999 /etc/group
              vboxsf:x:999:joe_public


              I think I logged out of my account and back in again here after I did this.



              OSX: —————



              Now we need to create a vboxsf group on the mac. I doubt that the name actually makes a difference here — it’s the 999 group id that’s important. Please remember that the directory system name spaces (as well as user names) are different between the host and the VM operating systems. But just to make life sane, we all call it vboxsf on the mac. Same reasoning why joe_public is used a user name on both sides.



              OSX doesn’t have a simple add group command like linux does — so use the dscl command to do this in multiple steps. Please see the mac os documentation for more details on this. Notice that we create the vboxsf group, and add joe_public to that group here.



              sudo dscl . -create /Groups/vboxsf
              sudo dscl . -create /Groups/vboxsf name vboxsf
              sudo dscl . -create /Groups/vboxsf passwd "*”
              sudo dscl . -create /Groups/vboxsf gid 999
              sudo dscl . -create /Groups/vboxsf GroupMembership joe_public


              So, at this point, we should have



              •   On mac, joe_public gid is 501
              • On linux, joe_public gid is 1000
              • On linux, vboxfs gid is 999
              • On mac, vboxsf gid is 999
              • On linux, joe_public is member of vboxsf
              • On mac, joe_public is member of vboxsf


              The proof here is if it works — so that’s the next step



              VBOX: ——————



              cd into our directory and touch a file



              joe_public@joe_public-ubuntu-VirtualBox:/$ cd /media/sf_shared
              joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ touch foo


              Check that we created a file successfully.



              joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ ls -al
              total 4
              drwxrwx--- 1 root vboxsf 102 Oct 8 00:44 .
              drwxr-xr-x 5 root root 4096 Oct 8 00:30 ..
              -rwxrwx--- 1 root vboxsf 0 Oct 8 00:44 foo


              OSX: —————



              Joes-MacBook-Pro:shared joe_public$ cd /vdisk/shared
              Joes-MacBook-Pro:shared joe_public$ ls -al
              total 0
              drwxrwxrwx 3 joe_public vboxsf 102 Oct 8 00:44 .
              drwxr-xr-x 6 joe_public admin 204 Oct 8 00:17 ..
              -rw-r--r-- 1 joe_public vboxsf 0 Oct 8 00:44 foo

              Joes-MacBook-Pro:shared joe_public$ touch bar
              Joes-MacBook-Pro:shared joe_public$ ls -al
              total 0
              drwxrwxrwx 4 joe_public vboxsf 136 Oct 8 00:45 .
              drwxr-xr-x 6 joe_public admin 204 Oct 8 00:17 ..
              -rw-r--r-- 1 joe_public vboxsf 0 Oct 8 00:45 bar


              VBOX: ——————



              joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ ls -al
              total 4
              drwxrwx--- 1 root vboxsf 136 Oct 8 00:45 .
              drwxr-xr-x 5 root root 4096 Oct 8 00:30 ..
              -rwxrwx--- 1 root vboxsf 0 Oct 8 00:45 bar
              -rwxrwx--- 1 root vboxsf 0 Oct 8 00:44 foo


              It all appears to be working..



              VBOX: —————— FINAL VERIFICATION



              What we are checking out here is that this whole thing depend upon the user joe_public being a member of the vboxsf group — and the simplest way is simply removing joe_public from the group



              Removing user joe_public from group vboxsf



              joe_public@joe_public-ubuntu-VirtualBox:~$ sudo gpasswd -d joe_public vboxsf
              log out/in ubuntu


              Seeing if we can access it our directory -- and we can't, and this proves that is a group permission problem



              joe_public@joe_public-ubuntu-VirtualBox:/$ ls /media/sf_shared
              ls: cannot open directory /media/sf_shared: Permission denied


              Add user back into vboxsf



              joe_public@joe_public-ubuntu-VirtualBox:/$ sudo usermod -a -G vboxsf joe_public
              log out/in ubuntu


              It works again !



              joe_public@joe_public-ubuntu-VirtualBox:~$ ls -al /media/sf_shared
              total 4
              drwxrwx--- 1 root vboxsf 170 Oct 8 01:48 .
              drwxr-xr-x 6 root root 4096 Oct 8 01:25 ..
              -rwxrwx--- 1 root vboxsf 0 Oct 8 00:45 bar
              -rwxrwx--- 1 root vboxsf 0 Oct 8 00:44 foo


              VBOX: -- ONE MORE PROBLEM -- symbolic links in vbox -------



              If you go into /media/sf_shared, you will find that symbolic links in shared directories simply don't work. This is a really big problem if you are trying to set up a full linux development environment on a shared drive.



              joe_public@joe_public-ubuntu-VirtualBox:/media$ cd sf_images
              joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ ls
              joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ mkdir test
              joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ ln -s test test2
              ln: failed to create symbolic link ‘test2’: Read-only file system


              By default, symbolic links aren't supported on virtual box shares. See below for explanations. Basically as I understand it, symbolic links are a security hole that were "fixed" in Virtual Box by disabling support for them in the 4.1.8 time frame (2011). I'm running 4.3.16 here...



              https://www.virtualbox.org/ticket/10085



              http://ahtik.com/blog/fixing-your-virtualbox-shared-folder-symlink-error/



              Fortunately there is a back door to re-enable it, via the Host's VBoxManage command. Like always, please understand the security holes here that you may be opening. I'm on a stand-alone development machine, so this doesn't appear to be a problem.



              OSX: ------------



              Joes-MacBook-Pro:shared pbradstr$ VBoxManage setextradata Ubuntu VBoxInternal2/SharedFoldersEnableSymlinksCreate/shared 1   


              Note: Ubuntu is my vm's name, and shared is the shared directory name.



              You can get the vm name like this:



              Joes-MacBook-Pro:shared pbradstr$ VBoxManage list vms
              "Ubuntu" {8461045a-1cee-4d44-8148-05920a47cee0}
              Joes-MacBook-Pro:shared pbradstr$


              And the shared folders name, either via the Virtual Box gui, or



              Joes-MacBook-Pro:shared pbradstr$ VBoxManage showvminfo Ubuntu | grep -A 5 "Shared folders"
              Shared folders:

              Name: 'shared', Host path: '/vdisk/shared' (machine mapping), writable
              Name: 'public', Host path: '/vdisk/public' (machine mapping), readonly
              Name: 'images', Host path: '/vdisk/images' (machine mapping), writable


              I rebooted the entire virtual box system here, I didn't figure out the minimum requirement for it to take.



              Anyway, to test this, go back to you vbox window



              VBOX: ---------



              joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ ln -s test test2


              No error -- and to verify



              joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ ls -ald test*
              drwxrwx--- 1 root vboxsf 102 Oct 8 11:33 test
              lrwxrwx--- 1 root vboxsf 4 Oct 8 13:10 test2 -> test


              OSX: ----------



              And back on the mac side -- just to prove it all works



              Joes-MacBook-Pro:shared pbradstr$ ln -s test test3
              Joes-MacBook-Pro:shared pbradstr$ ls -ald test*
              drwxr-xr-x 4 joe_public admin 136 Oct 8 13:20 test
              lrwxr-xr-x 1 joe_public admin 4 Oct 8 13:10 test2 -> test
              lrwxr-xr-x 1 joe_public admin 4 Oct 8 13:21 test3 -> test


              Please note, I have only tested this on a OSX host, and Ubuntu virtual box client. The references that I listed above seemed to indicate that there might be an issue running a Windows based host.



              EXERCISE LEFT FOR THE STUDENT ———————



              The benefit of the method listed above is that it can run on a stand-along machine, with no network access. But if you think about this, this name-verses-id issue has got to be a common problem between any heterogeneous computing environments.



              What other solutions are available where solutions to that problem are available? — Things like Active Directory (a Microsoft product) and the like might be able to solve this. It would be interesting to obtain a collection of those solutions and compare there various features and tradeoffs.






              share|improve this answer




























                4














                The problem -- permission issues in vbox/ubuntu accessing a OSX shared drive



                joe_public@joe_public-ubuntu-VirtualBox:/$ ls /media/sf_shared
                ls: cannot open directory /media/sf_shared: Permission denied


                The goal is a simple way to to share directories between Mac and Ubuntu environments. Unfortunately the examples that I have seen so far seem to be a bit more complex than they actual need to be, and don't really explain what the real problem that needs to be solved. I'll attempt to to handle both of those issues here.



                The environment here is a Mac running OSX 10.9.5, with Virtual Box 4.3.16 executing Ubuntu-14.04.1 with Guest extensions installed. September 2014 stuff.



                I think that the entire problem here is that the uid of the directories on the Mac, and in Ubuntu must match — The default gid’s assigned for user and groups are different between OSX and Ubuntu, and that’s where the trouble lies.



                To access a file, one must either own it, or be a member of the group that owns it. And as access is actually based on the id number of the group, not the group name, all that is necessary is to create a common group number on both sides, that the users belong to.



                That’s exactly what the solution below does. Don’t be mislead by the length of what’s written, it’s actually very simple. There are just lots and lots of examples of what’s going on.



                I’m going to be flipping between OSX and VBOX consoles here (mac and virtual-box/ubuntu) within this doc — make sure you understand which window your in.



                Final note: The solution shown below is based on establishing a common group id between the OSX and Ubuntu environments, so that the file permissions work. There may be other, more modern solutions. This one is really simple and understandable, and runs on bare bones basic unadorned installations.



                OSX: —————



                Note that is was done on a fresh out of the box 10.9.5 Mac, with nothing on it, not connected to a corporate network, nothing fancy running on it other than stock software. This is as simple as it gets.



                When I did the default install on the Mac, joe_public is the admin user, and his uid was set to 501.



                Joes-MacBook-Pro:/ joe_public$ id
                uid=501(joe_public) gid=20(staff) groups=20(staff),999(vboxsf),401(com.apple.sharepoint.group.1),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),501(access_bpf),33(_appstore),100(_lpoperator),204(_developer),398(com.apple.access_screensharing),399(com.apple.access_ssh)


                Notice that the uid is 501 — this is the default first account id on OSX — nothing special



                I created a few directories that I want to share on the Mac side — Note that I did not put them under my user directory for backup reasons.



                Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk
                Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk/shared
                Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk/public
                Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk/images

                Joes-MacBook-Pro:vdisk joe_public$ ls -al
                total 0
                drwxr-xr-x 5 joe_public admin 170 Oct 8 01:08 .
                drwxrwxr-t 36 root admin 1292 Oct 6 02:26 ..
                drwxrwxrwx 2 joe_public admin 68 Oct 6 01:08 images
                drwxr-xr-x 3 joe_public admin 102 Oct 8 01:07 public
                drwxrwxrwx 4 joe_public admin 136 Oct 8 00:45 shared


                VBOX: ——————



                Simple default virtual box and ubuntu installation - again, joe_public is the default admin created when I installed ubuntu.



                Please note once again, that the name space between the OSX and Ubuntu is completely different. There is absolutely no relationship between the two names here.



                joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ id
                uid=1000(joe_public) gid=1000(joe_public) groups=1000(joe_public),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),124(sambashare)


                Created three mount points, using Virtual Box's Setting -> Shared Folders gui.



                Name      Path              Auto-mount  Access
                images /vdisk/images Yes Full
                public /vdisk/pubic Yes Read-only
                shared /vdisk/shared Yes Full


                NOTE: I actually had to reboot my session for all these mount points to come up.



                joe_public@joe_public-ubuntu-VirtualBox:~$ mount | grep vboxsf
                shared on /media/sf_shared type vboxsf (gid=999,rw)
                public on /media/sf_public type vboxsf (gid=999,rw)
                images on /media/sf_images type vboxsf (gid=999,rw)


                Notice that the gid for these is 999 — this is the vboxsf group.



                joe_public@joe_public-ubuntu-VirtualBox:~$ grep 999 /etc/group
                vboxsf:x:999


                This was assigned automagicly by Virtual Box version 4.3.16 for us. The vbox documentation shows ways how to change this if you mount the path manually through the command line, but who’s going to remember that — Simply take the defaults that the GUI forces on us..



                But it doesn't work (expected at this point -- that's what we are trying to solve)



                joe_public@joe_public-ubuntu-VirtualBox:/$ ls /media/sf_shared
                ls: cannot open directory /media/sf_shared: Permission denied


                Note that at this point joe_public is not a member of that vboxsf group — and that’s going to be a problem until we fix it. FYI: These are the default groups assigned to the account when it is created.



                joe_public@joe_public-ubuntu-VirtualBox:/media$ grep joe_public /etc/group
                adm:x:4:syslog,joe_public
                cdrom:x:24:joe_public
                sudo:x:27:joe_public
                dip:x:30:joe_public
                plugdev:x:46:joe_public
                lpadmin:x:108:joe_public
                joe_public:x:1000:
                sambashare:x:124:joe_public


                So what we have at this point (we haven’t done anything yet to fix it)



                •   On mac,   joe_public gid is 501
                • On linux, joe_public gid is 1000
                • On linux, vboxfs gid is 999
                • On mac, vboxsf does not exist


                We don’t want to change the gid of the user joe_public on either side, as that’s a pain in the ass on already installed systems, and doesn’t solve this for other users. The simplest solution is to make a matching group id — vboxsf — on the mac side, and make sure that joe_public is a member of it on both sides.



                So, still on vbox/ubuntu, make joe_public a member of the 999 vboxsf group



                joe_public@joe_public-ubuntu-VirtualBox:/$ sudo usermod -a -G vboxsf joe_public
                joe_public@joe_public-ubuntu-VirtualBox:/$ grep 999 /etc/group
                vboxsf:x:999:joe_public


                I think I logged out of my account and back in again here after I did this.



                OSX: —————



                Now we need to create a vboxsf group on the mac. I doubt that the name actually makes a difference here — it’s the 999 group id that’s important. Please remember that the directory system name spaces (as well as user names) are different between the host and the VM operating systems. But just to make life sane, we all call it vboxsf on the mac. Same reasoning why joe_public is used a user name on both sides.



                OSX doesn’t have a simple add group command like linux does — so use the dscl command to do this in multiple steps. Please see the mac os documentation for more details on this. Notice that we create the vboxsf group, and add joe_public to that group here.



                sudo dscl . -create /Groups/vboxsf
                sudo dscl . -create /Groups/vboxsf name vboxsf
                sudo dscl . -create /Groups/vboxsf passwd "*”
                sudo dscl . -create /Groups/vboxsf gid 999
                sudo dscl . -create /Groups/vboxsf GroupMembership joe_public


                So, at this point, we should have



                •   On mac, joe_public gid is 501
                • On linux, joe_public gid is 1000
                • On linux, vboxfs gid is 999
                • On mac, vboxsf gid is 999
                • On linux, joe_public is member of vboxsf
                • On mac, joe_public is member of vboxsf


                The proof here is if it works — so that’s the next step



                VBOX: ——————



                cd into our directory and touch a file



                joe_public@joe_public-ubuntu-VirtualBox:/$ cd /media/sf_shared
                joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ touch foo


                Check that we created a file successfully.



                joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ ls -al
                total 4
                drwxrwx--- 1 root vboxsf 102 Oct 8 00:44 .
                drwxr-xr-x 5 root root 4096 Oct 8 00:30 ..
                -rwxrwx--- 1 root vboxsf 0 Oct 8 00:44 foo


                OSX: —————



                Joes-MacBook-Pro:shared joe_public$ cd /vdisk/shared
                Joes-MacBook-Pro:shared joe_public$ ls -al
                total 0
                drwxrwxrwx 3 joe_public vboxsf 102 Oct 8 00:44 .
                drwxr-xr-x 6 joe_public admin 204 Oct 8 00:17 ..
                -rw-r--r-- 1 joe_public vboxsf 0 Oct 8 00:44 foo

                Joes-MacBook-Pro:shared joe_public$ touch bar
                Joes-MacBook-Pro:shared joe_public$ ls -al
                total 0
                drwxrwxrwx 4 joe_public vboxsf 136 Oct 8 00:45 .
                drwxr-xr-x 6 joe_public admin 204 Oct 8 00:17 ..
                -rw-r--r-- 1 joe_public vboxsf 0 Oct 8 00:45 bar


                VBOX: ——————



                joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ ls -al
                total 4
                drwxrwx--- 1 root vboxsf 136 Oct 8 00:45 .
                drwxr-xr-x 5 root root 4096 Oct 8 00:30 ..
                -rwxrwx--- 1 root vboxsf 0 Oct 8 00:45 bar
                -rwxrwx--- 1 root vboxsf 0 Oct 8 00:44 foo


                It all appears to be working..



                VBOX: —————— FINAL VERIFICATION



                What we are checking out here is that this whole thing depend upon the user joe_public being a member of the vboxsf group — and the simplest way is simply removing joe_public from the group



                Removing user joe_public from group vboxsf



                joe_public@joe_public-ubuntu-VirtualBox:~$ sudo gpasswd -d joe_public vboxsf
                log out/in ubuntu


                Seeing if we can access it our directory -- and we can't, and this proves that is a group permission problem



                joe_public@joe_public-ubuntu-VirtualBox:/$ ls /media/sf_shared
                ls: cannot open directory /media/sf_shared: Permission denied


                Add user back into vboxsf



                joe_public@joe_public-ubuntu-VirtualBox:/$ sudo usermod -a -G vboxsf joe_public
                log out/in ubuntu


                It works again !



                joe_public@joe_public-ubuntu-VirtualBox:~$ ls -al /media/sf_shared
                total 4
                drwxrwx--- 1 root vboxsf 170 Oct 8 01:48 .
                drwxr-xr-x 6 root root 4096 Oct 8 01:25 ..
                -rwxrwx--- 1 root vboxsf 0 Oct 8 00:45 bar
                -rwxrwx--- 1 root vboxsf 0 Oct 8 00:44 foo


                VBOX: -- ONE MORE PROBLEM -- symbolic links in vbox -------



                If you go into /media/sf_shared, you will find that symbolic links in shared directories simply don't work. This is a really big problem if you are trying to set up a full linux development environment on a shared drive.



                joe_public@joe_public-ubuntu-VirtualBox:/media$ cd sf_images
                joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ ls
                joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ mkdir test
                joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ ln -s test test2
                ln: failed to create symbolic link ‘test2’: Read-only file system


                By default, symbolic links aren't supported on virtual box shares. See below for explanations. Basically as I understand it, symbolic links are a security hole that were "fixed" in Virtual Box by disabling support for them in the 4.1.8 time frame (2011). I'm running 4.3.16 here...



                https://www.virtualbox.org/ticket/10085



                http://ahtik.com/blog/fixing-your-virtualbox-shared-folder-symlink-error/



                Fortunately there is a back door to re-enable it, via the Host's VBoxManage command. Like always, please understand the security holes here that you may be opening. I'm on a stand-alone development machine, so this doesn't appear to be a problem.



                OSX: ------------



                Joes-MacBook-Pro:shared pbradstr$ VBoxManage setextradata Ubuntu VBoxInternal2/SharedFoldersEnableSymlinksCreate/shared 1   


                Note: Ubuntu is my vm's name, and shared is the shared directory name.



                You can get the vm name like this:



                Joes-MacBook-Pro:shared pbradstr$ VBoxManage list vms
                "Ubuntu" {8461045a-1cee-4d44-8148-05920a47cee0}
                Joes-MacBook-Pro:shared pbradstr$


                And the shared folders name, either via the Virtual Box gui, or



                Joes-MacBook-Pro:shared pbradstr$ VBoxManage showvminfo Ubuntu | grep -A 5 "Shared folders"
                Shared folders:

                Name: 'shared', Host path: '/vdisk/shared' (machine mapping), writable
                Name: 'public', Host path: '/vdisk/public' (machine mapping), readonly
                Name: 'images', Host path: '/vdisk/images' (machine mapping), writable


                I rebooted the entire virtual box system here, I didn't figure out the minimum requirement for it to take.



                Anyway, to test this, go back to you vbox window



                VBOX: ---------



                joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ ln -s test test2


                No error -- and to verify



                joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ ls -ald test*
                drwxrwx--- 1 root vboxsf 102 Oct 8 11:33 test
                lrwxrwx--- 1 root vboxsf 4 Oct 8 13:10 test2 -> test


                OSX: ----------



                And back on the mac side -- just to prove it all works



                Joes-MacBook-Pro:shared pbradstr$ ln -s test test3
                Joes-MacBook-Pro:shared pbradstr$ ls -ald test*
                drwxr-xr-x 4 joe_public admin 136 Oct 8 13:20 test
                lrwxr-xr-x 1 joe_public admin 4 Oct 8 13:10 test2 -> test
                lrwxr-xr-x 1 joe_public admin 4 Oct 8 13:21 test3 -> test


                Please note, I have only tested this on a OSX host, and Ubuntu virtual box client. The references that I listed above seemed to indicate that there might be an issue running a Windows based host.



                EXERCISE LEFT FOR THE STUDENT ———————



                The benefit of the method listed above is that it can run on a stand-along machine, with no network access. But if you think about this, this name-verses-id issue has got to be a common problem between any heterogeneous computing environments.



                What other solutions are available where solutions to that problem are available? — Things like Active Directory (a Microsoft product) and the like might be able to solve this. It would be interesting to obtain a collection of those solutions and compare there various features and tradeoffs.






                share|improve this answer


























                  4












                  4








                  4






                  The problem -- permission issues in vbox/ubuntu accessing a OSX shared drive



                  joe_public@joe_public-ubuntu-VirtualBox:/$ ls /media/sf_shared
                  ls: cannot open directory /media/sf_shared: Permission denied


                  The goal is a simple way to to share directories between Mac and Ubuntu environments. Unfortunately the examples that I have seen so far seem to be a bit more complex than they actual need to be, and don't really explain what the real problem that needs to be solved. I'll attempt to to handle both of those issues here.



                  The environment here is a Mac running OSX 10.9.5, with Virtual Box 4.3.16 executing Ubuntu-14.04.1 with Guest extensions installed. September 2014 stuff.



                  I think that the entire problem here is that the uid of the directories on the Mac, and in Ubuntu must match — The default gid’s assigned for user and groups are different between OSX and Ubuntu, and that’s where the trouble lies.



                  To access a file, one must either own it, or be a member of the group that owns it. And as access is actually based on the id number of the group, not the group name, all that is necessary is to create a common group number on both sides, that the users belong to.



                  That’s exactly what the solution below does. Don’t be mislead by the length of what’s written, it’s actually very simple. There are just lots and lots of examples of what’s going on.



                  I’m going to be flipping between OSX and VBOX consoles here (mac and virtual-box/ubuntu) within this doc — make sure you understand which window your in.



                  Final note: The solution shown below is based on establishing a common group id between the OSX and Ubuntu environments, so that the file permissions work. There may be other, more modern solutions. This one is really simple and understandable, and runs on bare bones basic unadorned installations.



                  OSX: —————



                  Note that is was done on a fresh out of the box 10.9.5 Mac, with nothing on it, not connected to a corporate network, nothing fancy running on it other than stock software. This is as simple as it gets.



                  When I did the default install on the Mac, joe_public is the admin user, and his uid was set to 501.



                  Joes-MacBook-Pro:/ joe_public$ id
                  uid=501(joe_public) gid=20(staff) groups=20(staff),999(vboxsf),401(com.apple.sharepoint.group.1),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),501(access_bpf),33(_appstore),100(_lpoperator),204(_developer),398(com.apple.access_screensharing),399(com.apple.access_ssh)


                  Notice that the uid is 501 — this is the default first account id on OSX — nothing special



                  I created a few directories that I want to share on the Mac side — Note that I did not put them under my user directory for backup reasons.



                  Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk
                  Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk/shared
                  Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk/public
                  Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk/images

                  Joes-MacBook-Pro:vdisk joe_public$ ls -al
                  total 0
                  drwxr-xr-x 5 joe_public admin 170 Oct 8 01:08 .
                  drwxrwxr-t 36 root admin 1292 Oct 6 02:26 ..
                  drwxrwxrwx 2 joe_public admin 68 Oct 6 01:08 images
                  drwxr-xr-x 3 joe_public admin 102 Oct 8 01:07 public
                  drwxrwxrwx 4 joe_public admin 136 Oct 8 00:45 shared


                  VBOX: ——————



                  Simple default virtual box and ubuntu installation - again, joe_public is the default admin created when I installed ubuntu.



                  Please note once again, that the name space between the OSX and Ubuntu is completely different. There is absolutely no relationship between the two names here.



                  joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ id
                  uid=1000(joe_public) gid=1000(joe_public) groups=1000(joe_public),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),124(sambashare)


                  Created three mount points, using Virtual Box's Setting -> Shared Folders gui.



                  Name      Path              Auto-mount  Access
                  images /vdisk/images Yes Full
                  public /vdisk/pubic Yes Read-only
                  shared /vdisk/shared Yes Full


                  NOTE: I actually had to reboot my session for all these mount points to come up.



                  joe_public@joe_public-ubuntu-VirtualBox:~$ mount | grep vboxsf
                  shared on /media/sf_shared type vboxsf (gid=999,rw)
                  public on /media/sf_public type vboxsf (gid=999,rw)
                  images on /media/sf_images type vboxsf (gid=999,rw)


                  Notice that the gid for these is 999 — this is the vboxsf group.



                  joe_public@joe_public-ubuntu-VirtualBox:~$ grep 999 /etc/group
                  vboxsf:x:999


                  This was assigned automagicly by Virtual Box version 4.3.16 for us. The vbox documentation shows ways how to change this if you mount the path manually through the command line, but who’s going to remember that — Simply take the defaults that the GUI forces on us..



                  But it doesn't work (expected at this point -- that's what we are trying to solve)



                  joe_public@joe_public-ubuntu-VirtualBox:/$ ls /media/sf_shared
                  ls: cannot open directory /media/sf_shared: Permission denied


                  Note that at this point joe_public is not a member of that vboxsf group — and that’s going to be a problem until we fix it. FYI: These are the default groups assigned to the account when it is created.



                  joe_public@joe_public-ubuntu-VirtualBox:/media$ grep joe_public /etc/group
                  adm:x:4:syslog,joe_public
                  cdrom:x:24:joe_public
                  sudo:x:27:joe_public
                  dip:x:30:joe_public
                  plugdev:x:46:joe_public
                  lpadmin:x:108:joe_public
                  joe_public:x:1000:
                  sambashare:x:124:joe_public


                  So what we have at this point (we haven’t done anything yet to fix it)



                  •   On mac,   joe_public gid is 501
                  • On linux, joe_public gid is 1000
                  • On linux, vboxfs gid is 999
                  • On mac, vboxsf does not exist


                  We don’t want to change the gid of the user joe_public on either side, as that’s a pain in the ass on already installed systems, and doesn’t solve this for other users. The simplest solution is to make a matching group id — vboxsf — on the mac side, and make sure that joe_public is a member of it on both sides.



                  So, still on vbox/ubuntu, make joe_public a member of the 999 vboxsf group



                  joe_public@joe_public-ubuntu-VirtualBox:/$ sudo usermod -a -G vboxsf joe_public
                  joe_public@joe_public-ubuntu-VirtualBox:/$ grep 999 /etc/group
                  vboxsf:x:999:joe_public


                  I think I logged out of my account and back in again here after I did this.



                  OSX: —————



                  Now we need to create a vboxsf group on the mac. I doubt that the name actually makes a difference here — it’s the 999 group id that’s important. Please remember that the directory system name spaces (as well as user names) are different between the host and the VM operating systems. But just to make life sane, we all call it vboxsf on the mac. Same reasoning why joe_public is used a user name on both sides.



                  OSX doesn’t have a simple add group command like linux does — so use the dscl command to do this in multiple steps. Please see the mac os documentation for more details on this. Notice that we create the vboxsf group, and add joe_public to that group here.



                  sudo dscl . -create /Groups/vboxsf
                  sudo dscl . -create /Groups/vboxsf name vboxsf
                  sudo dscl . -create /Groups/vboxsf passwd "*”
                  sudo dscl . -create /Groups/vboxsf gid 999
                  sudo dscl . -create /Groups/vboxsf GroupMembership joe_public


                  So, at this point, we should have



                  •   On mac, joe_public gid is 501
                  • On linux, joe_public gid is 1000
                  • On linux, vboxfs gid is 999
                  • On mac, vboxsf gid is 999
                  • On linux, joe_public is member of vboxsf
                  • On mac, joe_public is member of vboxsf


                  The proof here is if it works — so that’s the next step



                  VBOX: ——————



                  cd into our directory and touch a file



                  joe_public@joe_public-ubuntu-VirtualBox:/$ cd /media/sf_shared
                  joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ touch foo


                  Check that we created a file successfully.



                  joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ ls -al
                  total 4
                  drwxrwx--- 1 root vboxsf 102 Oct 8 00:44 .
                  drwxr-xr-x 5 root root 4096 Oct 8 00:30 ..
                  -rwxrwx--- 1 root vboxsf 0 Oct 8 00:44 foo


                  OSX: —————



                  Joes-MacBook-Pro:shared joe_public$ cd /vdisk/shared
                  Joes-MacBook-Pro:shared joe_public$ ls -al
                  total 0
                  drwxrwxrwx 3 joe_public vboxsf 102 Oct 8 00:44 .
                  drwxr-xr-x 6 joe_public admin 204 Oct 8 00:17 ..
                  -rw-r--r-- 1 joe_public vboxsf 0 Oct 8 00:44 foo

                  Joes-MacBook-Pro:shared joe_public$ touch bar
                  Joes-MacBook-Pro:shared joe_public$ ls -al
                  total 0
                  drwxrwxrwx 4 joe_public vboxsf 136 Oct 8 00:45 .
                  drwxr-xr-x 6 joe_public admin 204 Oct 8 00:17 ..
                  -rw-r--r-- 1 joe_public vboxsf 0 Oct 8 00:45 bar


                  VBOX: ——————



                  joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ ls -al
                  total 4
                  drwxrwx--- 1 root vboxsf 136 Oct 8 00:45 .
                  drwxr-xr-x 5 root root 4096 Oct 8 00:30 ..
                  -rwxrwx--- 1 root vboxsf 0 Oct 8 00:45 bar
                  -rwxrwx--- 1 root vboxsf 0 Oct 8 00:44 foo


                  It all appears to be working..



                  VBOX: —————— FINAL VERIFICATION



                  What we are checking out here is that this whole thing depend upon the user joe_public being a member of the vboxsf group — and the simplest way is simply removing joe_public from the group



                  Removing user joe_public from group vboxsf



                  joe_public@joe_public-ubuntu-VirtualBox:~$ sudo gpasswd -d joe_public vboxsf
                  log out/in ubuntu


                  Seeing if we can access it our directory -- and we can't, and this proves that is a group permission problem



                  joe_public@joe_public-ubuntu-VirtualBox:/$ ls /media/sf_shared
                  ls: cannot open directory /media/sf_shared: Permission denied


                  Add user back into vboxsf



                  joe_public@joe_public-ubuntu-VirtualBox:/$ sudo usermod -a -G vboxsf joe_public
                  log out/in ubuntu


                  It works again !



                  joe_public@joe_public-ubuntu-VirtualBox:~$ ls -al /media/sf_shared
                  total 4
                  drwxrwx--- 1 root vboxsf 170 Oct 8 01:48 .
                  drwxr-xr-x 6 root root 4096 Oct 8 01:25 ..
                  -rwxrwx--- 1 root vboxsf 0 Oct 8 00:45 bar
                  -rwxrwx--- 1 root vboxsf 0 Oct 8 00:44 foo


                  VBOX: -- ONE MORE PROBLEM -- symbolic links in vbox -------



                  If you go into /media/sf_shared, you will find that symbolic links in shared directories simply don't work. This is a really big problem if you are trying to set up a full linux development environment on a shared drive.



                  joe_public@joe_public-ubuntu-VirtualBox:/media$ cd sf_images
                  joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ ls
                  joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ mkdir test
                  joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ ln -s test test2
                  ln: failed to create symbolic link ‘test2’: Read-only file system


                  By default, symbolic links aren't supported on virtual box shares. See below for explanations. Basically as I understand it, symbolic links are a security hole that were "fixed" in Virtual Box by disabling support for them in the 4.1.8 time frame (2011). I'm running 4.3.16 here...



                  https://www.virtualbox.org/ticket/10085



                  http://ahtik.com/blog/fixing-your-virtualbox-shared-folder-symlink-error/



                  Fortunately there is a back door to re-enable it, via the Host's VBoxManage command. Like always, please understand the security holes here that you may be opening. I'm on a stand-alone development machine, so this doesn't appear to be a problem.



                  OSX: ------------



                  Joes-MacBook-Pro:shared pbradstr$ VBoxManage setextradata Ubuntu VBoxInternal2/SharedFoldersEnableSymlinksCreate/shared 1   


                  Note: Ubuntu is my vm's name, and shared is the shared directory name.



                  You can get the vm name like this:



                  Joes-MacBook-Pro:shared pbradstr$ VBoxManage list vms
                  "Ubuntu" {8461045a-1cee-4d44-8148-05920a47cee0}
                  Joes-MacBook-Pro:shared pbradstr$


                  And the shared folders name, either via the Virtual Box gui, or



                  Joes-MacBook-Pro:shared pbradstr$ VBoxManage showvminfo Ubuntu | grep -A 5 "Shared folders"
                  Shared folders:

                  Name: 'shared', Host path: '/vdisk/shared' (machine mapping), writable
                  Name: 'public', Host path: '/vdisk/public' (machine mapping), readonly
                  Name: 'images', Host path: '/vdisk/images' (machine mapping), writable


                  I rebooted the entire virtual box system here, I didn't figure out the minimum requirement for it to take.



                  Anyway, to test this, go back to you vbox window



                  VBOX: ---------



                  joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ ln -s test test2


                  No error -- and to verify



                  joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ ls -ald test*
                  drwxrwx--- 1 root vboxsf 102 Oct 8 11:33 test
                  lrwxrwx--- 1 root vboxsf 4 Oct 8 13:10 test2 -> test


                  OSX: ----------



                  And back on the mac side -- just to prove it all works



                  Joes-MacBook-Pro:shared pbradstr$ ln -s test test3
                  Joes-MacBook-Pro:shared pbradstr$ ls -ald test*
                  drwxr-xr-x 4 joe_public admin 136 Oct 8 13:20 test
                  lrwxr-xr-x 1 joe_public admin 4 Oct 8 13:10 test2 -> test
                  lrwxr-xr-x 1 joe_public admin 4 Oct 8 13:21 test3 -> test


                  Please note, I have only tested this on a OSX host, and Ubuntu virtual box client. The references that I listed above seemed to indicate that there might be an issue running a Windows based host.



                  EXERCISE LEFT FOR THE STUDENT ———————



                  The benefit of the method listed above is that it can run on a stand-along machine, with no network access. But if you think about this, this name-verses-id issue has got to be a common problem between any heterogeneous computing environments.



                  What other solutions are available where solutions to that problem are available? — Things like Active Directory (a Microsoft product) and the like might be able to solve this. It would be interesting to obtain a collection of those solutions and compare there various features and tradeoffs.






                  share|improve this answer














                  The problem -- permission issues in vbox/ubuntu accessing a OSX shared drive



                  joe_public@joe_public-ubuntu-VirtualBox:/$ ls /media/sf_shared
                  ls: cannot open directory /media/sf_shared: Permission denied


                  The goal is a simple way to to share directories between Mac and Ubuntu environments. Unfortunately the examples that I have seen so far seem to be a bit more complex than they actual need to be, and don't really explain what the real problem that needs to be solved. I'll attempt to to handle both of those issues here.



                  The environment here is a Mac running OSX 10.9.5, with Virtual Box 4.3.16 executing Ubuntu-14.04.1 with Guest extensions installed. September 2014 stuff.



                  I think that the entire problem here is that the uid of the directories on the Mac, and in Ubuntu must match — The default gid’s assigned for user and groups are different between OSX and Ubuntu, and that’s where the trouble lies.



                  To access a file, one must either own it, or be a member of the group that owns it. And as access is actually based on the id number of the group, not the group name, all that is necessary is to create a common group number on both sides, that the users belong to.



                  That’s exactly what the solution below does. Don’t be mislead by the length of what’s written, it’s actually very simple. There are just lots and lots of examples of what’s going on.



                  I’m going to be flipping between OSX and VBOX consoles here (mac and virtual-box/ubuntu) within this doc — make sure you understand which window your in.



                  Final note: The solution shown below is based on establishing a common group id between the OSX and Ubuntu environments, so that the file permissions work. There may be other, more modern solutions. This one is really simple and understandable, and runs on bare bones basic unadorned installations.



                  OSX: —————



                  Note that is was done on a fresh out of the box 10.9.5 Mac, with nothing on it, not connected to a corporate network, nothing fancy running on it other than stock software. This is as simple as it gets.



                  When I did the default install on the Mac, joe_public is the admin user, and his uid was set to 501.



                  Joes-MacBook-Pro:/ joe_public$ id
                  uid=501(joe_public) gid=20(staff) groups=20(staff),999(vboxsf),401(com.apple.sharepoint.group.1),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),501(access_bpf),33(_appstore),100(_lpoperator),204(_developer),398(com.apple.access_screensharing),399(com.apple.access_ssh)


                  Notice that the uid is 501 — this is the default first account id on OSX — nothing special



                  I created a few directories that I want to share on the Mac side — Note that I did not put them under my user directory for backup reasons.



                  Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk
                  Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk/shared
                  Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk/public
                  Joes-MacBook-Pro:/ joe_public$ mkdir /vdisk/images

                  Joes-MacBook-Pro:vdisk joe_public$ ls -al
                  total 0
                  drwxr-xr-x 5 joe_public admin 170 Oct 8 01:08 .
                  drwxrwxr-t 36 root admin 1292 Oct 6 02:26 ..
                  drwxrwxrwx 2 joe_public admin 68 Oct 6 01:08 images
                  drwxr-xr-x 3 joe_public admin 102 Oct 8 01:07 public
                  drwxrwxrwx 4 joe_public admin 136 Oct 8 00:45 shared


                  VBOX: ——————



                  Simple default virtual box and ubuntu installation - again, joe_public is the default admin created when I installed ubuntu.



                  Please note once again, that the name space between the OSX and Ubuntu is completely different. There is absolutely no relationship between the two names here.



                  joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ id
                  uid=1000(joe_public) gid=1000(joe_public) groups=1000(joe_public),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),124(sambashare)


                  Created three mount points, using Virtual Box's Setting -> Shared Folders gui.



                  Name      Path              Auto-mount  Access
                  images /vdisk/images Yes Full
                  public /vdisk/pubic Yes Read-only
                  shared /vdisk/shared Yes Full


                  NOTE: I actually had to reboot my session for all these mount points to come up.



                  joe_public@joe_public-ubuntu-VirtualBox:~$ mount | grep vboxsf
                  shared on /media/sf_shared type vboxsf (gid=999,rw)
                  public on /media/sf_public type vboxsf (gid=999,rw)
                  images on /media/sf_images type vboxsf (gid=999,rw)


                  Notice that the gid for these is 999 — this is the vboxsf group.



                  joe_public@joe_public-ubuntu-VirtualBox:~$ grep 999 /etc/group
                  vboxsf:x:999


                  This was assigned automagicly by Virtual Box version 4.3.16 for us. The vbox documentation shows ways how to change this if you mount the path manually through the command line, but who’s going to remember that — Simply take the defaults that the GUI forces on us..



                  But it doesn't work (expected at this point -- that's what we are trying to solve)



                  joe_public@joe_public-ubuntu-VirtualBox:/$ ls /media/sf_shared
                  ls: cannot open directory /media/sf_shared: Permission denied


                  Note that at this point joe_public is not a member of that vboxsf group — and that’s going to be a problem until we fix it. FYI: These are the default groups assigned to the account when it is created.



                  joe_public@joe_public-ubuntu-VirtualBox:/media$ grep joe_public /etc/group
                  adm:x:4:syslog,joe_public
                  cdrom:x:24:joe_public
                  sudo:x:27:joe_public
                  dip:x:30:joe_public
                  plugdev:x:46:joe_public
                  lpadmin:x:108:joe_public
                  joe_public:x:1000:
                  sambashare:x:124:joe_public


                  So what we have at this point (we haven’t done anything yet to fix it)



                  •   On mac,   joe_public gid is 501
                  • On linux, joe_public gid is 1000
                  • On linux, vboxfs gid is 999
                  • On mac, vboxsf does not exist


                  We don’t want to change the gid of the user joe_public on either side, as that’s a pain in the ass on already installed systems, and doesn’t solve this for other users. The simplest solution is to make a matching group id — vboxsf — on the mac side, and make sure that joe_public is a member of it on both sides.



                  So, still on vbox/ubuntu, make joe_public a member of the 999 vboxsf group



                  joe_public@joe_public-ubuntu-VirtualBox:/$ sudo usermod -a -G vboxsf joe_public
                  joe_public@joe_public-ubuntu-VirtualBox:/$ grep 999 /etc/group
                  vboxsf:x:999:joe_public


                  I think I logged out of my account and back in again here after I did this.



                  OSX: —————



                  Now we need to create a vboxsf group on the mac. I doubt that the name actually makes a difference here — it’s the 999 group id that’s important. Please remember that the directory system name spaces (as well as user names) are different between the host and the VM operating systems. But just to make life sane, we all call it vboxsf on the mac. Same reasoning why joe_public is used a user name on both sides.



                  OSX doesn’t have a simple add group command like linux does — so use the dscl command to do this in multiple steps. Please see the mac os documentation for more details on this. Notice that we create the vboxsf group, and add joe_public to that group here.



                  sudo dscl . -create /Groups/vboxsf
                  sudo dscl . -create /Groups/vboxsf name vboxsf
                  sudo dscl . -create /Groups/vboxsf passwd "*”
                  sudo dscl . -create /Groups/vboxsf gid 999
                  sudo dscl . -create /Groups/vboxsf GroupMembership joe_public


                  So, at this point, we should have



                  •   On mac, joe_public gid is 501
                  • On linux, joe_public gid is 1000
                  • On linux, vboxfs gid is 999
                  • On mac, vboxsf gid is 999
                  • On linux, joe_public is member of vboxsf
                  • On mac, joe_public is member of vboxsf


                  The proof here is if it works — so that’s the next step



                  VBOX: ——————



                  cd into our directory and touch a file



                  joe_public@joe_public-ubuntu-VirtualBox:/$ cd /media/sf_shared
                  joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ touch foo


                  Check that we created a file successfully.



                  joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ ls -al
                  total 4
                  drwxrwx--- 1 root vboxsf 102 Oct 8 00:44 .
                  drwxr-xr-x 5 root root 4096 Oct 8 00:30 ..
                  -rwxrwx--- 1 root vboxsf 0 Oct 8 00:44 foo


                  OSX: —————



                  Joes-MacBook-Pro:shared joe_public$ cd /vdisk/shared
                  Joes-MacBook-Pro:shared joe_public$ ls -al
                  total 0
                  drwxrwxrwx 3 joe_public vboxsf 102 Oct 8 00:44 .
                  drwxr-xr-x 6 joe_public admin 204 Oct 8 00:17 ..
                  -rw-r--r-- 1 joe_public vboxsf 0 Oct 8 00:44 foo

                  Joes-MacBook-Pro:shared joe_public$ touch bar
                  Joes-MacBook-Pro:shared joe_public$ ls -al
                  total 0
                  drwxrwxrwx 4 joe_public vboxsf 136 Oct 8 00:45 .
                  drwxr-xr-x 6 joe_public admin 204 Oct 8 00:17 ..
                  -rw-r--r-- 1 joe_public vboxsf 0 Oct 8 00:45 bar


                  VBOX: ——————



                  joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ ls -al
                  total 4
                  drwxrwx--- 1 root vboxsf 136 Oct 8 00:45 .
                  drwxr-xr-x 5 root root 4096 Oct 8 00:30 ..
                  -rwxrwx--- 1 root vboxsf 0 Oct 8 00:45 bar
                  -rwxrwx--- 1 root vboxsf 0 Oct 8 00:44 foo


                  It all appears to be working..



                  VBOX: —————— FINAL VERIFICATION



                  What we are checking out here is that this whole thing depend upon the user joe_public being a member of the vboxsf group — and the simplest way is simply removing joe_public from the group



                  Removing user joe_public from group vboxsf



                  joe_public@joe_public-ubuntu-VirtualBox:~$ sudo gpasswd -d joe_public vboxsf
                  log out/in ubuntu


                  Seeing if we can access it our directory -- and we can't, and this proves that is a group permission problem



                  joe_public@joe_public-ubuntu-VirtualBox:/$ ls /media/sf_shared
                  ls: cannot open directory /media/sf_shared: Permission denied


                  Add user back into vboxsf



                  joe_public@joe_public-ubuntu-VirtualBox:/$ sudo usermod -a -G vboxsf joe_public
                  log out/in ubuntu


                  It works again !



                  joe_public@joe_public-ubuntu-VirtualBox:~$ ls -al /media/sf_shared
                  total 4
                  drwxrwx--- 1 root vboxsf 170 Oct 8 01:48 .
                  drwxr-xr-x 6 root root 4096 Oct 8 01:25 ..
                  -rwxrwx--- 1 root vboxsf 0 Oct 8 00:45 bar
                  -rwxrwx--- 1 root vboxsf 0 Oct 8 00:44 foo


                  VBOX: -- ONE MORE PROBLEM -- symbolic links in vbox -------



                  If you go into /media/sf_shared, you will find that symbolic links in shared directories simply don't work. This is a really big problem if you are trying to set up a full linux development environment on a shared drive.



                  joe_public@joe_public-ubuntu-VirtualBox:/media$ cd sf_images
                  joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ ls
                  joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ mkdir test
                  joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ ln -s test test2
                  ln: failed to create symbolic link ‘test2’: Read-only file system


                  By default, symbolic links aren't supported on virtual box shares. See below for explanations. Basically as I understand it, symbolic links are a security hole that were "fixed" in Virtual Box by disabling support for them in the 4.1.8 time frame (2011). I'm running 4.3.16 here...



                  https://www.virtualbox.org/ticket/10085



                  http://ahtik.com/blog/fixing-your-virtualbox-shared-folder-symlink-error/



                  Fortunately there is a back door to re-enable it, via the Host's VBoxManage command. Like always, please understand the security holes here that you may be opening. I'm on a stand-alone development machine, so this doesn't appear to be a problem.



                  OSX: ------------



                  Joes-MacBook-Pro:shared pbradstr$ VBoxManage setextradata Ubuntu VBoxInternal2/SharedFoldersEnableSymlinksCreate/shared 1   


                  Note: Ubuntu is my vm's name, and shared is the shared directory name.



                  You can get the vm name like this:



                  Joes-MacBook-Pro:shared pbradstr$ VBoxManage list vms
                  "Ubuntu" {8461045a-1cee-4d44-8148-05920a47cee0}
                  Joes-MacBook-Pro:shared pbradstr$


                  And the shared folders name, either via the Virtual Box gui, or



                  Joes-MacBook-Pro:shared pbradstr$ VBoxManage showvminfo Ubuntu | grep -A 5 "Shared folders"
                  Shared folders:

                  Name: 'shared', Host path: '/vdisk/shared' (machine mapping), writable
                  Name: 'public', Host path: '/vdisk/public' (machine mapping), readonly
                  Name: 'images', Host path: '/vdisk/images' (machine mapping), writable


                  I rebooted the entire virtual box system here, I didn't figure out the minimum requirement for it to take.



                  Anyway, to test this, go back to you vbox window



                  VBOX: ---------



                  joe_public@joe_public-ubuntu-VirtualBox:/media/sf_images$ ln -s test test2


                  No error -- and to verify



                  joe_public@joe_public-ubuntu-VirtualBox:/media/sf_shared$ ls -ald test*
                  drwxrwx--- 1 root vboxsf 102 Oct 8 11:33 test
                  lrwxrwx--- 1 root vboxsf 4 Oct 8 13:10 test2 -> test


                  OSX: ----------



                  And back on the mac side -- just to prove it all works



                  Joes-MacBook-Pro:shared pbradstr$ ln -s test test3
                  Joes-MacBook-Pro:shared pbradstr$ ls -ald test*
                  drwxr-xr-x 4 joe_public admin 136 Oct 8 13:20 test
                  lrwxr-xr-x 1 joe_public admin 4 Oct 8 13:10 test2 -> test
                  lrwxr-xr-x 1 joe_public admin 4 Oct 8 13:21 test3 -> test


                  Please note, I have only tested this on a OSX host, and Ubuntu virtual box client. The references that I listed above seemed to indicate that there might be an issue running a Windows based host.



                  EXERCISE LEFT FOR THE STUDENT ———————



                  The benefit of the method listed above is that it can run on a stand-along machine, with no network access. But if you think about this, this name-verses-id issue has got to be a common problem between any heterogeneous computing environments.



                  What other solutions are available where solutions to that problem are available? — Things like Active Directory (a Microsoft product) and the like might be able to solve this. It would be interesting to obtain a collection of those solutions and compare there various features and tradeoffs.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Oct 8 '14 at 20:40

























                  answered Oct 8 '14 at 10:23









                  pbradstrpbradstr

                  412




                  412























                      3














                      For me all I needed to do was:



                      sudo adduser [username] vboxsf


                      That was enough for me to get access to the shared folders. The folder has a group of vboxsf, user only needs to be assigned to that group to get access.
                      If you need to set more strict access or more controllable access, you might need to go through the steps of mounting it manually with right userid-s.



                      For me the fstab solution didn't work and caused the machine not to boot correctly.






                      share|improve this answer


























                        3














                        For me all I needed to do was:



                        sudo adduser [username] vboxsf


                        That was enough for me to get access to the shared folders. The folder has a group of vboxsf, user only needs to be assigned to that group to get access.
                        If you need to set more strict access or more controllable access, you might need to go through the steps of mounting it manually with right userid-s.



                        For me the fstab solution didn't work and caused the machine not to boot correctly.






                        share|improve this answer
























                          3












                          3








                          3






                          For me all I needed to do was:



                          sudo adduser [username] vboxsf


                          That was enough for me to get access to the shared folders. The folder has a group of vboxsf, user only needs to be assigned to that group to get access.
                          If you need to set more strict access or more controllable access, you might need to go through the steps of mounting it manually with right userid-s.



                          For me the fstab solution didn't work and caused the machine not to boot correctly.






                          share|improve this answer












                          For me all I needed to do was:



                          sudo adduser [username] vboxsf


                          That was enough for me to get access to the shared folders. The folder has a group of vboxsf, user only needs to be assigned to that group to get access.
                          If you need to set more strict access or more controllable access, you might need to go through the steps of mounting it manually with right userid-s.



                          For me the fstab solution didn't work and caused the machine not to boot correctly.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Apr 25 '16 at 8:35









                          Kris AviKris Avi

                          312




                          312























                              3














                              After you create a shared folder in Virtualbox settings, Ubuntu will automatically mount it for you next time you boot up the system (you will see an icon on your desktop).



                              enter image description here



                              But if you are not using root account, you will not have permission to access it. What you need to do is to add your user account to a user group called 'vboxsf':



                              sudo usermod -G vboxsf -a $USER


                              Then logout and login again. You can access the shared folder now.






                              share|improve this answer




























                                3














                                After you create a shared folder in Virtualbox settings, Ubuntu will automatically mount it for you next time you boot up the system (you will see an icon on your desktop).



                                enter image description here



                                But if you are not using root account, you will not have permission to access it. What you need to do is to add your user account to a user group called 'vboxsf':



                                sudo usermod -G vboxsf -a $USER


                                Then logout and login again. You can access the shared folder now.






                                share|improve this answer


























                                  3












                                  3








                                  3






                                  After you create a shared folder in Virtualbox settings, Ubuntu will automatically mount it for you next time you boot up the system (you will see an icon on your desktop).



                                  enter image description here



                                  But if you are not using root account, you will not have permission to access it. What you need to do is to add your user account to a user group called 'vboxsf':



                                  sudo usermod -G vboxsf -a $USER


                                  Then logout and login again. You can access the shared folder now.






                                  share|improve this answer














                                  After you create a shared folder in Virtualbox settings, Ubuntu will automatically mount it for you next time you boot up the system (you will see an icon on your desktop).



                                  enter image description here



                                  But if you are not using root account, you will not have permission to access it. What you need to do is to add your user account to a user group called 'vboxsf':



                                  sudo usermod -G vboxsf -a $USER


                                  Then logout and login again. You can access the shared folder now.







                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited Oct 28 '18 at 12:31









                                  N0rbert

                                  21.5k547101




                                  21.5k547101










                                  answered Mar 24 '16 at 15:36









                                  realhurealhu

                                  1,27957




                                  1,27957























                                      3














                                      Ever since VirtualBox v4.0, it's easy to solve these permissions issues! You don't need to worry about mkdir, mount, chmod, umask, etc. To access your auto-mounted shared folders (which appear in /media with sf_ prefixes by default), there's only one thing you need to do: Add your username to the vboxsf group via sudo usermod -a -G vboxsf [username].



                                      For convenience, you may also want to create symbolic links to those shared folders within your home folder (e.g., ln -s /media/sf_Stuff ~/Stuff).



                                      Source: http://www.virtualbox.org/manual/ch04.html#sf_mount_auto






                                      share|improve this answer























                                      • Nice point about the symbolic link.
                                        – Shaun Dychko
                                        Nov 25 '16 at 9:24
















                                      3














                                      Ever since VirtualBox v4.0, it's easy to solve these permissions issues! You don't need to worry about mkdir, mount, chmod, umask, etc. To access your auto-mounted shared folders (which appear in /media with sf_ prefixes by default), there's only one thing you need to do: Add your username to the vboxsf group via sudo usermod -a -G vboxsf [username].



                                      For convenience, you may also want to create symbolic links to those shared folders within your home folder (e.g., ln -s /media/sf_Stuff ~/Stuff).



                                      Source: http://www.virtualbox.org/manual/ch04.html#sf_mount_auto






                                      share|improve this answer























                                      • Nice point about the symbolic link.
                                        – Shaun Dychko
                                        Nov 25 '16 at 9:24














                                      3












                                      3








                                      3






                                      Ever since VirtualBox v4.0, it's easy to solve these permissions issues! You don't need to worry about mkdir, mount, chmod, umask, etc. To access your auto-mounted shared folders (which appear in /media with sf_ prefixes by default), there's only one thing you need to do: Add your username to the vboxsf group via sudo usermod -a -G vboxsf [username].



                                      For convenience, you may also want to create symbolic links to those shared folders within your home folder (e.g., ln -s /media/sf_Stuff ~/Stuff).



                                      Source: http://www.virtualbox.org/manual/ch04.html#sf_mount_auto






                                      share|improve this answer














                                      Ever since VirtualBox v4.0, it's easy to solve these permissions issues! You don't need to worry about mkdir, mount, chmod, umask, etc. To access your auto-mounted shared folders (which appear in /media with sf_ prefixes by default), there's only one thing you need to do: Add your username to the vboxsf group via sudo usermod -a -G vboxsf [username].



                                      For convenience, you may also want to create symbolic links to those shared folders within your home folder (e.g., ln -s /media/sf_Stuff ~/Stuff).



                                      Source: http://www.virtualbox.org/manual/ch04.html#sf_mount_auto







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Jan 4 at 20:30

























                                      answered Nov 2 '15 at 3:43









                                      theDraketheDrake

                                      1336




                                      1336












                                      • Nice point about the symbolic link.
                                        – Shaun Dychko
                                        Nov 25 '16 at 9:24


















                                      • Nice point about the symbolic link.
                                        – Shaun Dychko
                                        Nov 25 '16 at 9:24
















                                      Nice point about the symbolic link.
                                      – Shaun Dychko
                                      Nov 25 '16 at 9:24




                                      Nice point about the symbolic link.
                                      – Shaun Dychko
                                      Nov 25 '16 at 9:24











                                      0














                                      I found this, I tested and it worked in Ubuntu and Xubuntu, just the automount feature didn't worked for me



                                      I. Install Guest Additions



                                      Firstly, it is necessary to install the VirtualBox’s Guest Additions to the host system:



                                      Choose in the VitualBox’s menu: Devices -> Install Guest Additions…



                                      It mounts a new ISO for the host system.
                                      A new CD appears in Ubuntu (or mount it). Run as root the VBoxLinuxAdditions-x86.run installation script (because it is an Intel based Mac) in a Terminal window:



                                      cd /media/cdrom
                                      sudo VBoxLinuxAdditions-x86.run


                                      Probably you will be asked to restart Ubuntu.



                                      Installing the Guest Additions has many advantages such as adopting screen resolution (your window size is the system resolution, i.e. no scrollbars), easy mouse mode (no need to press the left command button to release the mouse cursor) and, what we are looking for, shared folders.



                                      II. Create Shared Folder



                                      The goal is to access a shared folder, what is an easier way than to use sshd or Samba.



                                      Choose in the VitualBox’s menu: Devices -> Shared Folders...




                                      • Click on the Add new shared folder button.

                                      • Choose a Folder Path - a folder on your Mac harddrive, e.g. /Users/ondrej/Pictures.

                                      • Choose a Folder Name - a name that identifies this shared folder in Ubuntu (as a host system), e.g. pictures.

                                      • Select Make Permanent - if you would like to persist this shared folder definition.

                                      • Click on OK.

                                      • Click OK to close the list of shared folders.


                                      III. Mount Shared Folder



                                      Mount the created shared folder into a folder with permissions for your user. Let’s open a Terminal window on Ubuntu and:



                                      Create a folder where will be the shared folder mounted. (Skip this step if have already a folder for this.)



                                      mkdir DIR


                                      e.g. (in /tmp)



                                      mkdir share


                                      Get your user uid:



                                      id


                                      The result will be something like:



                                      uid=1000(ondrej)gid=1000(ondrej)groups=4(adm),20(dialout),24(cdrom),
                                      46(plugdev),112(lpadmin),119(admin),120(sambashare),1000(ondrej)


                                      so uid of my user is 1000.
                                      Mount the shared folder SHARED_FOLDER_NAME into folder MOUNTED_FOLDER with ownership for user with uid USER_ID as root:



                                      sudo mount -t vboxsf -o uid=USER_ID SHARED_FOLDER_NAME MOUNTED_FOLDER


                                      e.g.



                                      sudo mount -t vboxsf -o uid=1000 pictures /tmp/share


                                      Specifying the uid parameter enables writing to the shared folder for your user.
                                      The mounted folder MOUNTED_FOLDER (e.g. /tmp/share) contains files from the shared folder on your Mac harddrive. It is possible to write to the share folder as well.
                                      Optionally, a shared folder can be automatically mounted on the virtual machine start.
                                      Add the following line to the /etc/fstab file (as root, e.g. sudo vim /etc/fstab):



                                      SHARED_FOLDER_NAME /PATH/TO/MOUNTED/FOLDER vboxsf uid=1000,gid=1000 0 0


                                      e.g.



                                      pictures /tmp/share vboxsf uid=1000,gid=1000 0 0


                                      where the uid and gid values can be find in the output of the id command (see the step 2 for detailed example).
                                      The shared folder will be available also after a restart of the virtual machine.



                                      Source: http://www.valibuk.net/2009/03/accessing-mac-os-x-harddrive-from-ubuntu-in-virtualbox-via-shared-folders/






                                      share|improve this answer


























                                        0














                                        I found this, I tested and it worked in Ubuntu and Xubuntu, just the automount feature didn't worked for me



                                        I. Install Guest Additions



                                        Firstly, it is necessary to install the VirtualBox’s Guest Additions to the host system:



                                        Choose in the VitualBox’s menu: Devices -> Install Guest Additions…



                                        It mounts a new ISO for the host system.
                                        A new CD appears in Ubuntu (or mount it). Run as root the VBoxLinuxAdditions-x86.run installation script (because it is an Intel based Mac) in a Terminal window:



                                        cd /media/cdrom
                                        sudo VBoxLinuxAdditions-x86.run


                                        Probably you will be asked to restart Ubuntu.



                                        Installing the Guest Additions has many advantages such as adopting screen resolution (your window size is the system resolution, i.e. no scrollbars), easy mouse mode (no need to press the left command button to release the mouse cursor) and, what we are looking for, shared folders.



                                        II. Create Shared Folder



                                        The goal is to access a shared folder, what is an easier way than to use sshd or Samba.



                                        Choose in the VitualBox’s menu: Devices -> Shared Folders...




                                        • Click on the Add new shared folder button.

                                        • Choose a Folder Path - a folder on your Mac harddrive, e.g. /Users/ondrej/Pictures.

                                        • Choose a Folder Name - a name that identifies this shared folder in Ubuntu (as a host system), e.g. pictures.

                                        • Select Make Permanent - if you would like to persist this shared folder definition.

                                        • Click on OK.

                                        • Click OK to close the list of shared folders.


                                        III. Mount Shared Folder



                                        Mount the created shared folder into a folder with permissions for your user. Let’s open a Terminal window on Ubuntu and:



                                        Create a folder where will be the shared folder mounted. (Skip this step if have already a folder for this.)



                                        mkdir DIR


                                        e.g. (in /tmp)



                                        mkdir share


                                        Get your user uid:



                                        id


                                        The result will be something like:



                                        uid=1000(ondrej)gid=1000(ondrej)groups=4(adm),20(dialout),24(cdrom),
                                        46(plugdev),112(lpadmin),119(admin),120(sambashare),1000(ondrej)


                                        so uid of my user is 1000.
                                        Mount the shared folder SHARED_FOLDER_NAME into folder MOUNTED_FOLDER with ownership for user with uid USER_ID as root:



                                        sudo mount -t vboxsf -o uid=USER_ID SHARED_FOLDER_NAME MOUNTED_FOLDER


                                        e.g.



                                        sudo mount -t vboxsf -o uid=1000 pictures /tmp/share


                                        Specifying the uid parameter enables writing to the shared folder for your user.
                                        The mounted folder MOUNTED_FOLDER (e.g. /tmp/share) contains files from the shared folder on your Mac harddrive. It is possible to write to the share folder as well.
                                        Optionally, a shared folder can be automatically mounted on the virtual machine start.
                                        Add the following line to the /etc/fstab file (as root, e.g. sudo vim /etc/fstab):



                                        SHARED_FOLDER_NAME /PATH/TO/MOUNTED/FOLDER vboxsf uid=1000,gid=1000 0 0


                                        e.g.



                                        pictures /tmp/share vboxsf uid=1000,gid=1000 0 0


                                        where the uid and gid values can be find in the output of the id command (see the step 2 for detailed example).
                                        The shared folder will be available also after a restart of the virtual machine.



                                        Source: http://www.valibuk.net/2009/03/accessing-mac-os-x-harddrive-from-ubuntu-in-virtualbox-via-shared-folders/






                                        share|improve this answer
























                                          0












                                          0








                                          0






                                          I found this, I tested and it worked in Ubuntu and Xubuntu, just the automount feature didn't worked for me



                                          I. Install Guest Additions



                                          Firstly, it is necessary to install the VirtualBox’s Guest Additions to the host system:



                                          Choose in the VitualBox’s menu: Devices -> Install Guest Additions…



                                          It mounts a new ISO for the host system.
                                          A new CD appears in Ubuntu (or mount it). Run as root the VBoxLinuxAdditions-x86.run installation script (because it is an Intel based Mac) in a Terminal window:



                                          cd /media/cdrom
                                          sudo VBoxLinuxAdditions-x86.run


                                          Probably you will be asked to restart Ubuntu.



                                          Installing the Guest Additions has many advantages such as adopting screen resolution (your window size is the system resolution, i.e. no scrollbars), easy mouse mode (no need to press the left command button to release the mouse cursor) and, what we are looking for, shared folders.



                                          II. Create Shared Folder



                                          The goal is to access a shared folder, what is an easier way than to use sshd or Samba.



                                          Choose in the VitualBox’s menu: Devices -> Shared Folders...




                                          • Click on the Add new shared folder button.

                                          • Choose a Folder Path - a folder on your Mac harddrive, e.g. /Users/ondrej/Pictures.

                                          • Choose a Folder Name - a name that identifies this shared folder in Ubuntu (as a host system), e.g. pictures.

                                          • Select Make Permanent - if you would like to persist this shared folder definition.

                                          • Click on OK.

                                          • Click OK to close the list of shared folders.


                                          III. Mount Shared Folder



                                          Mount the created shared folder into a folder with permissions for your user. Let’s open a Terminal window on Ubuntu and:



                                          Create a folder where will be the shared folder mounted. (Skip this step if have already a folder for this.)



                                          mkdir DIR


                                          e.g. (in /tmp)



                                          mkdir share


                                          Get your user uid:



                                          id


                                          The result will be something like:



                                          uid=1000(ondrej)gid=1000(ondrej)groups=4(adm),20(dialout),24(cdrom),
                                          46(plugdev),112(lpadmin),119(admin),120(sambashare),1000(ondrej)


                                          so uid of my user is 1000.
                                          Mount the shared folder SHARED_FOLDER_NAME into folder MOUNTED_FOLDER with ownership for user with uid USER_ID as root:



                                          sudo mount -t vboxsf -o uid=USER_ID SHARED_FOLDER_NAME MOUNTED_FOLDER


                                          e.g.



                                          sudo mount -t vboxsf -o uid=1000 pictures /tmp/share


                                          Specifying the uid parameter enables writing to the shared folder for your user.
                                          The mounted folder MOUNTED_FOLDER (e.g. /tmp/share) contains files from the shared folder on your Mac harddrive. It is possible to write to the share folder as well.
                                          Optionally, a shared folder can be automatically mounted on the virtual machine start.
                                          Add the following line to the /etc/fstab file (as root, e.g. sudo vim /etc/fstab):



                                          SHARED_FOLDER_NAME /PATH/TO/MOUNTED/FOLDER vboxsf uid=1000,gid=1000 0 0


                                          e.g.



                                          pictures /tmp/share vboxsf uid=1000,gid=1000 0 0


                                          where the uid and gid values can be find in the output of the id command (see the step 2 for detailed example).
                                          The shared folder will be available also after a restart of the virtual machine.



                                          Source: http://www.valibuk.net/2009/03/accessing-mac-os-x-harddrive-from-ubuntu-in-virtualbox-via-shared-folders/






                                          share|improve this answer












                                          I found this, I tested and it worked in Ubuntu and Xubuntu, just the automount feature didn't worked for me



                                          I. Install Guest Additions



                                          Firstly, it is necessary to install the VirtualBox’s Guest Additions to the host system:



                                          Choose in the VitualBox’s menu: Devices -> Install Guest Additions…



                                          It mounts a new ISO for the host system.
                                          A new CD appears in Ubuntu (or mount it). Run as root the VBoxLinuxAdditions-x86.run installation script (because it is an Intel based Mac) in a Terminal window:



                                          cd /media/cdrom
                                          sudo VBoxLinuxAdditions-x86.run


                                          Probably you will be asked to restart Ubuntu.



                                          Installing the Guest Additions has many advantages such as adopting screen resolution (your window size is the system resolution, i.e. no scrollbars), easy mouse mode (no need to press the left command button to release the mouse cursor) and, what we are looking for, shared folders.



                                          II. Create Shared Folder



                                          The goal is to access a shared folder, what is an easier way than to use sshd or Samba.



                                          Choose in the VitualBox’s menu: Devices -> Shared Folders...




                                          • Click on the Add new shared folder button.

                                          • Choose a Folder Path - a folder on your Mac harddrive, e.g. /Users/ondrej/Pictures.

                                          • Choose a Folder Name - a name that identifies this shared folder in Ubuntu (as a host system), e.g. pictures.

                                          • Select Make Permanent - if you would like to persist this shared folder definition.

                                          • Click on OK.

                                          • Click OK to close the list of shared folders.


                                          III. Mount Shared Folder



                                          Mount the created shared folder into a folder with permissions for your user. Let’s open a Terminal window on Ubuntu and:



                                          Create a folder where will be the shared folder mounted. (Skip this step if have already a folder for this.)



                                          mkdir DIR


                                          e.g. (in /tmp)



                                          mkdir share


                                          Get your user uid:



                                          id


                                          The result will be something like:



                                          uid=1000(ondrej)gid=1000(ondrej)groups=4(adm),20(dialout),24(cdrom),
                                          46(plugdev),112(lpadmin),119(admin),120(sambashare),1000(ondrej)


                                          so uid of my user is 1000.
                                          Mount the shared folder SHARED_FOLDER_NAME into folder MOUNTED_FOLDER with ownership for user with uid USER_ID as root:



                                          sudo mount -t vboxsf -o uid=USER_ID SHARED_FOLDER_NAME MOUNTED_FOLDER


                                          e.g.



                                          sudo mount -t vboxsf -o uid=1000 pictures /tmp/share


                                          Specifying the uid parameter enables writing to the shared folder for your user.
                                          The mounted folder MOUNTED_FOLDER (e.g. /tmp/share) contains files from the shared folder on your Mac harddrive. It is possible to write to the share folder as well.
                                          Optionally, a shared folder can be automatically mounted on the virtual machine start.
                                          Add the following line to the /etc/fstab file (as root, e.g. sudo vim /etc/fstab):



                                          SHARED_FOLDER_NAME /PATH/TO/MOUNTED/FOLDER vboxsf uid=1000,gid=1000 0 0


                                          e.g.



                                          pictures /tmp/share vboxsf uid=1000,gid=1000 0 0


                                          where the uid and gid values can be find in the output of the id command (see the step 2 for detailed example).
                                          The shared folder will be available also after a restart of the virtual machine.



                                          Source: http://www.valibuk.net/2009/03/accessing-mac-os-x-harddrive-from-ubuntu-in-virtualbox-via-shared-folders/







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Nov 4 '14 at 19:15









                                          JesusJesus

                                          1234




                                          1234























                                              0














                                              Host OS: macOS
                                              VM (guest) OS: Ubuntu Server 16.04.5 LTS
                                              VirtualBox v5.2.18

                                              Both host OS and guest OS must have same user (further in the text: username).



                                              Stage 1: Install VirtualBox Guest Additions:



                                              1.1. Locate the VirtualBox Guest Additions,



                                              $ cd /Applications/VirtualBox.app/Contents/MacOS/
                                              $ cp VBoxGuestAdditions.iso ~/Downloads/


                                              1.2. Start the VM



                                              1.3. Click the CD icon in the bottom right task bar



                                              1.4. Select "Choose disk image..."" and search for the VBoxGuestAdditions.iso



                                              1.5. In the guest terminal type (you can also do this from the host terminal if you SSH into it):



                                              $ sudo su
                                              $ apt update
                                              $ apt upgrade
                                              $ apt-get install dkms build-essential linux-headers-generic gcc make
                                              $ mount /dev/cdrom /mnt
                                              $ cd /mnt
                                              $ sh ./VBoxLinuxAdditions.run
                                              $ reboot


                                              Stage 2: Shared Folders Setup:



                                              2.1. Create rules in VM:




                                              • Stop the VM

                                              • Go to Settings > Shared Folders

                                              • Click in the Add new port forwarding rule green button in the top right of the window.

                                              • Search and select the folder you would like to share (e.g.: /path/to/shared/host_folder)

                                              • Select the Auto-mount and Make Permanent options

                                              • Start the VM


                                              2.2. To mount shared folder on /opt you must create shared_folder_dir subfolder and set appropriate permissions to it:



                                              $ sudo mkdir -p /opt/shared_folder_dir
                                              $ sudo chmod ug+w -Rv /opt/shared_folder_dir
                                              $ sudo chown username:username -Rv /opt/shared_folder_dir


                                              2.3. Add username to the vboxsf group:



                                              $ sudo adduser username vboxsf
                                              $ sudo usermod -a -G vboxsf username


                                              2.4. Reboot VM to apply changes:



                                              $ sudo reboot


                                              Stage 3: Auto mounting host_folder into /opt/shared_folder_dir:



                                              3.1. Change VM's /etc/rc.local:



                                              $ sudo nano /etc/rc.local


                                              and place following right above exit 0:



                                              # 'folder_name' = given in the shared folders configuration
                                              # 'path/to/shared/folders' = guest path to access the shared folders from
                                              # 'id' = prints uid/gid
                                              # sudo mount -t vboxsf -o uid={uid},gid={gid} {shared_folder_name} {path/to/shared/folder}
                                              sleep 5
                                              sudo mount -t vboxsf -o uid=1000,gid=1000 host_folder /opt/shared_folder_dir
                                              exit 0
                                              <<< EOF >>>



                                              Note:
                                              I've added sleep 5 to execute mount operation after VirtualBox Guest Additions has started. You can check that by journalctl -b command.




                                              3.2. Reboot VM to apply changes:



                                              $ sudo reboot


                                              See also






                                              share|improve this answer


























                                                0














                                                Host OS: macOS
                                                VM (guest) OS: Ubuntu Server 16.04.5 LTS
                                                VirtualBox v5.2.18

                                                Both host OS and guest OS must have same user (further in the text: username).



                                                Stage 1: Install VirtualBox Guest Additions:



                                                1.1. Locate the VirtualBox Guest Additions,



                                                $ cd /Applications/VirtualBox.app/Contents/MacOS/
                                                $ cp VBoxGuestAdditions.iso ~/Downloads/


                                                1.2. Start the VM



                                                1.3. Click the CD icon in the bottom right task bar



                                                1.4. Select "Choose disk image..."" and search for the VBoxGuestAdditions.iso



                                                1.5. In the guest terminal type (you can also do this from the host terminal if you SSH into it):



                                                $ sudo su
                                                $ apt update
                                                $ apt upgrade
                                                $ apt-get install dkms build-essential linux-headers-generic gcc make
                                                $ mount /dev/cdrom /mnt
                                                $ cd /mnt
                                                $ sh ./VBoxLinuxAdditions.run
                                                $ reboot


                                                Stage 2: Shared Folders Setup:



                                                2.1. Create rules in VM:




                                                • Stop the VM

                                                • Go to Settings > Shared Folders

                                                • Click in the Add new port forwarding rule green button in the top right of the window.

                                                • Search and select the folder you would like to share (e.g.: /path/to/shared/host_folder)

                                                • Select the Auto-mount and Make Permanent options

                                                • Start the VM


                                                2.2. To mount shared folder on /opt you must create shared_folder_dir subfolder and set appropriate permissions to it:



                                                $ sudo mkdir -p /opt/shared_folder_dir
                                                $ sudo chmod ug+w -Rv /opt/shared_folder_dir
                                                $ sudo chown username:username -Rv /opt/shared_folder_dir


                                                2.3. Add username to the vboxsf group:



                                                $ sudo adduser username vboxsf
                                                $ sudo usermod -a -G vboxsf username


                                                2.4. Reboot VM to apply changes:



                                                $ sudo reboot


                                                Stage 3: Auto mounting host_folder into /opt/shared_folder_dir:



                                                3.1. Change VM's /etc/rc.local:



                                                $ sudo nano /etc/rc.local


                                                and place following right above exit 0:



                                                # 'folder_name' = given in the shared folders configuration
                                                # 'path/to/shared/folders' = guest path to access the shared folders from
                                                # 'id' = prints uid/gid
                                                # sudo mount -t vboxsf -o uid={uid},gid={gid} {shared_folder_name} {path/to/shared/folder}
                                                sleep 5
                                                sudo mount -t vboxsf -o uid=1000,gid=1000 host_folder /opt/shared_folder_dir
                                                exit 0
                                                <<< EOF >>>



                                                Note:
                                                I've added sleep 5 to execute mount operation after VirtualBox Guest Additions has started. You can check that by journalctl -b command.




                                                3.2. Reboot VM to apply changes:



                                                $ sudo reboot


                                                See also






                                                share|improve this answer
























                                                  0












                                                  0








                                                  0






                                                  Host OS: macOS
                                                  VM (guest) OS: Ubuntu Server 16.04.5 LTS
                                                  VirtualBox v5.2.18

                                                  Both host OS and guest OS must have same user (further in the text: username).



                                                  Stage 1: Install VirtualBox Guest Additions:



                                                  1.1. Locate the VirtualBox Guest Additions,



                                                  $ cd /Applications/VirtualBox.app/Contents/MacOS/
                                                  $ cp VBoxGuestAdditions.iso ~/Downloads/


                                                  1.2. Start the VM



                                                  1.3. Click the CD icon in the bottom right task bar



                                                  1.4. Select "Choose disk image..."" and search for the VBoxGuestAdditions.iso



                                                  1.5. In the guest terminal type (you can also do this from the host terminal if you SSH into it):



                                                  $ sudo su
                                                  $ apt update
                                                  $ apt upgrade
                                                  $ apt-get install dkms build-essential linux-headers-generic gcc make
                                                  $ mount /dev/cdrom /mnt
                                                  $ cd /mnt
                                                  $ sh ./VBoxLinuxAdditions.run
                                                  $ reboot


                                                  Stage 2: Shared Folders Setup:



                                                  2.1. Create rules in VM:




                                                  • Stop the VM

                                                  • Go to Settings > Shared Folders

                                                  • Click in the Add new port forwarding rule green button in the top right of the window.

                                                  • Search and select the folder you would like to share (e.g.: /path/to/shared/host_folder)

                                                  • Select the Auto-mount and Make Permanent options

                                                  • Start the VM


                                                  2.2. To mount shared folder on /opt you must create shared_folder_dir subfolder and set appropriate permissions to it:



                                                  $ sudo mkdir -p /opt/shared_folder_dir
                                                  $ sudo chmod ug+w -Rv /opt/shared_folder_dir
                                                  $ sudo chown username:username -Rv /opt/shared_folder_dir


                                                  2.3. Add username to the vboxsf group:



                                                  $ sudo adduser username vboxsf
                                                  $ sudo usermod -a -G vboxsf username


                                                  2.4. Reboot VM to apply changes:



                                                  $ sudo reboot


                                                  Stage 3: Auto mounting host_folder into /opt/shared_folder_dir:



                                                  3.1. Change VM's /etc/rc.local:



                                                  $ sudo nano /etc/rc.local


                                                  and place following right above exit 0:



                                                  # 'folder_name' = given in the shared folders configuration
                                                  # 'path/to/shared/folders' = guest path to access the shared folders from
                                                  # 'id' = prints uid/gid
                                                  # sudo mount -t vboxsf -o uid={uid},gid={gid} {shared_folder_name} {path/to/shared/folder}
                                                  sleep 5
                                                  sudo mount -t vboxsf -o uid=1000,gid=1000 host_folder /opt/shared_folder_dir
                                                  exit 0
                                                  <<< EOF >>>



                                                  Note:
                                                  I've added sleep 5 to execute mount operation after VirtualBox Guest Additions has started. You can check that by journalctl -b command.




                                                  3.2. Reboot VM to apply changes:



                                                  $ sudo reboot


                                                  See also






                                                  share|improve this answer












                                                  Host OS: macOS
                                                  VM (guest) OS: Ubuntu Server 16.04.5 LTS
                                                  VirtualBox v5.2.18

                                                  Both host OS and guest OS must have same user (further in the text: username).



                                                  Stage 1: Install VirtualBox Guest Additions:



                                                  1.1. Locate the VirtualBox Guest Additions,



                                                  $ cd /Applications/VirtualBox.app/Contents/MacOS/
                                                  $ cp VBoxGuestAdditions.iso ~/Downloads/


                                                  1.2. Start the VM



                                                  1.3. Click the CD icon in the bottom right task bar



                                                  1.4. Select "Choose disk image..."" and search for the VBoxGuestAdditions.iso



                                                  1.5. In the guest terminal type (you can also do this from the host terminal if you SSH into it):



                                                  $ sudo su
                                                  $ apt update
                                                  $ apt upgrade
                                                  $ apt-get install dkms build-essential linux-headers-generic gcc make
                                                  $ mount /dev/cdrom /mnt
                                                  $ cd /mnt
                                                  $ sh ./VBoxLinuxAdditions.run
                                                  $ reboot


                                                  Stage 2: Shared Folders Setup:



                                                  2.1. Create rules in VM:




                                                  • Stop the VM

                                                  • Go to Settings > Shared Folders

                                                  • Click in the Add new port forwarding rule green button in the top right of the window.

                                                  • Search and select the folder you would like to share (e.g.: /path/to/shared/host_folder)

                                                  • Select the Auto-mount and Make Permanent options

                                                  • Start the VM


                                                  2.2. To mount shared folder on /opt you must create shared_folder_dir subfolder and set appropriate permissions to it:



                                                  $ sudo mkdir -p /opt/shared_folder_dir
                                                  $ sudo chmod ug+w -Rv /opt/shared_folder_dir
                                                  $ sudo chown username:username -Rv /opt/shared_folder_dir


                                                  2.3. Add username to the vboxsf group:



                                                  $ sudo adduser username vboxsf
                                                  $ sudo usermod -a -G vboxsf username


                                                  2.4. Reboot VM to apply changes:



                                                  $ sudo reboot


                                                  Stage 3: Auto mounting host_folder into /opt/shared_folder_dir:



                                                  3.1. Change VM's /etc/rc.local:



                                                  $ sudo nano /etc/rc.local


                                                  and place following right above exit 0:



                                                  # 'folder_name' = given in the shared folders configuration
                                                  # 'path/to/shared/folders' = guest path to access the shared folders from
                                                  # 'id' = prints uid/gid
                                                  # sudo mount -t vboxsf -o uid={uid},gid={gid} {shared_folder_name} {path/to/shared/folder}
                                                  sleep 5
                                                  sudo mount -t vboxsf -o uid=1000,gid=1000 host_folder /opt/shared_folder_dir
                                                  exit 0
                                                  <<< EOF >>>



                                                  Note:
                                                  I've added sleep 5 to execute mount operation after VirtualBox Guest Additions has started. You can check that by journalctl -b command.




                                                  3.2. Reboot VM to apply changes:



                                                  $ sudo reboot


                                                  See also







                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered Aug 22 '18 at 8:47









                                                  UkrUkr

                                                  1011




                                                  1011























                                                      -1














                                                      From https://askubuntu.com/a/171357/476506



                                                      # usermod -aG vboxsf user


                                                      Above command will give access to shared folder for "user".






                                                      share|improve this answer




























                                                        -1














                                                        From https://askubuntu.com/a/171357/476506



                                                        # usermod -aG vboxsf user


                                                        Above command will give access to shared folder for "user".






                                                        share|improve this answer


























                                                          -1












                                                          -1








                                                          -1






                                                          From https://askubuntu.com/a/171357/476506



                                                          # usermod -aG vboxsf user


                                                          Above command will give access to shared folder for "user".






                                                          share|improve this answer














                                                          From https://askubuntu.com/a/171357/476506



                                                          # usermod -aG vboxsf user


                                                          Above command will give access to shared folder for "user".







                                                          share|improve this answer














                                                          share|improve this answer



                                                          share|improve this answer








                                                          edited Apr 13 '17 at 12:24









                                                          Community

                                                          1




                                                          1










                                                          answered Nov 27 '15 at 7:47









                                                          Utkarsh NaiknawareUtkarsh Naiknaware

                                                          11




                                                          11

















                                                              protected by N0rbert Oct 28 '18 at 12:32



                                                              Thank you for your interest in this question.
                                                              Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                                              Would you like to answer one of these unanswered questions instead?



                                                              Popular posts from this blog

                                                              數位音樂下載

                                                              When can things happen in Etherscan, such as the picture below?

                                                              格利澤436b