9

I have the following in my Vagrantfile:

config.vm.network :private_network, ip: "10.0.0.103"
config.vm.synced_folder ".", "/vagrant/", type: "nfs"

doing vagrant up on a fresh box yields:

==> default: Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o 'vers=3,udp' 10.0.0.1:'/Users/wayne/app' /vagrant

Stdout from the command:



Stderr from the command:

stdin: is not a tty
mount.nfs: access denied by server while mounting 10.0.0.1:/Users/wayne/app

I then need to vagrant reload and it seems to work... But surely I shouldn't have to do this?

[updated: log output]

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!

mount -o 'vers=3,udp' 10.0.0.1:'/Users/wayne/sonatribe' /vagrant

Stdout from the command:



Stderr from the command:

stdin: is not a tty
mount.nfs: requested NFS version or transport protocol is not supported
>
 INFO ssh: Execute: mount -o 'vers=3,udp' 10.0.0.1:'/Users/wayne/sonatribe' /vagrant (sudo=true)
 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!

mount -o 'vers=3,udp' 10.0.0.1:'/Users/wayne/sonatribe' /vagrant

Stdout from the command:



Stderr from the command:

stdin: is not a tty
mount.nfs: requested NFS version or transport protocol is not supported
  • which operating system are you using? Also, you say a reload actually allows NFS to work? – Hassan Nov 23 '14 at 13:59
  • The host is OSX Yosemite and the guest is XUbuntu, reload allows NFS to work - when reloading I don't need to re-input my password but it works –  Nov 23 '14 at 14:46
  • Do "VAGRANT_LOG=info vagrant up" and paste the output. – Hassan Nov 23 '14 at 14:59
  • @Hassan done - seems the key is: mount.nfs: requested NFS version or transport protocol is not supported –  Nov 23 '14 at 15:14
  • Downgrading and changing the base image to be an LTS Ubuntu (as opposed to XUbuntu) seemed to fix this –  Nov 23 '14 at 17:34

7 Answers7

7

For Linux I do this in the host machine:

systemctl stop nfs-kernel-server.service
systemctl disable nfs-kernel-server.service
systemctl enable nfs-kernel-server.service
systemctl start nfs-kernel-server.service
Oleksandr Fedorov
  • 1,213
  • 10
  • 17
2

Possibly due to OS patching and packages upgrades my Vagrant env stopped working allowing me to waste about 4 precious hours. This is how I managed to resolve it: I use Ubuntu 18.04 and Vbox 6.

  1. re-install vagrant vbguest plugin with vagrant plugin install vagrant-vbguest
  2. Make sure the vbox guest additions matches VirtualBox. Best to install the latest Download VBox Guest Additions
  3. Somehow an NFS package was missing so sudo apt-get install -y nfs-server
  4. Reboot
  5. Run the following with admin permissions

    sudo systemctl stop nfs-kernel-server.service
    sudo systemctl disable nfs-kernel-server.service
    sudo systemctl enable nfs-kernel-server.service
    sudo systemctl start nfs-kernel-server.service
    
  6. just to be sure I did vagrant destroy with vagrant global-status --prune

halfer
  • 19,824
  • 17
  • 99
  • 186
Andre Leon Rangel
  • 1,659
  • 1
  • 16
  • 28
1

It could happen due to host VirtualBox and Guest Additions version mismatch. In this case just before the error line in your boot log, you should be getting:

  ==> default: Checking for guest additions in VM...
  default: The guest additions on this VM do not match the installed version of
  default: VirtualBox! In most cases this is fine, but in rare cases it can
  default: prevent things such as shared folders from working properly. If you see
  default: shared folder errors, please make sure the guest additions within the
  default: virtual machine match the version of VirtualBox you have installed on
  default: your host and reload your VM.
  default:
  default: Guest Additions Version: 5.0.26
  default: VirtualBox Version: 5.1

In my case updating VirtualBox to the newest version fixed the issue.

Alternatively you can make sure the correct Guest Addition version is installed using vbguest Vagrant plugin on your host machine:

vagrant plugin install vagrant-vbguest
Tomas Liubinas
  • 181
  • 2
  • 7
  • This does not solve the problem. I install `vagrant-vbguest` before vagrant up with ansible and I get the error. – nbro Apr 05 '22 at 11:40
1

TL;DR - Check to make sure all your entries in /etc/exports point to folders that exist. If you've removed or renamed any folders that had previously been configured as NFS shares, it can cause all future attempts to start NFS sharing between host and client VM to fail.

This thread is still a top result for this error on search results, and there's another possible underlying cause - failed mounts in your /etc/exports

The NFS server will read /etc/exports for its list of mounts, and if a entry configured therein is no longer valid (e.g., you moved/renamed/deleted a folder) it will cause the nfs server to fail to start. The commands will differ depending on your OS, but if you check the status of the NFS server you might find that NFS failed to start because of a configuration issue in /etc/exports.

Daniel L
  • 614
  • 6
  • 7
0

Downgrading and changing the base image to be an LTS Ubuntu (as opposed to XUbuntu) seemed to fix this.

0

As described here, sometimes this happen when you don't have nfs-server installed in your linux distro. here explains how to install it according with your distro. This works for me today. o/

Matheus Porto
  • 169
  • 1
  • 5
0

I solved this problem by changing last number in IP of virtual machine higher than 1. ex(192.168.10.1->not work, 192.168.10.2->work)

Alen Verk
  • 1
  • 1