Search code examples
virtualboxvagrantnfs

Vagrant permissions issue with NFS - files owned by unknown user


I have an NFS share on my Vagrant VM. It works but it can't write files (Symfony2 app, needs to write to app/cache/prod/sessions).

If I use "non-NFS" shares it works, but is dog slow!

From within the guest VM, /var/www/fh-admin is owned by user 501 group root, which I assume is a user on my host OS (OSX)?

Here is my Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = '2'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = 'precise64'
  config.vm.box_url = 'http://files.vagrantup.com/precise64.box'

  #config.vm.network :private_network, ip: '192.168.33.12'
  config.vm.network :private_network, ip: "101.0.0.101", :netmask => "255.255.0.0"
  config.vm.boot_timeout = 60

  config.vm.network "forwarded_port", guest: 80, host: 8080

  config.vm.provision :ansible do |ansible|
    ansible.limit = 'all'
    ansible.sudo = true
    ansible.playbook = '../fh-ansible/fh.yml'
    ansible.inventory_path = 'inventory.ini'
    ansible.verbose = "v"
  end

  config.vm.synced_folder '.', '/var/www/fh-admin', :nfs => { :mount_options => ["dmode=777","fmode=666"] }
  config.vm.synced_folder '/var/www/surveyor-cordova/assets/www', '/var/www/fhapp', :nfs => { :mount_options => ["dmode=777","fmode=666"] }
  config.vm.provider :vmware do |vb|
    vb.customize ["modifyvm", :id, "--memory", "2048"]
  end
  config.vm.provider "vmware_fusion" do |v|
    v.vmx["memsize"] = "2048"
    v.vmx["numvcpus"] = "2"
  end
end

Solution

  • One option would be to not store session data within the NFS share. There's details on how to move it on this blog post by Benjamin Eberlei: http://www.whitewashing.de/2013/08/19/speedup_symfony2_on_vagrant_boxes.html. I think you can also specify the Symfony2 session dir independently though config if you don't want to go down that involved route.