在 PBS(Debian 12) 主機內安裝 NFS 服務
- 安裝環境 PBS 3.0-3 (Debian 12.2)
- 預計 NFS 分享的路徑 : /mnt/datastore/zfs-backup/nfsshare
- 預計 NFS Client IP 範圍 : 10.20.0.0 - 10.20.2.254 → 10.20.0.0/22
安裝與設定程序
- 安裝 NFS 服務套件
apt update apt install nfs-server -y
- 建立與設定分享目錄
mkdir -p /mnt/datastore/zfs-backup/nfsshare chown 1000:1000 /mnt/datastore/zfs-backup/nfsshare chmod 755 /mnt/datastore/zfs-backup/nfsshare vi /etc/exports
: /mnt/datastore/zfs-backup/nfsshare 10.20.0.0/22(rw,sync,no_subtree_check,no_root_squash,all_squash,anonuid=1000,anongid=1000)
- 關鍵參數解釋:
- no_root_squash:允許 root 用戶保留完整權限
- all_squash:將所有用戶映射到匿名用戶
- anonuid=1000:指定匿名用戶的 UID
- anongid=1000:指定匿名用戶的 GID
- 啟動 nfs 服務與檢查狀況
exportfs -ra systemctl restart nfs-server systemctl enable nfs-server systemctl status nfs-server
如果正常啟動會看到類似以下的訊息
# systemctl status nfs-server ● nfs-server.service - NFS server and services Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; preset: enabled) Active: active (exited) since Thu 2023-10-19 21:49:02 CST; 17s ago Process: 152486 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS) Process: 152487 ExecStart=/usr/sbin/rpc.nfsd (code=exited, status=0/SUCCESS) Main PID: 152487 (code=exited, status=0/SUCCESS) CPU: 3ms Oct 19 21:49:02 pbs-253 systemd[1]: Starting nfs-server.service - NFS server and services... Oct 19 21:49:02 pbs-253 systemd[1]: Finished nfs-server.service - NFS server and services.
常見問題
- 關閉 NFS Server 服務
systemctl stop nfs-server systemctl disable nfs-server