Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant: can't get NFS working

I'm trying to change my VagrantFile so that it uses an NFS mount instead of the default VirtualBox shared folders.

I get this error message:

vm:
* Shared folders that have NFS enabled do not support owner/group
attributes. Host path: .

This is my VagrantFile:

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 
  config.vm.box = "ktbartholomew/lamp"
  config.vm.network "private_network", type: "dhcp"
  config.vm.synced_folder ".", "/vagrant", type: "nfs"
end

I can't see any owner or group getting set.

Please help! Thanks

like image 417
JamesPlayer Avatar asked Jul 21 '14 23:07

JamesPlayer


2 Answers

I've found mapping the uid/gid directly works OK. It's a little weird on the vagrant side, because they are arbitrary users/groups but apart from that it is fine.

Vagrant.configure("2") do |config|
  # ...
  config.nfs.map_uid = Process.uid
  config.nfs.map_gid = Process.gid
  config.vm.synced_folder ".",  "/vagrant", id: "vagrant-root", :nfs => true
  config.vm.synced_folder "..", "/var/www", id: "application",  :nfs => true
end
like image 97
Ryan Avatar answered Oct 08 '22 07:10

Ryan


Vagrant only raises this error when the owner or group is true. Try forcing it by passing nil for both these options for both synced_folder configs.

, group: nil, owner: nil

Here's the code: https://github.com/mitchellh/vagrant/blob/8655d212c327d363f8e80185705ff70bb2e97f6b/plugins/kernel_v2/config/vm.rb#L572

like image 2
Bijan Avatar answered Oct 08 '22 08:10

Bijan