記一下 MAC OS 中mount nfs 報錯問題.
環境和配置文件
-
NFS 服務端
- Ubuntu
- 安裝 apt install nfs-kernel-server
- Ubuntu
-
服務端的配置文件
cat /etc/exports
-
/nfsdata 192.168.22.1/26(rw,sync,insecure,no_root_squash)
-
CentOS 下測試掛載
yum install nfs-utils -y
mount -t nfs -o rw 192.168.22.8:/nfsdata /tmp/test
-
Ubuntu 下測試掛載
apt install nfs-common -y
mount -t nfs -o rw 192.168.22.8:/nfsdata /tmp/test
-
Mac OS 下掛載測試
- 使用掛載命令
mount -t nfs -o rw 192.168.22.8:/nfsdata /tmp/test
- 使用find手動連接
- finder -> "前往" -> "連接服務器..."。在打開的窗口中輸入"nfs://192.168.22.8/nfsdata"
問題重點1
(/etc/exports) 這里的配置文件必須要加入 insecure 參數,否則Mac OS 一直報找不到服務器的錯誤。
/nfsdata 192.168.22.1/26(rw,sync,insecure,no_root_squash)
問題點2
由於mac os 用戶id和服務端id不一致導致設置權限有問題. 不能寫操作.
解決方法
可直接 chmod 777 /nfsdata 這種方法很暴力
在服務端新建一個用戶和mac中uid一樣的用戶然后 設置附加權限 就ok了.
mac 端 查看自己的uid
id
id uid=501(makeit) gid=20(staff) groups=20(staff),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),33(_appstore
nfs服務端
#新建用戶時候指定uid useradd -u 501 makeit #配置共享目錄的附加權限 #ubuntu 中可能沒有chfacl,需要自行安裝 `apt install acl -y` chfacl -m makeit:rwx -R /nfsdata # 如果已經有該用戶了,可以使用usermod 修改用戶信息 usermod -u 501 makeit
以上操作完成就直接可以在find中增刪文件了.
enjoy 😯
- 使用掛載命令
參考:
https://www.server-world.info/en/note?os=Ubuntu_16.04&p=acl
https://blog.csdn.net/zyqblog/article/details/79226826#23-權限控制-acl
https://www.jianshu.com/p/5314f90330a6