1、安装NFS
sudo apt install nfs-kernel-server
2、创建并设置共享目录
mkdir /home/zhenglf/nfs
sudo gedit /etc/exports
在最后一行加入
/home/zhenglf/nfs *(rw,sync,no_root_squash)
各段表达的意思如下,根据实际进行修改
/home :共享的目录
* :指定哪些用户可以访问
* 所有可以ping同该主机的用户
192.168.1.* 指定网段,在该网段中的用户可以挂载
192.168.1.12 只有该用户能挂载
(ro,sync,no_root_squash): 权限
ro : 只读
rw : 读写
sync : 同步
no_root_squash: 不降低root用户的权限
其他选项man 5 exports 查看
3、重启NFS
sudo /etc/init.d/nfs-kernel-server restart
4、查看NFS服务器(192.168.141.129)上的共享目录
sudo showmount -e 192.168.141.129
显示:/home/zhenglf/nfs *
5、在windows上挂载(需要在windows上开启NFS客户端服务,自行百度!!!!!!!!!!)
mount \\192.168.141.129\home\zhenglf\nfs x:
6、在linux上挂载
mount -t nfs 192.168.141.129:/home/zhenglf/nfs /mnt/mnt1 -o nolock,tcp
192.168.141.129:/home/zhenglf/nfs为nfs服务端器的目录
/mnt/mnt1为linux客户端的目录