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

When running a vagrant instance the project folder is mounted on /vagrant automatically. However is mounted with the following permissions

# ll -d /vagrant
drwx------ 1 vagrant vagrant 612 Jun 13 14:41 /vagrant/

I need it to be mounted with (at least) 0770 but I can't find how. If I run the mount command I see this output

# mount
v-root on /vagrant type vboxsf (uid=1000,gid=100,rw)

I've tried both chmod and chown/chgrp, but they won't work on that mounted folder so my apache user can't access that folder. I read in Vagrant manual that I can change owner and group but it doesn't mention nothing about permission.

How can I do that?

Another option could be switch to NFS but in this way it won't work on Windows platforms and it need to edit local /etc/exports file and it would require root privileges and also it's pretty annoying, so I'd prefer to not make this change.

share|improve this question
add comment

1 Answer

up vote 33 down vote accepted

Solved with this line in my Vagantfile

config.vm.share_folder("v-root", "/vagrant", ".", :extra => 'dmode=770,fmode=770')

Credits: http://ubuntuforums.org/showthread.php?t=1434884

As pointed out in comments for vagrant >= 1.2 the right syntax to use is:

config.vm.synced_folder ".", "/vagrant", :extra => "dmode=777,fmode=666"

Credits: Aal

1.3.2 > Syntax

For v1.3.2 and later the 'extra' flag on synced folder was changed to 'mount_options'. The options need to be in an array with each option as a separate string ( as opposed to both options being in a single string in previous versions )

config.vm.synced_folder ".", "/vagrant", :mount_options => ["dmode=777","fmode=666"]
share|improve this answer
6  
Dunno why, but I need a slightly different syntax: config.vm.synced_folder ".", "/vagrant", :extra => "dmode=777,fmode=666" –  AaL May 10 '13 at 12:14
1  
+1 Aal and +1 Fabio: share_folder is pre-Vagrant v1.2, synced_folder is Vagrant v1.2 and after. I use puphpet.com to generate my Manifest but had to do this adjustment in the Vagrantfile. –  therobyouknow Aug 1 '13 at 9:10
    
This helped me and my team so much right now! Thanks a lot! –  Andresch Serj Aug 13 '13 at 10:34
1  
config.vm.synced_folder ".", "/vagrant", :mount_options => ["dmode=777,fmode=666"] worked for me on v1.3.2. –  Nobu Sep 18 '13 at 7:59
    
In Vagrant 1.4.3 the syntax is a bit different yet again. The following change to Vagrantfile worked for me: config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{folder['id']}", type: nfs, mount_options: ["dmode=777","fmode=666"] –  Fre Feb 12 at 19:12
add comment

Your Answer

 
discard

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.