Score:1

Vagrant NFS share no longer working

td flag

The following Vagrantfile used to work, and now it doesn't.

This is an Ubuntu 20.04 install, and I'm using Virtualbox.

Vagrant.configure('2') do |config|
  # Set Box
  config.vm.box = "generic/ubuntu2004"
  # Set hostname
  config.vm.hostname = "xxx"
  config.vm.define "xxx"
  config.vm.provider :virtualbox do |vb|
    vb.name = "xxx"
  end

  # Prevent vagrant-vbguests from being auto updated, this is time consuming and causes version mismatch with host
  if Vagrant.has_plugin? "vagrant-vbguest"
    config.vbguest.no_install  = false
    config.vbguest.auto_update = false
    config.vbguest.no_remote   = true
  end

  # Enable vagrant-bindfs support, if the plugin is installed
  # see https://github.com/gael-ian/vagrant-bindfs for details
  if Vagrant.has_plugin?("vagrant-bindfs")
    # The bindfs option has one more option, and the /var/nfs
    # is where the the folder is synced then it binds it to the
    # guest_path after.
    #
    # Ubuntu 22.04 has UDP disabled for NFS mounts
    # https://discourse.ubuntu.com/t/jammy-jellyfish-release-notes/24668

    config.vm.synced_folder ".", "/var/nfs", type: "nfs", nfs_udp: false

    # This uses uid and gid of the user that started vagrant.
    config.nfs.map_uid = Process.uid
    config.nfs.map_gid = Process.gid

    config.bindfs.bind_folder "/var/nfs", "/vagrant",
      perms: 'u=rwX:g=rwD',
      u: 'vagrant',
      g: 'www-data',
      o: 'nonempty'
  else
    # Enable NFS file system
    config.vm.synced_folder ".", "/vagrant", type: "nfs",  nfs_udp: false

    # This uses uid and gid of the user that started vagrant.
    config.nfs.map_uid = Process.uid
    config.nfs.map_gid = Process.gid
  end

  # This uses the vagrant-disksize support, if the plugin is installed
  if Vagrant.has_plugin?("vagrant-disksize")
    config.disksize.size = '20GB'
  end

  # Configure RAM
  config.vm.provider "virtualbox" do |vb|
    # Customize the amount of memory on the VM:
    vb.memory = "4096"
    vb.cpus = 2
  end

  # Specify private network
  config.vm.network "private_network", ip: "192.168.56.10"
  # Port requires for postgres
  config.vm.network :forwarded_port, guest: 5432, host: 5432
  config.vm.network :forwarded_port, guest: 80, host: 8080

  # Enable provisioning with a shell script.
  # config.vm.provision :shell, :path => "local/bootstrap.sh"

end

The error I get is:

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.56.1:/home/steve/Projects/ze /var/nfs

Stdout from the command:

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

I always run vagrant destroy then vagrant up on each test. What I've done:

  • Allowed the vbguests to run and update
  • Tried NFS version 4
  • Tried it without NFS (it completes but the installation doesn't work)
  • Tried "192.168.56.1" as the host IP
  • Initially on Vagrant 2.3.4, upgraded to 2.3.7 (and tried everything again)
  • Tried to do the mount inside the VM, results typically this:
sudo mount -o vers=3 192.168.56.1:/home/steve/Projects/ze /var/nfs -v

mount.nfs: timeout set for Mon Jul  3 09:06:25 2023
mount.nfs: trying text-based options 'vers=3,addr=192.168.56.1'
mount.nfs: prog 100003, trying vers=3, prot=6
mount.nfs: portmap query retrying: RPC: Program not registered
mount.nfs: prog 100003, trying vers=3, prot=17
mount.nfs: portmap query failed: RPC: Program not registered
mount.nfs: requested NFS version or transport protocol is not supported

I'm losing the will to live, so any help would be appreciated.

NotTheDr01ds avatar
vn flag
With apologies on behalf of the community, it looks like your question was spammed by a trio of bots that is posting multiple AI-generated answers on questions. Unfortunately, the majority of the Moderators on Stack Exchange sites (including Ask Ubuntu) are on strike *primarily* because the parent company has reduced their ability to remove these bogus answers. We're hoping that things get back to normal shortly, but in the meantime, we're having to deal with stuff like this.
Score:1
td flag

OK.

I eventually discovered (using nmap) that NFS was not running on the host machine, and that was because there was an entry in /etc/exports linked to a directory that no longer existed, so NFS initialisation failed.

Details of that found using systemctl status nfs-server

That meant that when trying to mount the NFS shared folders, the connection was refused and the mount failed.

The first clue in the trail found when I tried to do a mount with vers=4 which included the "refused" error message.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.