nfs安装及与windows挂载共享

nfs安装及与windows挂载共享步骤:

实验需要两台机器,一台作为服务端,一台作为客户端

服务端安装两个包nfs-utils和rpcbind:yum install -y nfs-utils rpcbind

编辑配置文件,允许共享主机IP:vim /etc/exports
添加配置内容为:/home/nfstestdir 服务器IP 最后一位是0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)
windowsIP(rw,sync,all_squash,anonuid=1000,anongid=1000)

创建共享目录,给创建目录777权限:mkdir /home/nfstestdir
chmod 777 /home/nfstestdir

服务端启动rpcbind:systemctl start rpcbind

启动nfs:systemctl start nfs

设置开机自启动:systemctl enable nfs

关闭防火墙:systemctl stop firewalld
setenforce 0

另一台虚拟机客户端,安装包nfs-utils:yum install -y nfs-utils rpcbind

启动rpcbind:systemctl start rpcbind

启动nfs:systemctl start nfs

客户端连接服务端的IP:showmount -e 服务器端IP

挂载服务端的共享目录:mount -t nfs 服务器端IP:/home/nfstestdir /mnt
df -h测试

关闭防火墙:systemctl stop firewalld
setenforce 0

(如果要重启nfs服务需要取消mnt挂载:umount /mnt)

完成连接后,服务端 /hom/nfstestdir 目录和客户端 /mnt目录下是相通的。

windows挂载共享:

打开控制面板——程序——启用或关闭windows功能——点击NFS服务和适用于Linus的windows子系统——确定——重启电脑
nfs安装及与windows挂载共享_第1张图片
nfs安装及与windows挂载共享_第2张图片
nfs安装及与windows挂载共享_第3张图片
nfs安装及与windows挂载共享_第4张图片

windows键+R键——命令行输入:mount \服务器端IP:\home x:,显示已成功连接即可
此电脑——挂载盘存在即成功
nfs安装及与windows挂载共享_第5张图片
断开挂载,命令行输入:umount x: ,断开连接即可。

你可能感兴趣的:(Linux)