/home/zp/share 192.168.2.*(rw,sync,no_root_squash)
或者:/home/zp/share 192.168.2.0/24(rw,sync,no_root_squash)
192.168.2.* 网段内的NFS客户端能够共享NFS服务器/home/zp/share目录内容.且有读,写权限, 并且该用户进入/home/zp/share目录后的身份为root
最好加上sync, 否则 $ sudo exportfs -r 时会给出警告, sync是NFS的默认选项.
运行 $ showmount -e 查看NFS server的export list.
若更改了/etc/exports, 运行 $ sudo exportfs -r 更新
运行 $ sudo /etc/init.d/nfs-kernel-server restart 重启nfs服务
/etc/exports实际上就是nfs服务器的核心配置文件了. 鸟哥的Linux私房菜列举了一些exports文件的写法.
测试NFS
可以尝试一下挂载本地磁盘(假设本地主机IP地址为:192.128.2.1,将/home/zp/share挂载到/mnt)
$ sudo mount 192.168.2.1:/home/zp/share /mnt
运行 $ df 看看结果
$ sudo umount /mnt
注意被拷贝文件的读/写权限!
另外, 可以使用一定的参数:
使用加参数的办法:mount -o nolock,rsize=1024,wsize=1024,timeo=15 192.168.2.130:/tmp/ /tmp/