Setting up an nfs share

I’m trying to set up an nfs share as per https://wiki.archlinux.org/title/NFS

I’ve followed it exactly (making /srv/nfs/ and bind mounts, /etc/exports is as specified - except I’ve used a single ip instead of a range)

I’ve got as far as

Manual mounting
For NFSv3 use this command to show the server’s exported file systems:
$ showmount -e servername

Instead of the exported share, I get
rpc mount export: RPC: unable to receive; errno = Connection refused

It’s not listed in https://wiki.archlinux.org/title/NFS/Troubleshooting. A Google search gives issues such as Firewalls (I have no rules according to iptables -L), permissions (but /srv/nfs is drwxr-xr-x) and portmapper restrictions (but I have no portmapper).

So I’m stuck. Any help would be much appreciated.

Did you replace servername with the actual servername you are trying to connect to?

Yes

Are you running a firewall on the server? Are their any barriers between the server and the client?

No, I don’t think so. I’ve run iptables -L on both server and client and it reads (policy ACCEPT) for INPUT, FORWARD, and OUTPUT and no other policies. Running ufw status gives ‘inactive’.

I do have a setup here with one NFS server and several PCs that use one or more of the NFS shares mounted via fstab.
Looking at those links you mentioned some questions from my side:

  1. On the NFS server did you use something like /mnt/music /srv/nfs/music none bind 0 0 to bind the directory/directories you want to export via /srv/nfs?
  2. Does your /etc/exports does contain /srv/nfs too?
  3. Did you run exportfs -arv before starting and enabling nfs-server.service?
2 Likes

Almost exactly that as it happens, the music folder is not at /mnt, it’s further within the filesystem, but apart from that, it’s basically what I’ve got.

Yes, it’s (xxx.xxx.x.xx being the client ip)

/srv/nfs xxx.xxx.x.xx(rw,sync,crossmnt,fsid=0)
/srv/nfs/music xxx.xxx.x.xx(rw,sync)

Yes. systemctl status nfs-server gives (among other things) Active: active (exited). Is ‘exited’ right?

OK, that’s good. Some years ago while switching from NFS3 to NFS4 this was my main fault. :roll_eyes:

I am using (rw,fsid=0,no_subtree_check,async) for the root export and (rw,nohide,no_subtree_check,async) for the real shares. But this should not be the cause of your problem.

It seems to be active.
Please run sudo systemctl restart nfs-server.service and then post the output of sudo systemctl status nfs-server.service. Maybe we can find some error messages that point to the root cause.

Thanks.

sudo systemctl status nfs-server.service
● nfs-server.service - NFS server and services
     Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled; vendor preset: disabled)
    Drop-In: /run/systemd/generator/nfs-server.service.d
             └─order-with-mounts.conf
     Active: active (exited) since Sun 2021-11-14 17:14:18 GMT; 16s ago
    Process: 11654 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
    Process: 11655 ExecStart=/usr/sbin/rpc.nfsd (code=exited, status=0/SUCCESS)
   Main PID: 11655 (code=exited, status=0/SUCCESS)
        CPU: 10ms

Nov 14 17:14:18 desk exportfs[11654]: exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export...
Nov 14 17:14:18 desk exportfs[11654]:   Assuming default behaviour ('no_subtree_check').
Nov 14 17:14:18 desk exportfs[11654]:   NOTE: this default has changed since nfs-utils version 1.0.x
Nov 14 17:14:18 desk exportfs[11654]: exportfs: /etc/exports [2]: Neither 'subtree_check' or 'no_subtree_check' specified for export...
Nov 14 17:14:18 desk exportfs[11654]:   Assuming default behaviour ('no_subtree_check').
Nov 14 17:14:18 desk exportfs[11654]:   NOTE: this default has changed since nfs-utils version 1.0.x
Nov 14 17:14:18 desk exportfs[11654]: exportfs: /etc/exports [2]: Neither 'subtree_check' or 'no_subtree_check' specified for export...
Nov 14 17:14:18 desk exportfs[11654]:   Assuming default behaviour ('no_subtree_check').
Nov 14 17:14:18 desk exportfs[11654]:   NOTE: this default has changed since nfs-utils version 1.0.x
Nov 14 17:14:18 desk systemd[1]: Finished NFS server and services.

I’ve left off the client ips of the exports it’s referencing (probably excessive security but…)

I am confused by those messages. It seems to me that there is something wrong in your exports.
Please run journalctl -b -0 -u nfs-server.service and post the output here.

That’s OK.

Not giving me much more than the service status I’m afraid…

-- Journal begins at Thu 2020-10-08 07:20:47 BST, ends at Sun 2021-11-14 17:33:27 GMT. --
Nov 14 17:14:18 desk systemd[1]: Stopping NFS server and services...
Nov 14 17:14:18 desk systemd[1]: nfs-server.service: Deactivated successfully.
Nov 14 17:14:18 desk systemd[1]: Stopped NFS server and services.
Nov 14 17:14:18 desk systemd[1]: Starting NFS server and services...
Nov 14 17:14:18 desk exportfs[11654]: exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "xxx.xxx.x.xx:/srv/nfs".
Nov 14 17:14:18 desk exportfs[11654]:   Assuming default behaviour ('no_subtree_check').
Nov 14 17:14:18 desk exportfs[11654]:   NOTE: this default has changed since nfs-utils version 1.0.x
Nov 14 17:14:18 desk exportfs[11654]: exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "xxx.xxx.x.xa:/srv/nfs".
Nov 14 17:14:18 desk exportfs[11654]:   Assuming default behaviour ('no_subtree_check').
Nov 14 17:14:18 desk exportfs[11654]:   NOTE: this default has changed since nfs-utils version 1.0.x
Nov 14 17:14:18 desk exportfs[11654]: exportfs: /etc/exports [2]: Neither 'subtree_check' or 'no_subtree_check' specified for export "xxx.xxx.x.xx:/srv/nfs/music".
Nov 14 17:14:18 desk exportfs[11654]:   Assuming default behaviour ('no_subtree_check').
Nov 14 17:14:18 desk exportfs[11654]:   NOTE: this default has changed since nfs-utils version 1.0.x
Nov 14 17:14:18 desk exportfs[11654]: exportfs: /etc/exports [2]: Neither 'subtree_check' or 'no_subtree_check' specified for export "xxx.xxx.x.xa:/srv/nfs/music".
Nov 14 17:14:18 desk exportfs[11654]:   Assuming default behaviour ('no_subtree_check').
Nov 14 17:14:18 desk exportfs[11654]:   NOTE: this default has changed since nfs-utils version 1.0.x
Nov 14 17:14:18 desk systemd[1]: Finished NFS server and services.

Can you please post your /etc/exports (anonymized, if you want) and inside /etc please run ls -la exports* and post this output. I am trying to find out if your exports is configured right.

# /etc/exports - exports(5) - directories exported to NFS clients
#
# Example for NFSv2 and NFSv3:
#  /srv/home        hostname1(rw,sync) hostname2(ro,sync)
# Example for NFSv4:
#  /srv/nfs4	    hostname1(rw,sync,fsid=0)
#  /srv/nfs4/home   hostname1(rw,sync,nohide)
# Using Kerberos and integrity checking:
#  /srv/nfs4        *(rw,sync,sec=krb5i,fsid=0)
#  /srv/nfs4/home   *(rw,sync,sec=krb5i,nohide)
#
# Use `exportfs -arv` to reload.
/srv/nfs xxx.xxx.x.xx(rw,sync,crossmnt,fsid=0) xxx.xxx.x.xa(rw,sync,crossmnt,fsid=0)
/srv/nfs/music xxx.xxx.x.xx(rw,sync) xxx.xxx.x.xa(rw,sync)

xxx.xxx.x.xx and xxx.xxx.x.xa are two clients - I’ve check the ips, I can ping both.

ls -la exports*
-rw-r--r-- 1 root root  583 Nov 14 12:43 exports
-rw-r--r-- 1 root root  523 Nov 14 11:17 exports~

exports.d:
total 20
drwxr-xr-x   2 root root  4096 Sep  7  2018 .
drwxr-xr-x 116 root root 12288 Nov 14 12:43 ..

If not obvious, ‘exports~’ is a backup from using nano -B to edit

That looks fine. I would have configured it a little bit different (see above), but this is not the root cause.

No, that’s not a problem. I just wanted to check if there is another exports file that might cause the trouble.
Can you please post the section [nfsd] from your nfs.conf? Maybe you do not have the right NFS versions configured.

[nfsd]
# debug=0
# threads=8
# host=
# port=0
# grace-time=90
# lease-time=90
# udp=n
# tcp=y
# vers2=n
# vers3=y
# vers4=y
# vers4.0=y
# vers4.1=y
# vers4.2=y
rdma=y
rdma-port=20049

There a lot of commented out lines there…?

Try following:

[nfsd]
threads=8
host=<IP-Address>
vers2=n
vers3=y
vers4=y
vers4.0=y
vers4.1=y
vers4.2=y
rdma=y
rdma-port=20049

Maybe the NFS server is not bound to the IP-address you tried with showmount?

Tried as you suggested, but still getting the same error. I went ahead and tried to mount the export anyway just with mount, but it came back ‘Connection refused’.

??

Did you restart the NFS server after changing nfs.conf? Sorry, I forgot to mention this above.
Does showmount -e <IP-Address> show the same error as showmount -e servername?

Think so, I ran sudo systemctl restart nfs-server.service, then sudo exportfs -arv, still the same error.

Then I just rebooted both server and client, to be on the safe side, same error.

I don’t have a servername set up for the server, I’m just using IPs (in other words, using any servername just comes up ‘unknown host’)

First export then service restart