How can the NFS server on a Debian 8 system be limited to NFSv3?

By default, shares can be mounted with both vers=3 and vers=4.


# To disable NFSv4 on the server, specify '--no-nfs-version 4' here
RPCMOUNTDOPTS="--manage-gids --no-nfs-version 4"

This option does not seem to have any effect (rpcinfo still shows nfs accepting version 4).


Turns out modifying the RPCMOUNTDOPTS variable as described in /etc/default/nfs-kernel-server does not work and there's a bug report for that: #738063

This variable is used in the rpc.mountd call:

# systemctl status nfs-kernel-server
● nfs-kernel-server.service - LSB: Kernel NFS server support
   Loaded: loaded (/etc/init.d/nfs-kernel-server)
   Active: active (running) since Sun 2016-06-12 19:46:01 CEST; 6s ago
  Process: 15110 ExecStop=/etc/init.d/nfs-kernel-server stop (code=exited, status=0/SUCCESS)
  Process: 15119 ExecStart=/etc/init.d/nfs-kernel-server start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/nfs-kernel-server.service
           └─15167 /usr/sbin/rpc.mountd --manage-gids --port 2048 --no-nfs-version 4

However, clients are still able to mount using -o vers=4.

Instead, this option must be passed to rpc.nfsd. Looking at the init script /etc/init.d/nfs-kernel-server, it seems like the RPCNFSDCOUNT variable is the only variable that's passed to rpc.nfsd. It's not intended for that purpose, but it works and it seems to be the only option short of editing the init script.


In /etc/default/nfs-kernel-server, add the --no-nfs-version 4 option to RPCNFSDCOUNT instead of RPCMOUNTDOPTS:

# Number of servers to start up
RPCNFSDCOUNT="8 --no-nfs-version 4"

Restart the NFS service:

# systemctl restart nfs-kernel-server

Test it:

# mount -t nfs -o vers=4 SERVER:/data/public /mnt
mount.nfs: Protocol not supported

Version 3 still works:

# mount -t nfs -o vers=3 SERVER:/data/public /mnt
  • Very good solution, clearly a bug! – Mvorisek Jan 3 '18 at 16:26
  • a good solution but appeared not enough for the rootfs mounting from the linux kernel. it appeared NFSv4 is no longer working over UDP but is expecting TCP to be used, however kernel by default is trying to connect over UDP even for the NFSv4 so special parameter has to be added at the tail of the nfsroot. Example: nfsroot=,tcp – Oleg Kokorin Mar 30 '18 at 11:18

looks like you want

RPCMOUNTDOPTS="--manage-gids -V 3"

It seems there are no compatibility problem with -V 3 and --manage-gids but I didn't test.

  • of course you need to restart the nfs server service. – Emmanuel May 26 '16 at 15:08
  • No, that option does not disable version 4 either. – basic6 Jun 12 '16 at 18:00

After edit restart nfs-kernel-server On other linux distro i use another method, edit /etc/nfsmount.conf

# Protocol Version [2,3,4]
# This defines the default protocol version which will
# be used to start the negotiation with the server.

Then restart nfs,this enable only nfs3

  • 1
    /etc/nfsmount.conf does not exist (by default, Debian) and "negotiation with the server" indicates that this is a client setting. – basic6 May 25 '15 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.