服务端:
[root@nfs_server ~]# yum -y install nfs-utils rpcbind
[root@nfs_server ~]# systemctl enable rpcbind
[root@nfs_server ~]# systemctl enable nfs-server
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
[root@nfs_server ~]# systemctl enable nfs-lock
[root@nfs_server ~]# systemctl enable nfs-idmap
[root@nfs_server ~]# systemctl start rpcbind
[root@nfs_server ~]# systemctl start nfs-server
[root@nfs_server ~]# systemctl start nfs-lock
[root@nfs_server ~]# systemctl start nfs-idmap
[root@nfs_server ~]# mkdir -p /application/share -p 级联创建
[root@nfs_server ~]# chmod -R 777 /application/share 更改share文件夹及其子文件夹权限为777
[root@nfs_server ~]# echo "/application/share 192.168.0.*(rw,sync,no_root_squash)" >> /etc/exports
[root@nfs_server ~]# exportfs -a 使exports的修改生效
[root@nfs_server /]# showmount -e
Export list for nfs_server:
/application/share 192.168.0.*
[root@nfs_server ~]# firewall-cmd --add-service=nfs --permanent --zone=public
success
[root@nfs_server ~]# firewall-cmd --add-service=mountd --permanent --zone=public
success
[root@nfs_server ~]# firewall-cmd --add-service=rpc-bind --permanent --zone=public
success
[root@nfs_server ~]# firewall-cmd --reload 重新载入配置,使其生效
success
客户端:
[root@nfs_client ~]# yum -y install nfs-utils
[root@nfs_client ~]# mkdir -p /application/localshare
[root@nfs_client ~]# mount -t nfs 192.168.0.240:/application/share /application/localshare
解释一下:
mount :挂载命令
nfs :使用的协议
nolock :不阻塞
vers : 使用的NFS版本号
IP : NFS服务器的IP(NFS服务器运行在哪个系统上,就是哪个系统的IP)
/work/nfs: 要挂载的目录(Ubuntu的目录)
/mnt : 要挂载到的目录(开发板上的目录,注意挂载成功后,/mnt下原有数据将会被隐藏,无法找到)
配置客户端开机自动挂载nfs共享目录
vi /etc/fstab
添加 192.168.0.240:/application/share /application/share nfs defaults 0 0