How to force NFSv4 (server side)?

Do we curently have a way of forcing using NFSv4?

Archwiki says that systemd has the option of running NFSv4 only, so I suppose that it is somewhere (not on the NixOS Wiki.

Do any of you know about this option?

Not sure if it is NFS4 only but I use:

fileSystems.“/mnt/nfs/share” = {
device = “server.domain:/file/store/stuff”;
fsType = “nfs4”;

Are you trying to prevent a fallback? I’ve not seen it happen, but could just be my setup…

I’d be interested in the answer too if I am misunderstanding!

1 Like

Just to be clear, I have a NFS server on NixOS and I want the files to be avalible only for nfs4 clients.

I have added the fsType to my bind mount:

fileSystems.${nfsDir} = { # see hardware-config.nix
    device = "/mnt/${discDir}";
    options = [ "bind" ];
    fsType = "nfs4";

However, I do not think that this changes the nfs version avalibility:

user@notNix ~ $ rpcinfo -p | grep nfs
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    3   tcp   2049  nfs_acl

Could you please provide the output of this command?

Are you trying to prevent a fallback?

Not really. I am trying to limit resource usage and improve security.
And of course play around with NixOS.

You can turn NFSv3 off on the server by using extraNfsdConfig:

services.nfs.server.extraNfsdConfig = ''

It writes the options for nfs.conf (see man pages for nfs.conf, rpc.nfsd)

1 Like

I have managed to set this config:

  services.nfs.server = { enable=true;
    exports = "${exportFileContents}";
    extraNfsdConfig =''
      rdma = true # Remote Direct Memory Access
      vers3 = false
      vers4 = true
      vers4.0 = false
      vers4.1 = false
      vers4.2 = true
1 Like