Thursday, April 25, 2024
 Popular · Latest · Hot · Upcoming
26
rated 0 times [  26] [ 0]  / answers: 1 / hits: 42338  / 3 Years ago, thu, august 26, 2021, 2:12:58

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

More From » virtualbox

 Answers
4

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

[#39230] Friday, August 27, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
disdry

Total Points: 133
Total Questions: 128
Total Answers: 109

Location: Greenland
Member since Fri, Jul 31, 2020
4 Years ago
disdry questions
Tue, Apr 11, 23, 11:37, 1 Year ago
Thu, Oct 13, 22, 19:09, 2 Years ago
Fri, Oct 28, 22, 15:06, 2 Years ago
Sat, Feb 25, 23, 11:33, 1 Year ago
;