Vagrant up fails on mounting NFS shard folders


#1

I am experiencing an issue that has come up before here in the forums, but I feel like I’ve tried every possible suggested solution - both here on the discourse, github and stack overflow - but to no avail.

My setup:

macOS Sierra (10.12.2)
Vagrant 1.9.1
Ansible 2.2.0.0

I’ve followed every step of the guide here in the Trellis docs, and when I vagrant up I receive the following error:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o vers=3 192.168.50.1:/Users/username/Dev/example.com/site /vagrant-nfs-example.com
result=$?
if test $result -eq 0; then
if test -x /sbin/initctl && command -v /sbin/init && /sbin/init 2>/dev/null --version | grep upstart; then
/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=/vagrant-nfs-example.com
fi
else
exit $result
fi

Stdout from the command:

Stderr from the command:

mount.nfs: requested NFS version or transport protocol is not supported

I should mention that I have been able to vagrant up before without this issue and as far as I know I haven’t updated my os or anything.

Any help or tips would be greatly appreciated!

Thanks


#2

Is your home directory encrypted?

Encrypted folders: If you have an encrypted disk, then NFS very often will refuse to export the filesystem. The error message given by NFS is often not clear. One error message seen is does not support NFS. There is no workaround for this other than sharing a directory which is not encrypted.

via https://www.vagrantup.com/docs/synced-folders/nfs.html


#3

Here are a few more ideas that came to mind:


#4

What is considered an “invalid entry”?


#5

I mean an entry that doesn’t make sense. Most common might be an entry with sync dirs for a machine that no longer exists. I imagine these could be left behind if you destroy a VM via the VirtualBox GUI instead of via the vagrant CLI.

# /etc/exports

# If the example.com VM no longer exists, the entry below could cause problems in the future...

# VAGRANT-BEGIN: 501 300...some_id
"/Users/philip/projects/roots/example.com/trellis" 192.168.50.5 -alldirs -mapall=501:20
"/Users/philip/projects/roots/example.com/site" 192.168.50.5 -alldirs -mapall=501:20
# VAGRANT-END: 501 300...some_id

Entries could also be problematic if somehow their paths were incorrect (a less likely scenario).


#6

I woke up today and “up’ed” a vagrant box only to run into errors immediately. Literally been trying to fix this since 9am this morning.

Anyways, I’ve got to this point and can’t get past it:

After:

==> default: Mounting NFS shared folders…

I get this error:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o vers=3,udp 192.168.50.1:/Volumes/LaCie/_development/_trellis/trellis.xxx.dev/site /vagrant-nfs-xxx.com

Stdout from the command:

Stderr from the command:

mount.nfs: requested NFS version or transport protocol is not supported


#7

Have you tried any of the suggestions in this thread?


#8

Yes, everything. I’ve tried everything in this thread and everything else outside of this thread.


#9

If you’ve tried everything then I’m not sure what else I could add


#10

Ok, thanks though.

Maybe someone else will add something.


#11

Just in case anyone runs into this issue, this may solve it for you as it solved it for me.

127.0.0.1 localhost in /etc/hosts somehow was removed since yesterday and adding that back has allowed me to vagrant up again.


Vagrant NFS problem
#12

@joshb thanks for reporting this diagnosis and solution. I’m not sure how localhost could be removed from your /etc/hosts but the problem and solution is consistent with this prior report:


#13

Thanks for the positive response. I’m not sure either as I was working on projects yesterday with no delay.


#14

Hi, i was facing the same problem and, as you, nothing seemed to work.

spent the last week trying to figure out why, and finally found the solution that worked for me:

ended with:

if !Vagrant.has_plugin? 'vagrant-bindfs'
      fail_with_message "vagrant-bindfs missing, please install the plugin with this command:\nvagrant plugin install vagrant-bindfs"
    else
      wordpress_sites.each_pair do |name, site|
        config.vm.synced_folder local_site_path(site), nfs_path(name), type: 'nfs', nfs_version: 4, nfs_udp: false
        config.bindfs.bind_folder nfs_path(name), remote_site_path(name, site), u: 'vagrant', g: 'www-data', o: 'nonempty'
      end
      config.vm.synced_folder ANSIBLE_PATH, '/ansible-nfs', type: 'nfs', nfs_version: 4, nfs_udp: false
      config.bindfs.bind_folder '/ansible-nfs', ANSIBLE_PATH_ON_VM, o: 'nonempty', p: '0644,a+D'
      config.bindfs.bind_folder bin_path, bin_path, perms: '0755'
    end

so the original lines were:

L87:

config.vm.synced_folder local_site_path(site), nfs_path(name), type: 'nfs'

replace it with:

config.vm.synced_folder local_site_path(site), nfs_path(name), type: 'nfs', nfs_version: 4, nfs_udp: false

L90:

config.vm.synced_folder ANSIBLE_PATH, '/ansible-nfs', type: 'nfs'

replace it:

config.vm.synced_folder ANSIBLE_PATH, '/ansible-nfs', type: 'nfs', nfs_version: 4, nfs_udp: false

the key thing here is adding , nfs_version: 4, nfs_udp: false


#15

I’ve tried your suggestion and something changed (still not working as supposed), here is my error now:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o vers=4 192.168.50.1:/home/xxx/Trellis/xxx/site /vagrant-nfs-xxx

Stdout from the command:



Stderr from the command:

mount.nfs: access denied by server while mounting 192.168.50.1:/home/xxx/Trellis/xxx/site

I’m using antergOS (arch) and can’t get vagrant up running. I’ve tried all of above methods and nothing seems to work.

Edit: I’ve changed nfs version to 3 and leave udp: false and now it’s working.


#16

Work for me too.

Thank you :slight_smile:


#17

I had the same issue, since I had upgraded from Ubuntu 16.04 to 18.04, but changing the nfs version( in the Vagrantfile) didn’t solve it …

Checking the status of my nfs server (sudo systemctl status nfs-server.service) I discovered that I had a line from an older trellis site creating problems
exportfs: Failed to stat /home/ben/Code/mytestsite.test: No such file or directory

So all I needed to do was to clean the /etc/export file of the culprit lines pointing to that non existing directory

sudo vi /etc/export