Trying to get NFS working but I can't even connect from localhost

I’m trying to get Network File System working on my nixos box. Here is the relevant configuration:

  fileSystems."/export/sea5" = {
    device = "/mnt/sea5";
    options = [ "bind" ];
  };

  services.nfs.server.enable = true;
  services.nfs.server.exports = ''
    /export      192.168.1.*(rw,fsid=0,no_subtree_check) 
    /export/sea5 192.168.1.*(rw,nohide,insecure,no_subtree_check)
  '';

I’ve also opened port 2049:

  networking.firewall.allowedTCPPorts = [ 
    4000
    4001
    4002
    4003
    2049
  ];

The /export/sea5 correctly binds:

[tbrowne@bee:~]$ ls -lh /export/sea5
total 0
drwxr-xr-x 1 tbrowne users 62 Jun 24  2024 compare_trace
drwxr-xr-x 1 tbrowne users 48 Dec 18 20:02 data
drwx------ 1 tbrowne users 76 Sep  4 13:23 Dropbox-Personal
drwxr-xr-x 1 tbrowne users 26 Sep 20 01:07 dumps
drwxr-xr-x 1 tbrowne users  0 Jan 14 08:29 scratch

it’s no owner and no group for both /export and /export/sea5:

[tbrowne@bee:/]$ ls -lh /export
total 16K
drwxr-xr-x 1 nobody nogroup 90 Jan 11 08:16 sea5

[tbrowne@bee:/]$ ls -lh /
total 8.0K
drwxr-xr-x   1 root   root       4 Jan 18 22:40 bin
drwxr-xr-x   4 root   root    8.0K Jan  1  1970 boot
drwxr-xr-x  19 root   root    3.4K Jan 18 22:40 dev
drwxr-xr-x   1 root   root    1.2K Jan 18 22:40 etc
drwxr-xr-x   1 nobody nogroup    8 Jan 16 11:43 export
drwxr-xr-x   1 root   root      14 May  2  2024 home
drwxr-xr-x   1 root   root      26 Jan  9 23:42 lib
drwxr-xr-x   1 root   root      40 Jan  9 23:42 lib64
drwxrwxrwx   1 root   root      16 Jul  7  2024 mnt
drwxr-xr-x   1 root   root      16 May  2  2024 nix
dr-xr-xr-x 241 root   root       0 Jan 18 22:39 proc
drwx------   1 root   root     116 May 19  2024 root
drwxr-xr-x  24 root   root     660 Jan 18 23:09 run
drwxr-xr-x   1 root   root       0 May  2  2024 srv
dr-xr-xr-x  13 root   root       0 Jan 18 23:14 sys
drwxrwxrwt   1 root   root    3.1K Jan 18 23:00 tmp
drwxr-xr-x   1 root   root       6 May  2  2024 usr
drwxr-xr-x   1 root   root      82 May  2  2024 var

yet:

[tbrowne@bee:/]$ sudo mount -t nfs localhost:/export/sea5 /home/tbrowne/scratch/sea5
[sudo] password for tbrowne:
mount.nfs: access denied by server while mounting localhost:/export/sea5

(yes /home/tbrowne/scratch/sea5 does exist):

[tbrowne@bee:~/scratch/sea5]$ pwd
/home/tbrowne/scratch/sea5

What’s going wrong?

if you try to mount using your local ip address instead of the localhost alias, does it work? e.g. mount -t nfs 192.168.1.x?

I dont know much about setting up nfs, but I have ran into that kind of issue before

sudo mount -t nfs 192.168.1.82:/export/sea5 /home/tbrowne/scratch/sea5
mount.nfs: access denied by server while mounting 192.168.1.82:/export/sea5

No that does not make a difference.

Here’s my working configuration to share to 192.168.122.0 (qemu / kvm VMs):

NFS server

services.nfs.server = {
enable = true;
# fixed rpc.statd port; for firewall
lockdPort = 4001;
mountdPort = 4002;
statdPort = 4000;
extraNfsdConfig = ‘’‘’;
};
services.nfs.server.exports = ‘’
/home/xxxxx/VM_Share 192.168.122.0/24(rw,no_subtree_check,fsid=0,no_root_squash)
‘’;
services.nfs.server.createMountPoints = true;
networking.firewall = {
enable = true;
# for NFSv3; view with rpcinfo -p
allowedTCPPorts = [ 111 2049 4000 4001 4002 20048 ];
allowedUDPPorts = [ 111 2049 4000 4001 4002 20048 ];
};

Excellent that works.

I think it was my failure to open 111 and 20048.

I can now connect from other Linux machines and also from my mac (though mac requires resvport) like this:

sudo mount -t nfs -o resvport 192.168.1.82:/mnt/sea5 /Users/mmai/mnt/sea5