NFS(Network File System)網絡文件系統,讓局域網機器透過 TCP/IP 共享資源,客戶端讀寫遠端文件如同本地。
sudo apt-get install nfs-kernel-server
sudo vim /etc/exports
# 共享 /home/student/xushan 目錄,允許所有網段讀寫、同步寫入、root 權限不壓縮
/home/student/xushan *(rw,sync,no_root_squash)
*:所有網段rw:讀寫權限sync:同步寫入內存與硬盤no_root_squash:客戶端 root 保持 root 權限sudo /etc/init.d/portmap restart
sudo /etc/init.d/nfs-kernel-server restart
showmount -e # 顯示共享目錄
sudo mount -t nfs 192.168.1.117:/home/student/xushan /mnt
df -h # 驗證掛載
# 在 /mnt 創建文件,服務端同步出現
sudo umount /mnt # 卸載(先退出目錄)