Copy the shared folder (vbox) as another user

I'm sorry if you ask about it here, but I tried serverfault and did not receive a response within 4 days.

Related question: https://serverfault.com/questions/394197/mount-shared-folder-vbox-as-another-user


Question:

I try to set my vbox shared folder every time my ubuntu (10.04) starts up.

So, I added an entry to / etc / init with this:

description "mount vboxsf Desktop" start on startup task exec mount -t vboxsf Desktop /var/www/shared 

It seems to work, except for the fact that all files are owned by "root" and I don’t have permission to write to the folder (neither chmod nor chown seem to work).

So, how can I make all the files in this shared folder belong to the www-data user / group?


ps .: The main reason for me is to have an automatic shared folder, so I can create / edit files from HOST in the www GUEST folder.

If you have a better idea, instead of sharing a folder, feel free to say.

+8
ubuntu virtualbox mount
source share
1 answer

Well, while I had another problem related to my shared folder, I got into this stack question: Shared folder in VirtualBox for Apache

This helped me in two ways, and it seems that I need these uid and gid options.

So, to set the shared folder as another user, I would run:

 mount -t vboxsf SHARE_NAME /some/dir -o uid=48,gid=48 

Also, to find out what your gid and uid WWW data is, just run id www-data .

If you also need to change permissions on mounted files, just add "dmode" to the parameters, for example:

 sudo mount -t vboxsf SHARE_NAME-o rw,dmode=777,gid=GROUP_ID,uid=USER_ID /path/on/guest 

Available options: (from mount help):

 rw mount read write (default) ro mount read only uid =<arg> default file owner user id gid =<arg> default file owner group id ttl =<arg> time to live for dentry iocharset =<arg> i/o charset (default utf8) convertcp =<arg> convert share name from given charset to utf8 dmode =<arg> mode of all directories fmode =<arg> mode of all regular files umask =<arg> umask of directories and regular files dmask =<arg> umask of directories fmask =<arg> umask of regular files 

And if you need it to start during system initialization, just create a file on /etc/init/SOMETHING.conf, with something like this:

 description "SOME DESCRIPTION" start on startup task exec mount -t vboxsf YOUR_SHARE_NAME /path/on/guest -o uid=1000,gid=33 
+19
source share

All Articles