Trouble mounting a local nfs server

I’m attempting to mount a local nfs server and I’m not sure what’s preventing it. Rebuilding the system doesn’t spit out an error, but the mount directory remains empty.

I have added an entry according to the wiki:

  fileSystems."/mnt/nfs" = {
    device = "";
    fsType = "nfs";

I have enabled the nfs service (is this needed if I don’t intend to run a server?):

  services = {
    rpcbind.enable = true;
    nfs.server.enable = true;

I have also installed nfs-utils (is this needed?) and disabled the firewall.

If I attempt to do a manual mount, it doesn’t seem to be able to find it:

mount -t nfs /mnt/nfs
mount.nfs: No such device

The path is correct, the server is online, and I can view it from a different machine.

Systemctl shows the service as exited:

systemctl list-units --type=service | grep nfs
  nfs-idmapd.service                                                                        loaded active running NFSv4 ID-name mapping service
  nfs-mountd.service                                                                        loaded active running NFS Mount Daemon
  nfs-server.service                                                                        loaded active exited  NFS server and services
  nfsdcld.service                                                                           loaded active running NFSv4 Client Tracking Daemon

Any ideas on how to resolve this?

Not sure what the problem is here but I can offer that the services and utilities shouldn’t be necessary. I’ve been able to mount TrueNAS NFS shares with just the fileSystems declaration, and rpcbind.service seems to have been started automatically.

1 Like

I had some troubles as well with my QNAP NAS.
It turned out that it didn’t support the newest NFS version.

For me this config is working on my notebook (hence the automount):

Or this config for one of my servers:

1 Like

Turns out I was missing the nfs kernel module. Loaded it and the server now mounts.

Oh how did that happen?

i wonder if nixos service modules can check for the existence or kernel modules in the nixos , in theory it just has to evaluate config. and see if those modules are enabled in the kernel, and warn if they are not…

I’ve got it to work with the following options.

# nfs
environment.systemPackages = with pkgs; [ nfs-utils ];
boot.initrd = {
  supportedFilesystems = [ "nfs" ];
  kernelModules = [ "nfs" ];
fileSystems."/mnt/share" = {
  device = "local-machine:/srv/share";
  fsType = "nfs";
1 Like