17

I recently tried to install a VM with vagrant but "vagrant up" always failed with the error:

Mounting NFS shared folders failed. This is most often caused by the NFS client software not being installed on the guest machine. Please verify that the NFS client software is properly installed, and consult any resources specific to the linux distro you're using for more information on how to do this.

NFS client was properly installed on my machine so I looked for other causes of errors and found a blogpost explaining that my /etc/exports might be corrupted. I restored exportsbak (which contains only commented examples), hoping that vagrant would reconfigure that file properly... but it doesn't, and the error is still there.

How can I force vagrant to regenerate that file or fix it? Thanks.

4

4 回答 4

26

Just delete the file.

sudo rm -f /etc/exports

The file will be recreated during the vagrant up process.

于 2012-09-30T13:42:47.167 回答
0

I was not able to get nfs running on my Ubuntu, because I used the vagrant packages from apt (V 1.2.2)

I installed the latest Vagrant Version (1.5) from here: http://www.vagrantup.com/downloads and nfs worked.

于 2014-03-13T15:22:06.903 回答
0
  1. Check the NSF server is not installed, you can do…</li>

dpkg -l | grep nfs-kernel-server

  1. If it is not installed, install the required packages…</li>

apt-get install nfs-kernel-server apt-get install nfs-common service nfs-kernel-server restart sudo service portmap restart mkdir -p /var/exports

  1. Then in Vagranfile add line under #shared folders...

    config.vm.synced_folder "www", "/var/www", :nfs => { :mount_options => "dmode=755","fmode=755"] }

When vagrant is starting it will ask for root password, to run it without root password you can edit /etc/sudoers and add following lines…</p>

Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_NFSD_CHECK = /etc/init.d/nfs-kernel-server status

Cmnd_Alias VAGRANT_NFSD_START = /etc/init.d/nfs-kernel-server start

Cmnd_Alias VAGRANT_NFSD_APPLY = /usr/sbin/exportfs -ar

Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /bin/sed -r -e * d -ibak /etc/exports

%sudo ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD_CHECK, VAGRANT_NFSD_START, VAGRANT_NFSD_APPLY, VAGRANT_EXPORTS_REMOVE
于 2014-12-08T14:35:07.687 回答
0

if your host is Windows, then you need to install a vagrant plugin Vagrant WinNFSd.

$ vagrant plugin install vagrant-winnfsd
于 2020-12-07T05:32:45.687 回答