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.


[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: https://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
  • 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
  • 1
    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 '14 at 1:09
  • 1
    Thanks for pointing that out, @MartinCleaver. I've edited the answer. – dmmd Dec 30 '14 at 20:52

If you want to share your files between your host and your guest, you can easily run a Web Server instead of hard sharing of a folder. Please note that host and client is Ubuntu 14.04 in my commands: In the host:

mkdir /home/SomeDirectory
cd /home/SomeDirectory
python -m SimpleHTTPServer

Supposing host ip (, now in the guest, open the directory using the followings:


Note that your port above may be different than 8000. xdg-open is in xdg-utils package. If you don't install it before, run this in the guest:

sudo apt-get install xdg-utils

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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