Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mount shared folder (vbox) as another user [closed]

I'm sorry to ask this in here, but I tried serverfault and didn't get any answer for 4 days.

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


Question:

I'm trying to mount my vbox shared folder every time my ubuntu (10.04) starts.

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

description     "mount vboxsf Desktop"

start on startup

task
exec mount -t vboxsf Desktop /var/www/shared

Seems to work, except by the fact that all the files are owned by "root", and I don't have permission to write on the folder (neither chmod nor chown seems to be working).

So, how can I make all the files under this shared folder to be owned by www-data user/group?


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

If you have a better idea for that, instead of sharing the folder, fell free to say.

like image 223
dmmd Avatar asked Jun 04 '12 23:06

dmmd


People also ask

Can VirtualBox mount shared folder?

With the help of VirtualBox's shared folders feature, you can select a folder on your host OS to share. Inside your VirtualBox virtual machine you can then mount this shared folder. Once configured, you can easily exchange files between the host and guest OS.

Where does VirtualBox mount shared folders Linux?

The default mount location is in /media/sf_ . You can access the share by making the user, or group id of 1000 , a member of group vboxsf . This is done by changing the vboxsf line in the /etc/group file.


1 Answers

Well, while I was having another issue related with my shared folder, I ended up getting to this stackoverflow question: Shared folder in VirtualBox for Apache

It helped me in 2 ways, and seems that what I need are those uid and gid options.

So, to mount a shared folder as another user, I would run:

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

Also, to see what are your www-data's gid and uid, just run id www-data.

If you also need to change the permissions on the mounted files, just add "dmode" to the options, as:

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

The available options are (from mount's 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 run during the system init, 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
like image 56
dmmd Avatar answered Oct 13 '22 21:10

dmmd