如何让你的电脑多出一块盘

效果图:

在这里插入图片描述

运行环境:CentOS7

脚本:

#!/bin/bash
systemctl stop firewalld
setenforce 0
yum install  rpcbind nfs-utils -y
mkdir /RemoteFile
mkdir /mnt/RemoteFile
chmod 777 /RemoteFile/
systemctl restart rpcbind 
systemctl restart nfs-server
echo '/RemoteFile *(rw,sync,no_root_squash)' > /etc/exports
systemctl restart rpcbind && systemctl restart nfs-server
mount -t nfs $1:/RemoteFile /mnt/RemoteFile

如何使用

Linux中

[root@localhost ~]# vi NFS.sh
-- 将shell脚本粘贴到NFS.sh中

[root@localhost ~]# chmod +x NFS.sh 
[root@localhost ~]# ip a
-- 查看到本机IP为:192.168.255.133
-- ps如果是公网IP,则以公网IP为准

[root@localhost ~]# ./NFS.sh 192.168.255.133

Windows中

当脚本执行完之后,在Windows命令行输入
C:\Users\NIKI>mount \\192.168.255.133\RemoteFile z:
z: 现已成功连接到 \\192.168.255.133\RemoteFile
命令已成功完成。

打开Explore(资源管理器)就可以看到多出来一块盘了,且盘符名字为z,这个在RemoteFile后面可以修改。
如果觉得RemoteFile这个名字不好听, 可以在脚本里修改,将脚本里所有的RemoteFile全部替换即可。
PS:
如果 
mount \\192.168.255.133\RemoteFile z:
这个命令长时间没有响应,或者报错,是应为Windows的NFS服务没有打开。
在控制面板--程序--程序和功能--启用或关闭Windows功能--NFS服务
勾选所有的NFS服务

在这里插入图片描述

想要了解更多,可以Google NFS挂载Windows

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值