Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

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

description     "mount vboxsf Desktop"

start on startup

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.

share|improve this question

1 Answer 1

up vote 7 down vote accepted

[Same answer as in: StackOverflow]

Well, while I was having another issue related with my shared folder, I ended up getting to this stackoverflow question: http://stackoverflow.com/questions/6298933/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

exec mount -t vboxsf SHARE_NAME /path/on/guest -o uid=1000,gid=33
share|improve this answer
Goodness, I have been looking for well over an hour how to get the owner to anything else than root and I was going crazy: you saved my sanity! –  Matthieu M. Jul 15 '12 at 14:19
I'm glad that it helped (If you could, just up vote my answer please) :) –  dmmd Jul 15 '12 at 22:15
excellent, excellent answer. I did not realise the idea is to mount it as another user. I answered my own question superuser.com/questions/527963/… with your help. Thank you! –  Kim Stacks Jan 4 '13 at 9:06
Thanks! And of course SHARE_NAME-o is actually SHARE_NAME -o –  Martin Cleaver Dec 23 at 1:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.