Ubuntu – How to make the nfs server support protocol version 2 in Ubuntu 17.10

17.10nfs

I have a linux embedded system that (when doing active development on it) mounts its root filesystem as an nfs share exported from my ubuntu box. So just to be extra clear: embedded linux is the nfs client, my ubuntu box is the nfs server. I don't have much control over the embedded system doing the actual nfs mounting.

When I upgraded to ubuntu 17.10, I found out this does not work any more.

After much debugging, I think I pinpointed the problem to a protocol version mismatch: while sniffing traffic with wireshark I found out the embedded system sends NFS packets with the old protocol version 2, but here's what I get on my ubuntu box I run

$ rpcinfo -p localhost
program vers proto   port  service
 100000    4   tcp    111  portmapper
 100000    3   tcp    111  portmapper
 100000    2   tcp    111  portmapper
 100000    4   udp    111  portmapper
 100000    3   udp    111  portmapper
 100000    2   udp    111  portmapper
 100005    1   udp  43512  mountd
 100005    1   tcp  39783  mountd
 100005    2   udp  35844  mountd
 100005    2   tcp  58287  mountd
 100005    3   udp  48188  mountd
 100005    3   tcp  60599  mountd
 100003    3   tcp   2049  nfs
 100003    4   tcp   2049  nfs
 100227    3   tcp   2049
 100003    3   udp   2049  nfs
 100227    3   udp   2049
 100021    1   udp  44366  nlockmgr
 100021    3   udp  44366  nlockmgr
 100021    4   udp  44366  nlockmgr
 100021    1   tcp  43079  nlockmgr
 100021    3   tcp  43079  nlockmgr
 100021    4   tcp  43079  nlockmgr
 100024    1   udp  50305  status
 100024    1   tcp  42983  status

so no nfs version 2, only 3 and 4.

Anyone knows how to add nfs version 2 support to my nfs server?

Best Answer

You need to modify /etc/default/nfs-kernel-server to have these lines:

RPCNFSDOPTS="--nfs-version 2,3,4 --debug --syslog"
# To confirm above mods are in effect after service restart use
#     cat /run/sysconfig/nfs-utils
#  or 
#    service nfs-kernel-server status
#

and restart the service

service nfs-kernel-server restart

take care that after service restart you may need to re-start shares

zfs share -a

Finally confirm that protocol 2 is being supported (tcp and udp too if necessary)

rpcinfo -p servername | fgrep nfs

You should see this

100003    2   tcp   2049  nfs
100003    3   tcp   2049  nfs
100003    4   tcp   2049  nfs
100003    2   udp   2049  nfs
100003    3   udp   2049  nfs