Setting up an nfs share

Thanks. Tried that. Still the same error.

This seems to have slipped into the bin of never-to-be-solved issues,

Not sure what the protocol is on dead threads, but for what it’s worth…

I upgraded the Kernel to 5.10 and now showmount -e shows the mounts on the client and showmount -e (server ip} shows the mounts on the client…

…but still nothing’s working. mount -t nfs {server ip}:/srv/nfs/music /external/music just hangs for ages before reporting ‘mount.nfs: connection refused’, mount -a reports no errors at all, just does nothing (the mount is all set up in my fstab, so it should either mount or error - not nothing, surely)

interestingly mount -t nfs desk:/srv/nfs/music /external/music (where ‘desk’ is the server name) reports ‘mount.nfs: Failed to resolve server desk: Name or service not known’ despite both /etc/hostname file reading desk and /etc/hosts having a {server ip} desk line

I use nfs to mount directories on my raspberrypi.
FTR, I use autofs to automount the nfs share, so when I cd /net/raspberrypi2/ it just works for example findmnt shows

....
....
  └─/net/raspberrypi2/export                -hosts             autofs          rw,relatime,fd=11,pgrp=2280,timeout=300,minproto=5,maxproto=5,offset,pipe_ino=25112
    └─/net/raspberrypi2/export              raspberrypi2:/export
                                                               nfs             rw,nosuid,nodev,relatime,vers=3,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,tim
      ├─/net/raspberrypi2/export/media      -hosts             autofs          rw,relatime,fd=11,pgrp=2280,timeout=300,minproto=5,maxproto=5,offset,pipe_ino=25112
      ├─/net/raspberrypi2/export/music      -hosts             autofs          rw,relatime,fd=11,pgrp=2280,timeout=300,minproto=5,maxproto=5,offset,pipe_ino=25112
      └─/net/raspberrypi2/export/users      -hosts             autofs          rw,relatime,fd=11,pgrp=2280,timeout=300,minproto=5,maxproto=5,offset,pipe_ino=25112

Anyways, I do have two boxes running endeavourOS and I wanted to export one of the partitions over nfs, this is what I worked for me

sudo pacman -S nfs-utils
sudo mkdir -p /srv/nfs/sdb4
sudo mount --bind /sd/b4 /srv/nfs/sdb4
sudo vim /etc/exports
sudo exportfs -arv
systemctl enable nfs-server.service
systemctl start nfs-server.service

then

$ rpcinfo -p | grep nfs
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    3   tcp   2049  nfs_acl

/etc/exports looks like this

$ cat exports
# /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        192.168.173.0/24(rw,sync,crossmnt)
/srv/nfs/sdb4   192.168.173.0/24(rw,sync)

The box I’m exporting from is Precision-Tower-5810 ip address set in /etc/hosts
The automount worked, and on the other box findmnt shows

...
...
└─/net                                      -hosts             autofs          rw,relatime,fd=11,pgrp=2280,timeout=300,minproto=5,maxproto=5,indirect,pipe_ino=25112
  ├─/net/Precision-Tower-5810/srv/nfs -hosts             autofs          rw,relatime,fd=11,pgrp=2280,timeout=300,minproto=5,maxproto=5,offset,pipe_ino=25112
  │ └─/net/Precision-Tower-5810/srv/nfs
  │                                         Precision-Tower-5810:/srv/nfs
  │                                                            nfs4            rw,nosuid,nodev,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp
  │   └─/net/Precision-Tower-5810/srv/nfs/sdb4
  │                                         -hosts             autofs          rw,relatime,fd=11,pgrp=2280,timeout=300,minproto=5,maxproto=5,offset,pipe_ino=25112
  │     └─/net/Precision-Tower-5810/srv/nfs/sdb4
  │                                         Precision-Tower-5810:/srv/nfs/sdb4
  │                                                            nfs4            rw,nosuid,nodev,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp
  └─/net/raspberrypi2/export                -hosts             autofs          rw,relatime,fd=11,pgrp=2280,timeout=300,minproto=5,maxproto=5,offset,pipe_ino=25112
...
...

So with arch the protocol version is NFSv4
I tried to include as much detail as possible, hopefully this isn’t just another works for me example :frowning:

2 Likes

Looks good! Bookmarked for my future reference. Thanks! :slightly_smiling_face:

Thanks.

Followed your set up to the letter (only with changes to names, obviously).

rpcinfo -p | grep nfs gives me nothing at all

rpcinfo -p lists all the ports I’d expect, but no nfs

Any ideas?

Whats does systemctl status nfs-server.service show?
I see something like this

$ 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 Mon 2021-12-27 11:30:50 GMT; 1min 24s ago
    Process: 1699 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
    Process: 1702 ExecStart=/usr/sbin/rpc.nfsd (code=exited, status=0/SUCCESS)
   Main PID: 1702 (code=exited, status=0/SUCCESS)
        CPU: 7ms

Dec 27 11:30:49 bdias-precisiontower5810 systemd[1]: Starting NFS server and services...
Dec 27 11:30:49 bdias-precisiontower5810 exportfs[1699]: exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.173.>
Dec 27 11:30:49 bdias-precisiontower5810 exportfs[1699]:   Assuming default behaviour ('no_subtree_check').
Dec 27 11:30:49 bdias-precisiontower5810 exportfs[1699]:   NOTE: this default has changed since nfs-utils version 1.0.x
Dec 27 11:30:49 bdias-precisiontower5810 exportfs[1699]: exportfs: /etc/exports [2]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.173.>
Dec 27 11:30:49 bdias-precisiontower5810 exportfs[1699]:   Assuming default behaviour ('no_subtree_check').
Dec 27 11:30:49 bdias-precisiontower5810 exportfs[1699]:   NOTE: this default has changed since nfs-utils version 1.0.x
Dec 27 11:30:50 bdias-precisiontower5810 systemd[1]: Finished NFS server and services.
`
$ rpcinfo -p | grep nfs
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    3   tcp   2049  nfs_acl
$ 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 Mon 2021-12-27 06:33:24 GMT; 5h 2min ago
   Main PID: 1459 (code=exited, status=0/SUCCESS)
        CPU: 7ms

Dec 27 06:33:24 desk exportfs[1458]:   Assuming default behaviour ('no_subtree_check').
Dec 27 06:33:24 desk exportfs[1458]:   NOTE: this default has changed since nfs-utils version 1.0.x
Dec 27 06:33:24 desk exportfs[1458]: exportfs: /etc/exports [2]: Neither 'subtree_check' or 'no_subtree_check' specified for export>
Dec 27 06:33:24 desk exportfs[1458]:   Assuming default behaviour ('no_subtree_check').
Dec 27 06:33:24 desk exportfs[1458]:   NOTE: this default has changed since nfs-utils version 1.0.x
Dec 27 06:33:24 desk exportfs[1458]: exportfs: /etc/exports [2]: Neither 'subtree_check' or 'no_subtree_check' specified for export>
Dec 27 06:33:24 desk exportfs[1458]:   Assuming default behaviour ('no_subtree_check').
Dec 27 06:33:24 desk exportfs[1458]:   NOTE: this default has changed since nfs-utils version 1.0.x
Dec 27 06:33:24 desk rpc.nfsd[1459]: rpc.nfsd: unable to bind AF_INET TCP socket: errno 99 (Cannot assign requested address)
Dec 27 06:33:24 desk systemd[1]: Finished NFS server and services.

I can spot the difference, but I’ve no idea what it means

rpc.nfsd[1459]: rpc.nfsd: unable to bind AF_INET TCP socket: errno 99 (Cannot assign requested address)

Not sure, but maybe some other service is bound to port 2049?
on the endeavourOS box running the NFS server, I see

$ sudo netstat -lnp | grep -w 2049
tcp        0      0 0.0.0.0:2049            0.0.0.0:*               LISTEN      -                   
tcp6       0      0 :::2049                 :::*                    LISTEN      -  

On endeavourOS not running NFS server, I get no hits for the same command.

Yep, I get nothing - on the machine that’s supposed to be running the nfs server. So nothing’s on 2049?

I’m afraid this is now a case of the blind leading the blind :frowning_face:
Googling, the top hit was this https://www.reddit.com/r/linuxquestions/comments/gt1xs3/nfsserver_not_starting/
Is that relevant in your case?
Are you using a firewall?

You’ve been a great help, I appreciate it - at least I’ve got something more to go on now. I’ll have a look at the thread you’ve linked tomorrow and see if it leads on anywhere, but no, no firewall.

Thanks again for your help.

It just worked for me, which conversely meant I didn’t learn anything new :roll_eyes:
Keep us posted if you do find a solution.
I’m assuming you’ve tried restarting the nfs server/ rebooted

Sorry, I have been away for really long time … :roll_eyes:
I found something interesting, what might help you:
On the following page “Troubleshooting common NFS issues in Linux” the author writes:

This is caused by DNS name resolution issue. NFS(RPC) needs reverse name resolution. If NFS server or client cannot resolve their name, this error occurs. In case gets the error message, check DNS configuration and /etc/hosts configuration.

Do you have any DNS configuration?
It may be possible just to add the two machines in hosts file and reboot and try again?