![如何使用版本 4 連接到我的 RPi NFS 伺服器?](https://rvso.com/image/50570/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%E7%89%88%E6%9C%AC%204%20%E9%80%A3%E6%8E%A5%E5%88%B0%E6%88%91%E7%9A%84%20RPi%20NFS%20%E4%BC%BA%E6%9C%8D%E5%99%A8%EF%BC%9F.png)
我已將 Raspberry Pi 設定為 NFS 伺服器,但無法使用 NFS 版本 4 連接到它。來自我的 Kubuntu 13.04 用戶端:
$ sudo mount -t nfs -o proto=tcp,port=2049,vers=4 192.168.1.91:/export /mnt/pi -v
mount.nfs: timeout set for Tue Sep 17 09:47:26 2013
mount.nfs: trying text-based options 'proto=tcp,port=2049,vers=4,addr=192.168.1.91,clientaddr=192.168.1.7'
mount.nfs: mount(2): Permission denied
mount.nfs: access denied by server while mounting 192.168.1.91:/export
$ sudo mount -t nfs -o proto=tcp,port=2049,vers=3 192.168.1.91:/export /mnt/pi -v
mount.nfs: timeout set for Tue Sep 17 09:47:31 2013
mount.nfs: trying text-based options 'proto=tcp,port=2049,vers=3,addr=192.168.1.91'
mount.nfs: prog 100005, trying vers=3, prot=6
mount.nfs: trying 192.168.1.91 prog 100005 vers 3 prot TCP port 35976
從伺服器來看,核心似乎編譯了NFS版本4。
$ rpcinfo -p
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
100024 1 udp 51953 status
100024 1 tcp 42383 status
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100227 2 tcp 2049
100227 3 tcp 2049
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100227 2 udp 2049
100227 3 udp 2049
100021 1 udp 41873 nlockmgr
100021 3 udp 41873 nlockmgr
100021 4 udp 41873 nlockmgr
100021 1 tcp 35095 nlockmgr
100021 3 tcp 35095 nlockmgr
100021 4 tcp 35095 nlockmgr
100005 1 udp 60943 mountd
100005 1 tcp 44936 mountd
100005 2 udp 52342 mountd
100005 2 tcp 56312 mountd
100005 3 udp 57888 mountd
100005 3 tcp 35976 mountd
/var/log/messages
兩次嘗試的伺服器日誌均未更改。對於不成功的 v4 嘗試,伺服器日誌/var/log/syslog
不會發生變化,但對於成功的 v3 嘗試會附加伺服器日誌,如下所示。
Sep 17 21:48:27 raspberrypi rpc.mountd[24098]: authenticated mount request from 192.168.1.7:1021 for /export (/export)
Sep 17 22:09:12 raspberrypi rpc.mountd[24098]: authenticated mount request from 192.168.1.7:790 for /export (/export)
Sep 17 22:09:51 raspberrypi rpc.mountd[24098]: authenticated mount request from 192.168.1.7:1002 for /export (/export)
奇怪的是,儘管我指定了 2049,但連接埠似乎正在更改?
伺服器的內容/etc/export
/export 192.168.1.0/24(rw,fsid=0,insecure,no_subtree_check,async,crossmnt)
注意,這最初發佈於Raspberry Pi Stackexchange 站點兩週前,但我在這裡嘗試,因為我還沒有得到像樣的回應。如果我在這裡得到好的回應,我會刪除另一個。
==編輯==
/etc/default/nfs-common
伺服器上的內容:
# If you do not set values for the NEED_ options, they will be attempted
# autodetected; this should be sufficient for most people. Valid alternatives
# for the NEED_ options are "yes" and "no".
# Do you want to start the statd daemon? It is not needed for NFSv4.
NEED_STATD=
# Options for rpc.statd.
# Should rpc.statd listen on a specific port? This is especially useful
# when you have a port-based firewall. To use a fixed port, set this
# this variable to a statd argument like: "--port 4000 --outgoing-port 4001".
# For more information, see rpc.statd(8) or http://wiki.debian.org/SecuringNFS
STATDOPTS=
# Do you want to start the idmapd daemon? It is only needed for NFSv4.
NEED_IDMAPD=yes
# Do you want to start the gssd daemon? It is required for Kerberos mounts.
NEED_GSSD=no