Vagrant up fails on mounting NFS shared folders

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

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 NFS - Synced Folders | Vagrant | HashiCorp Developer

1 Like

Here are a few more ideas that came to mind:

What is considered an “invalid entry”?

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).

1 Like

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

Have you tried any of the suggestions in this thread?

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

1 Like

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

Ok, thanks though.

Maybe someone else will add something.

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.

3 Likes

@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:

1 Like

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

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

4 Likes

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.

3 Likes

Work for me too.

Thank you :slight_smile:

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

1 Like

FYI, I discovered that using using docker-machine + docker-machine-nfs (which also are powered by VirtualBox) will cause an NFS exports collision. The solution I found for now was to comment out the exports from docker-machine while using Trellis.

I ran into this issue again today. I spun up on older project and was met with the mounting NFS shared folders issue. Prior to spinning up the old project, I was working on a few other projects flawlessly.

Now that the old project spit the error, I’m having a really hard time getting my other projects running. Not every project, every time is doing it… but randomly I’m getting 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.project.build/site 
/vagrant-nfs-project.com

Stdout from the command:



Stderr from the command:

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

One thing I noticed is that my /etc/hosts file is using the same IP address (192.168.50.5) for each project I attempt to launch regardless of the IP address I’ve defined in the trellis hosts files for local development.

I’ve tried a lot of different fixes today that I’ve found here on this discourse and google with little luck.

The one thing I’ve come across multiple times is that iTerm needs to have Full Disk Access but when I visit my Sys Pref > Security & Privacy > Privacy, I do not even see that option in the window:

Sorry if this post is not descriptive enough. I’m really losing it today.

It turns out that somehow my Mac encountered Kernel Panic and had suffered from disk permissions. So far, after the fix, I’ve been able to boot up vagrant boxes just fine (without any NFS errors) but I still can’t get them to assign the correct IP I’ve given them in their vagrant host files. Loading my /etc/host files after booting up boxes show they’re all assigned the default IP that comes shipped with Trellis (192.168.50.5), although I’ve assigned others such as 192.168.50.44, 192,168,50,77, and 192.168.50.98.

The other thing I’m seeing is that 192.168.50.98 is actually returning 192.168.50.21 in /etc/hosts file after the machine boots up and is able to run concurrently with one of the other machines. As soon as I book up another machine, it returns 192.168.50.5 and overrides any other machine that is associated with that same IP of course.

I’ve tried ‘vagrant destroy’, then ‘vagrant up’.
I’ve tried ‘vagrant destroy’, then ‘vagrant up --provision’
I’ve tried ‘vagrant destroy’, then ‘vagrant reload --provision’

All of the above commands work without throwing errors but they do not assign the correct IP. This means I can only run one machine at a time and must halt other machines before moving on to another project. That’s fine but I prefer to have some of them operate concurrently.

If anyone has any suggestions, it would be much appreciated as usual.