user156888
user156888

Reputation:

Using NFS with vagrant doesn't work

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

Upvotes: 9

Views: 12897

Answers (7)

Alen Verk
Alen Verk

Reputation: 1

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)

Upvotes: 0

Matheus Porto
Matheus Porto

Reputation: 179

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/

Upvotes: 0

Daniel L
Daniel L

Reputation: 632

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.

Upvotes: 1

Andre Leon Rangel
Andre Leon Rangel

Reputation: 1799

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

Upvotes: 3

Tomas Liubinas
Tomas Liubinas

Reputation: 300

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

Upvotes: 1

Oleksandr Fedorov
Oleksandr Fedorov

Reputation: 1271

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

Upvotes: 7

user156888
user156888

Reputation:

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

Upvotes: 0

Related Questions