我正在嘗試在我的 Raspberry Pi 上建立 NFS 伺服器,網路上的任何伺服器都可以寫入該伺服器。 NFS 共用是啟動時安裝的外部裝置上的目錄:
$ cat /etc/fstab
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 2
/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
# This is my external device
/dev/sda1 /data ext4 defaults,nofail 0 2
我的配置/etc/exports
如下:
$ cat /etc/exports
/data *(rw,sync,all_squash,no_subtree_check,anonuid=1000,anongid=1000)
/data/share *(rw,sync,all_squash,no_subtree_check,anonuid=1000,anongid=1000)
1000的用戶ID和群組ID是pi用戶和pi群組,它同時擁有/data和/data/share:
$ ls -la /data
total 28
drwxrwxrwx 4 pi pi 4096 Sep 30 08:41 .
drwxr-xr-x 23 root root 4096 Oct 9 15:54 ..
drwx------ 2 pi pi 16384 Sep 25 14:57 lost+found
drwxrwxrwx 2 pi pi 4096 Sep 30 08:41 share
當我嘗試從 Mac 掛載共享時,出現以下錯誤:
$ mount 192.168.101.10:/data tmp
mount_nfs: can't mount /data from 192.168.101.10 onto /Users/davejlong/Downloads/tmp: Operation not permitted
這是輸出exportfs -v
$ sudo exportfs -v
/data <world>(rw,wdelay,root_squash,all_squash,no_subtree_check,anonuid=1000,anongid=1000)
/data/share <world>(rw,wdelay,root_squash,all_squash,no_subtree_check,anonuid=1000,anongid=1000)
我不確定我的配置做錯了什麼。
答案1
當然,我在提出問題後立即找到了答案:facepalm:
看來我需要將選項添加insecure
到我的匯出中:
$ cat /etc/exports
/data *(rw,sync,all_squash,no_subtree_check,insecure,anonuid=1000,anongid=1000)
/data/share *(rw,sync,all_squash,no_subtree_check,anonuid=1000,anongid=1000)