嵌入式 NFS 服务器不支持 ver=2,但支持 1,3 - 这可能吗?

嵌入式 NFS 服务器不支持 ver=2,但支持 1,3 - 这可能吗?

我的 MontaVista 2.6.37 Linux 编译了 NFS 模块。我按顺序启动它们:

rpcbind
rpc.nfsd 4
rpc.mountd
rpc.statd

默认配置文件和 etab 为:

/mnt/sda1 192.168.50.0/24(rw,sync,wdelay,hide,nocrossmnt,secure,no_root_squash,no_all_squash,no_subtree_check,secure_locks,acl,fsid=1,anonuid=65534,anongid=65534)

作为客户端,我的 FC32 一切正常:

[root@leonp mnt]# mount -v 192.168.1.1:/mnt/sda1/ srv
mount.nfs: timeout set for Mon Aug  3 16:04:08 2020
mount.nfs: trying text-based options 'vers=4.2,addr=192.168.1.1,clientaddr=192.168.1.57'
mount.nfs: mount(2): Protocol not supported
mount.nfs: trying text-based options 'vers=4,minorversion=1,addr=192.168.1.1,clientaddr=192.168.1.57'
mount.nfs: mount(2): Protocol not supported
mount.nfs: trying text-based options 'vers=4,addr=192.168.1.1,clientaddr=192.168.1.57'
mount.nfs: mount(2): Protocol not supported
mount.nfs: trying text-based options 'addr=192.168.1.1'
mount.nfs: prog 100003, trying vers=3, prot=6
mount.nfs: trying 192.168.1.1 prog 100003 vers 3 prot TCP port 2049
mount.nfs: prog 100005, trying vers=3, prot=17
mount.nfs: trying 192.168.1.1 prog 100005 vers 3 prot UDP port 39445
[root@leonp mnt]#

当我尝试连接仅支持 NFSv2 的客户端时,问题就出现了。因此,要从 PC 进行测试:

[root@leonp mnt]# mount -vvv -o vers=2 192.168.1.1:/mnt/sda1/ srv
mount.nfs: timeout set for Mon Aug  3 13:50:14 2020
mount.nfs: trying text-based options 'vers=2,addr=192.168.1.1'
mount.nfs: prog 100003, trying vers=2, prot=6
mount.nfs: trying 192.168.1.1 prog 100003 vers 2 prot TCP port 2049
mount.nfs: prog 100005, trying vers=1, prot=17
mount.nfs: trying 192.168.1.1 prog 100005 vers 1 prot UDP port 36357
mount.nfs: mount(2): Protocol not supported
mount.nfs: Protocol not supported

为什么这个?我检查了:

[root@leonp mnt]# rpcinfo 192.168.1.1 
   program version netid     address                service    owner
    100000    4    tcp       0.0.0.0.0.111          portmapper superuser
    100000    3    tcp       0.0.0.0.0.111          portmapper superuser
    100000    2    tcp       0.0.0.0.0.111          portmapper superuser
    100000    4    udp       0.0.0.0.0.111          portmapper superuser
    100000    3    udp       0.0.0.0.0.111          portmapper superuser
    100000    2    udp       0.0.0.0.0.111          portmapper superuser
    100000    4    local     /var/run/rpcbind.sock  portmapper superuser
    100000    3    local     /var/run/rpcbind.sock  portmapper superuser
    100003    2    tcp       0.0.0.0.8.1            nfs        unknown
    100003    3    tcp       0.0.0.0.8.1            nfs        unknown
    100003    2    udp       0.0.0.0.8.1            nfs        unknown
    100003    3    udp       0.0.0.0.8.1            nfs        unknown
    100021    1    udp       0.0.0.0.148.56         nlockmgr   unknown
    100021    3    udp       0.0.0.0.148.56         nlockmgr   unknown
    100021    4    udp       0.0.0.0.148.56         nlockmgr   unknown
    100021    1    tcp       0.0.0.0.228.206        nlockmgr   unknown
    100021    3    tcp       0.0.0.0.228.206        nlockmgr   unknown
    100021    4    tcp       0.0.0.0.228.206        nlockmgr   unknown
    100005    1    udp       0.0.0.0.142.5          mountd     superuser
    100005    1    tcp       0.0.0.0.130.95         mountd     superuser
    100005    2    udp       0.0.0.0.218.108        mountd     superuser
    100005    2    tcp       0.0.0.0.174.251        mountd     superuser
    100005    3    udp       0.0.0.0.154.21         mountd     superuser
    100005    3    tcp       0.0.0.0.132.150        mountd     superuser

唯一不支持 v2 的是 nlockmgr - 它会成为挂载拒绝的原因吗?为了测试这一点,我尝试从运行中删除 nlockmgr - 没有成功。我试图通过注释掉 100021 在 /etc/rpc 中阻止它 - 没有成功。

更新:

#rcp.nfsd -d
rpc.nfsd: Checking netconfig for visible protocols.
rpc.nfsd: Enabling inet udp.
rpc.nfsd: Enabling inet tcp.
rpc.nfsd: knfsd is currently down
rpc.nfsd: Writing version string to kernel: +4.1 +2 +3 +4

#cat /proc/fs/nfsd/versions
+2 +3
============

任何帮助将不胜感激。

答案1

您需要调整 NFS 内核服务器以提供版本 2(正如您所注意到的,默认情况下它不再包含该版本)。在服务器上运行此命令将允许您测试建议的修复是否有效

rpc.nfsd 0 && sleep 1           # Stop all previous threads
rpc.nfsd --nfs-version 2,3 8    # Restart 8 threads with versions 2 and 3

如果有效,您需要将其永久化。在我的 Debian(“buster”)系统上,似乎仍然涉及编辑/etc/default/nfs-kernel-server.在您的系统上,它可能会有所不同。

原始代码

# Number of servers to start up
RPCNFSDCOUNT=32

修改后的代码

# Options and number of servers to start up
RPCNFSDCOUNT='--nfs-version 2,3 8'

相关内容