(1)在windows下,新建share文件夹,然后属性设置为共享文件夹。
(2)新建共享文件,理论可以通过//win10的ip/share访问
(3)获得windows10的ip,在命令行输入ipconfig /all
mkdir /mnt/win10
建议用第一条: [root@localhost ~]# mount -t cifs -o username=root,password=dsg112,rw,uid=1000,gid=1000 //192.168.2.168/wwwroot2 /mnt/win10_2 [root@localhost ~]# mount -t cifs -o username=win10User,password=win10Pw,sec=ntlm //win10Ip/share /mnt/win10 或者 # mount -t cifs -o username=win10User,password=win10Pw //win10Ip/share /mnt/win10 或者 # mount.cifs //win10Ip/share /mnt/win10 -o username=win10User,password=win10Pw
df -Th
其中:
cifis:CIFS(Common Internet File System)文件系统也称通用Internet文件系统,它使程序可以访问远程Internet计算机上的文件并要求此计算机的服务。
win10User/win10Pw:分别是windows用户名和密码
win10Ip:windows的ip
share:windows的共享文件夹
/mnt/win10:最终挂载目录
一、如果报错:
mount: 文件系统类型错误、选项错误、192.168.137.101:/data/wwwroot/pc 上有坏超级块、 缺少代码页或助手程序,或其他错误 (对某些文件系统(如 nfs、cifs) 您可能需要 一款 /sbin/mount.<类型> 助手程序) 有些情况下在 syslog 中可以找到一些有用信息- 请尝试 dmesg | tail 这样的命令看看。
可以尝试:
yum install cifs-utils -y 或者 yum -y install nfs-utils systemctl start nfs-utils systemctl enable nfs-utils
二、如果每次重启之后想让系统自动挂载(前提是宿主机能有固定IP,需要先在路由器中分配好)
方法一:(建议)
在/etc/rc.local文件中添加下列代码,
mount -t cifs -o username=root,password=dsg112,rw,uid=1000,gid=1000 //192.168.2.168/wwwroot2 /mnt/win10_2
在CentOS 7中,rc.local的权限被降低了,所以还要多执行一句
chmod +x /etc/rc.d/rc.local
方法二:
在/etc/fstab文件中添加下列代码,
mount -t cifs -o username=root,password=dsg112,rw,uid=1000,gid=1000 //192.168.2.168/wwwroot2 /mnt/win10_2