0

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?

6

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
  • Thank you so much, this helped me out of a really sticky situation. – Ron Thompson Jan 22 '18 at 23:00
  • Thank you!! I've been "debugging" this for a few hours :). Well not this directly. NFS client mounted its rootfs and requested v2 - the difference between 2 servers was that one was configured w/ v2 support, the other not. This would have been much easier to debug if only "rpcdebug -m nfsd all" would have displayed in /var/log/syslog an error message such as "NFS: version not supported". Do you know why NFS server doesn't log that or how do I see that logged?? – Corneliu Zuzu Oct 1 '18 at 6:30
2

If you upgrade to Ubuntu 18.04, you will find that there is no RPCNFSDOPTS variable anymore in /etc/default/nfs-kernel-server.

I had to hijack RPCNFSDCOUNT to get it to use NFS v2:

RPCNFSDCOUNT="--nfs-version 2 8"

Proof that it worked:

$ service nfs-kernel-server restart
$ cat /proc/fs/nfsd/versions
+2 +3 +4 +4.1 +4.2

After this I could mount the file system from OpenVMS Alpha 8.2 (... yes, really, ...)

$ tcpip mount dnfs2:[000000] /host=beauty /path="/exports/home" /struct=5
%TCPIP$DNFSMOUNT-S-MOUNTED, /exports/home mounted on _DNFS2:[000000]
0

I ran into the same problem with my embedded system (TI AM5728). Assuming you are using uboot, the trick is to change the command line being passed to the kernel. This is set by the contents of the bootargs environment variable. (see uboot documentation for details)

To fix you will need to add a ",nfsvers=3" addition onto the end of the nfsroot portion of your kernel command line (bootargs variable)

On my system when booting into NFS, the bootargs variable line looks like the following:

bootargs=console=ttyO2,115200n8 root=/dev/nfs rw rootfstype=nfs ip=dhcp nfsroot=192.168.x.x:/path/to/share

This worked fine until 17.10 and then died - The following change forces the kernel to connect using NFS v3.

bootargs=console=ttyO2,115200n8 root=/dev/nfs rw rootfstype=nfs ip=dhcp nfsroot=192.168.x.x:/path/to/share,nfsvers=3

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.