Vagrant fails to mount NFS shared folders because of corrupted /etc/exports. How do I fix that file?

StackOverflow https://stackoverflow.com//questions/12651733

  •  11-12-2019
  •  | 
  •  

Question

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.

Was it helpful?

Solution

Just delete the file.

sudo rm -f /etc/exports

The file will be recreated during the vagrant up process.

OTHER TIPS

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.

  1. Check the NSF server is not installed, you can do…

dpkg -l | grep nfs-kernel-server

  1. If it is not installed, install the required packages…

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…

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top