本文共 867 字,大约阅读时间需要 2 分钟。
$ sudo apt-get install nfs-kernel-server 安装服务器程序
$ sudo apt-get install nfs-common 安装客户端程序
$ mkdir ~/test
配置文件为 /etc/exports 文件,打开添加下面一行:
/home/***/test *(rw,root_squash,anonuid=1001,anongid=1001,no_subtree_check,sync)
rw 挂载该目录的客户端对该目录具有读写权限;
root_squash 客户端用户是root用户时,将root用户映射为匿名用户anonymous的权限(默认)
anonuid 指定匿名用户的uid
anongid 指定匿名用户的gid
no_subtree_check 不检查父目录的权限
sync 修改同步写入内存和磁盘
另外nfs还有其他配置参数,请根据需求添加:
ro read-only 只读权限
no_root_squash 不将root用户映射为匿名用户
all_squash 不论登录用户是什么,都映射为匿名用户
secure 数据通过1024以下的安全TCP/IP端口发送
insecure 数据通过1024以上的端口发送
wdelay 如果有多个用户要写入,则归组写入
no_wdelay 如果有多个用户要写入,立即写入,当使用async时,无需此设置
hide 共享目录不共享其子目录
no_hide 共享目录共享器子目录(默认)
subtree_check 强制检查父目录权限
async 修改暂存于内存中,不直接写入磁盘
$ sudo /etc/init.d/nfs-kernel-server restart
转载地址:http://kzadi.baihongyu.com/