Vagrant up throws error

I’m trying to set up Trellis for the first time to try it out. It was hanging when mounting nfs until I disabled my firewall. I’ve been searching for a few days and can’t find any info on setting up UFW for
Trellis. That’s the first issue.

Next, when I run vagrant up with the firewall disabled I get the following error:

==> 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 192.168.56.1:/home/mark/Dev/Trellis/learn-trellis/site /vagrant-nfs-example.com

Stdout from the command:



Stderr from the command:

mount.nfs: an incorrect mount option was spec

I found a similar issue here:

But, following those directions changed nothing and I’m still getting the same error.

Can anyone point a newbie to Trellis to a solution for this?

I’m using Kubuntu 22.04 for my host machine. Virtualbox for the VM. I’m not sure what else you’d need to know so let me know please.

Here’s my vagrant.default.yml

---
vagrant_ip: "192.168.56.5"
vagrant_cpus: 1
vagrant_memory: 1024 # in MB
vagrant_box: "bento/ubuntu-22.04"
vagrant_box_version: ">= 0"
vagrant_box_auto_arch: true
vagrant_ansible_version: "2.10.7"
vagrant_skip_galaxy: false
vagrant_mount_type: "nfs"
vagrant_require_version: ">= 2.1.0"

vagrant_install_plugins: true
vagrant_plugins:
  - name: vagrant-bindfs
  - name: vagrant-hostmanager

# Array of synced folders:
vagrant_synced_folders:
  - local_path: ../test
    destination: /test
    create: false
    type: nfs
    bindfs: true
    mount_options: ["uid=1000", "gid=33"]
    bindfs_options:
      o: "nonempty"
      p: "0644,a+D"
      u: "vagrant"
      g: "www-data"
# See https://www.vagrantup.com/docs/synced-folders/basic_usage.html#mount_options
#vagrant_synced_folders: []

1 Like

This is how I get synced folders to work:

vagrant_synced_folders:

  - local_path: "/Volumes/some-folder-outside-website"
    destination: /srv/www/name-this-whatever
    create: true
    type: nfs
    bindfs: true
    mount_options: []
    bindfs_options:
      o: 'nonempty'
      p: '0644,a+D'
      u: 'vagrant'
      g: 'www-data'
2 Likes

Thank you. But, it didn’t change anything. Here’s the new config:

---
vagrant_ip: '192.168.56.5'
vagrant_cpus: 1
vagrant_memory: 1024 # in MB
vagrant_box: 'bento/ubuntu-22.04'
vagrant_box_version: '>= 0'
vagrant_box_auto_arch: true
vagrant_ansible_version: '2.10.7'
vagrant_skip_galaxy: false
vagrant_mount_type: 'nfs'
vagrant_require_version: '>= 2.1.0'

vagrant_install_plugins: true
vagrant_plugins:
  - name: vagrant-bindfs
  - name: vagrant-hostmanager

  # Array of synced folders:

vagrant_synced_folders:

  - local_path: .
    destination: /srv/www/public
    create: true
    type: nfs
    bindfs: true
    mount_options: []
    bindfs_options:
      o: 'nonempty'
      p: '0644,a+D'
      u: 'vagrant'
      g: 'www-data'
# See https://www.vagrantup.com/docs/synced-folders/basic_usage.html#mount_options


Same error as above. I tried vagrant ssh and then I tried running the failed command on the client. It complained, mount.nfs: failed to apply fstab options

I tried running it with sudo and it just hangs and leaves a blinking cursor until finally, mount.nfs: Connection timed out

Installed the plugins vagrant-bindfs and vagrant-hostmanager. Still the same error.

I seem to have gotten the firewall setup though. But, still that error.

This is what Trellis uses as synced folder options:

So one or some of the options is not supported by your system/workstation.

The extra mount options that are merged there should not be the reason as you have already adjusted your Trellis configuration.

Ok. I’m trying to figure out what that means and drawing a blank. Why would options not be supported by an operating system with which these tools were designed to work? Namely ubuntu.

Am I being punished for not using Windows for my workstation?

My two cents here: Kubuntu 22.04 that you are using may have a different NFS server than mainline Ubuntu 22, hence issues with the NFS related configuration.

Are you using the latest Vagrant? What NFS server package?

1 Like

Thanks for your input.

Vagrant 2.3.4

For the NFS server I went here: How to Install and Configure an NFS Server on Ubuntu 22.04
It had me install it with, sudo apt install nfs-kernel-server

I looked up how to get the version and they say to run nfsstat -c which gave me:
Error: No Client Stats (/proc/net/rpc/nfs: No such file or directory).

Sheesh. Why the heck isn’t it starting with the OS? Do I have to configure that? Do I have to run start the service every time?

So, I ran: sudo nfsd enable
And I got: sudo: nfsd: command not found

WTF?

Hm, what does sudo systemctl restart nfs-kernel-server do?

1 Like

I found this: https://www.howtoforge.com/how-to-install-nfs-server-and-client-on-ubuntu-22-04/

I ran: sudo systemctl is-enabled nfs-server
Then: sudo systemctl status nfs-server
It returned:

● nfs-server.service - NFS server and services
     Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor pr>
    Drop-In: /run/systemd/generator/nfs-server.service.d
             └─order-with-mounts.conf
     Active: active (exited) since Fri 2023-02-03 17:30:57 MST; 16h ago
    Process: 2998 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUC>
    Process: 3058 ExecStart=/usr/sbin/rpc.nfsd (code=exited, status=0/SUCCESS)
   Main PID: 3058 (code=exited, status=0/SUCCESS)
        CPU: 6ms

Feb 03 17:30:56 dt systemd[1]: Starting NFS server and services...
Feb 03 17:30:57 dt systemd[1]: Finished NFS server and services.

I’m trying vagrant destroy && vagrant up again

Ugh, it’s still hanging on Mounting NFS shared folders.

nfsstat -c still returns this error:
Error: No Client Stats (/proc/net/rpc/nfs: No such file or directory).

Hm, what does sudo systemctl restart nfs-kernel-server do?

That command runs without error. No output.

It finally finished trying again:

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.56.1:/home/mark/Dev/Trellis/learn-trellis/site /vagrant-nfs-example.com

Stdout from the command:



Stderr from the command:

mount.nfs: Connection timed out

Do I need to completely set up an NFS server on this machine for Trellis to work? I don’t know anything about NFS servers. I just wanted to try Trellis.

Do I need to completely set up NFS with the client on my host machine too? How is this even supposed to work?

Well, according to the Vagrant docs about NFS, you have to install the NFS server and enable NFS support, for VirtualBox a network adjustment is needed:

1 Like

OMG it says:

If you are using the VirtualBox provider, you will also need to make sure you have a private network set up. This is due to a limitation of VirtualBox’s built-in networking. With VMware, you do not need this.

That suggests to me that I should just switch to VMware. Is that a viable option for Trellis?

I suppose it wouldn’t mention it if it wasn’t. So, can I just uninstall virtualbox and install vmware and be done with these problems?

Trying to get virtualbox working, I added to the Vagrantfile:

 # https://developer.hashicorp.com/vagrant/docs/synced-folders/nfs#prerequisites
Vagrant.configure("2") do |config|
  config.vm.synced_folder ".", "/vagrant", type: "nfs"
end

Vagrant.configure("2") do |config|
  config.vm.network "private_network", type: "dhcp"
end

running vagrant destroy && vagrant up again

Still hanging on Mounting NFS shared folders.

Full system restart.

sudo systemctl stats nfs-server

● nfs-server.service - NFS server and services
     Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: en>
    Drop-In: /run/systemd/generator/nfs-server.service.d
             └─order-with-mounts.conf
     Active: active (exited) since Sat 2023-02-04 11:03:41 MST; 13min ago
    Process: 2960 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
    Process: 3016 ExecStart=/usr/sbin/rpc.nfsd (code=exited, status=0/SUCCESS)
   Main PID: 3016 (code=exited, status=0/SUCCESS)
        CPU: 6ms

Feb 04 11:03:41 dt systemd[1]: Starting NFS server and services...
Feb 04 11:03:41 dt systemd[1]: Finished NFS server and services.

Still hanging on Mounting NFS shared folders.

I tried vagrant ssh then /usr/local/etc/init.d/nfs-client start
It returned: -bash: /usr/local/etc/init.d/nfs-client: No such file or directory

I have no clue what any of this means.

I don’t know what I’m doing, but I tried sudo systemctl status nfs-common on the virtual machine and got:

○ nfs-common.service
     Loaded: masked (Reason: Unit nfs-common.service is masked.)
     Active: inactive (dead)

Is that a clue?

Then I found this: https://www.reddit.com/r/linux4noobs/comments/kxqmq5/nfs_server_stopped_working_no_idea_how_to_fix/

Tried(on virtual machine): sudo systemctl unmask nfs-common nfs-common.service
Then: sudo systemctl start nfs-common nfs-common.service

Result: Failed to start nfs-common.service: Unit nfs-common.service is masked.
LOL

Found this: https://askubuntu.com/questions/804946/systemctl-how-to-unmask

Tried the highest rated answer. It all worked and x11 installed where it hadn’t been there previously. But, when I try to run the failed command on the virtual machine I still get:
mount.nfs: Connection timed out

I noticed my mistake with the x11 thing and redid all the directions for nfs-common instead (on the client machine).

systemctl status nfs-common
Returns:

○ nfs-common.service
     Loaded: masked (Reason: Unit nfs-common.service is masked.)
     Active: inactive (dead)

Found this: https://developer.hashicorp.com/vagrant/docs/boxes/base#default-user-settings

Added this to end of config.
vagrant ALL=(ALL) NOPASSWD: ALL

Still ends up at mount.nfs: Connection timed out

Seriously, how the hell does anyone actually use this software for business when it’s so buggy?

I just noticed that every time I try to vagrant up it says this:

    default: SSH username: vagrant    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Installing NFS client...
==> default: Exporting NFS shared folders.
==> default: Preparing to edit /etc/exports. Administrator privileges will be required...
==> default: Mounting NFS shared folders...

Two things stand out. The first warning seems to say there’s something wrong with an SSH key.
The second thing is that it says “Administrator privileges will be required…” But then it never asks for a password. It just hangs on Mounting NFS folders.

Is it failing to ask for the password?

Sorry for the frustration and thanks for trying all this troubleshooting! NFS can be tricky on some hosts machines. It’s simple when it just “works”, but when it doesn’t it can be quite complex which makes supporting edge cases like this harder.

Since you’re on a Linux host, I’d also try using a different mount type to avoid NFS.

Try updating vagrant.default.yml (or creating a vagrant.local.yml file) with this setting:

vagrant_mount_type: virtualbox

(instead of nfs which is the default)

It should be simpler and you might see performance benefits too on Linux (ref: Default mount type and slow VM · Issue #1428 · roots/trellis · GitHub)

1 Like

It’s working! I seem to have been asking the wrong question. I didn’t even want to install nfs in the first place. But, every tutorial seems to lead to that.

Thank you very much swalkinshaw!!! Whew.

Note: had to completely remove nfs-kernel-server and nfs-common and reset the Vagrantfile and vagrant.default.yml to their default versions, except that one change.

I also kept:
vagrant ALL=(ALL) NOPASSWD: ALL

Hopefully that’s not terrible for security and will just make life easier.

3 Likes