Last week I hit an odd issue with Vagrant. My environment was working fine when suddenly while resuming my box I started to get the following exception printed in the console:
INFO retryable: Retryable exception raised: #<Vagrant::Errors::LinuxNFSMountFailed: The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed!
After checking VirtualBox I could see my virtual machine was running and I was able to open a shell connection to it, however, the NFS shares were not mounted.
That lead me to a path of trying to figure it out what could be the cause of the problem. In the end I didn't find a clear answer, the closest I got was this answer from Hashimoto:
I understand that this is an intermittent issue for people. Iv'e even seen it myself. I'm still not sure what exactly causes this or how to get a solid reproduction. Or, how to fix it. Because of that, I'm going to close it since it is a rare issue. If someone can shed more light, I'd be happy to fix. Thanks.
What I did manage to do was gather a few steps that helped some people solved the Vagrant problems with NFS, they are listed below:
Before trying any of the options below make sure to export the VAGRANT_LOG=DEBUG environment variable to get more details in the console:
1 - Configure firewall
On the mac, under System Preferences > Security & Privacy - Firewall
Make sure the Automatically allow signed software to receive incomming connections is checked
A more detailed firewall rule list can be found on this github issue
2 - Install vagrant VBGuest plugin
To install the plugin:
vagrant plugin install vagrant-vbguest
The plugin's github page
3 - Restart vboxnet0 interface
Bring the interface down and up
$ sudo ifconfig vboxnet0 down $ sudo ifconfig vboxnet0 up
4 - Restart NFSD daemon
First remove all the entries for your vagrant box in the /etc/exports file and then restart the nfsd daemon
sudo nfsd restart
5 - Install NFS dependencies on the client
In the case of an Ubuntu virtual machine make sure the nfs-common and nfs-kernel-server are installed
apt-get install nfs-common nfs-kernel-server
- Running vagrant up hangs on NFS mounting
- missing NFS support error on Ubuntu hosts could be improved perhaps
- Upgrade to Virtual Box 5.0.8 causing NFS failure?
- [NFS] vagrant up hangs while "Mounting NFS shared folders"
- NFS is broken on Mac OS X 10.8.5 using VirtualBox 4.2.18 and Vagrant 1.3.x
- NFS mount fails on subsequent vagrant up commands
- NFS Mount fails when doing Vagrant Up