ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
来源:https://www.cnblogs.com/jiangxiaobo/p/10531475.html # [windows共享文件夹至centos系统文件夹下](https://www.cnblogs.com/jiangxiaobo/p/10531475.html) ![](https://cdn.nlark.com/yuque/0/2021/png/1307389/1632647343456-892b402b-aeed-4f04-ad08-a6540bb6f2f9.png) 1\. window 共享文件夹 https://jingyan.baidu.com/article/358570f6633ba4ce4624fc48.html 2\. 在访问Windows共享资料之前,请确保Windows共享是可用的,这里就不再赘述该怎样设置Windows共享了,那可是另外一个课题。 Linux访问Windows共享或者Linux共享资料给Windows时,其实都是在使用一个叫做Samba的软件,这个软件已经使用多年,稳定性和可靠性得到了很好的验证,也是很多网络NAS常用的软件。 我们这里要讲的Linux需要用到的工具就是Samba软件中的一种,samba-client。 在尝试访问Windows共享之前,需要首先确认samba-client已经安装了。最简单的方式是命令行查询“**rpm -qa | grep samba-client**”,当然也可以使用“**yum**”工具查询, 如“**yum info samba-client**”或“**yum list samba-client**”之类的命令。 ![](https://cdn.nlark.com/yuque/0/2021/png/1307389/1632647265936-0aaad866-c9ad-4257-9561-a2f1996ad6e1.png) 如果samba-client没有安装,就需要使用命令“**yum install samba-client**”安装一下,yum会自动安装samba-client所需的相关依赖库,安装时选择Y就行了。 针对常见的Debian Linux发行版,如Ubuntu或CentOS,也可以使用“**sudo apt-get install smbclient**”和“**sudo apt-get install smbfs**”安装相应的共享访问工具。 ![](https://cdn.nlark.com/yuque/0/2021/png/1307389/1632647265965-7225c459-a21c-4ab6-9b3f-cbe87847feb5.png) **遇到问题:** **mount时报错 host is down** 需求:将[Windows](https://www.baidu.com/s?wd=Windows&tn=24004469_oem_dg&rsv_dl=gh_pl_sl_csd)文件挂载到虚拟机 前提:虚拟机和Windows是互相可ping通的 设备IP为:192.168.12.209 虚拟机IP为: 192.168.253.140 1、ping通 ![](https://cdn.nlark.com/yuque/0/2021/png/1307389/1632647265867-182e56c2-869f-4448-af23-49dfdb7ddb92.png) ![](https://cdn.nlark.com/yuque/0/2021/png/1307389/1632647265930-63bd17f0-b86b-4bff-b1ef-71a1ec0590ac.png) 2、挂载 使用mount -t cifs //192.168.12.209/code /home/lxd -o username=administrator,password=123456 mount -t cifs ip/你电脑的共享目录 要挂载到服务器某个目录下 -o 其他项 命令无错误,但是出现host is down 最后发现是版本的问题,解决方法如下: ![](https://cdn.nlark.com/yuque/0/2021/png/1307389/1632647265764-6838822b-f2bf-4fa3-bb4d-1f31a7d0fbfb.png) 在命令后面加最新版本version即可 3、卸载 umount /home/lxd(刚才挂载到服务器的目录路径) 如果提示target is busy 说明你是在当前目录下卸载当前目录,肯定不行,得退出当前路径再去unmout 如果提示dervice is busy 可选择强制卸载 umount -f /home/lxd # CentOS7挂载windows共享时提示写保护 centos7挂载windows共享时,提示被共享的位置写保护,只能以只读方式挂载,紧接着就是以只读方式挂载失败 初时以为是另一台centos6.4已挂载此共享,所以同时挂载会引起读写保护,取消6.4的mount后依然是这样, 后来各种搜索,发现可能是组件少装了,于是 yum install cifs-utils 安装完后,正常挂载使用。 ok ok ok 最后,成功挂载命令 mount -t cifs //192.168.135.131/code /mnt/MYSHARE/ -o username=Administrator,password=15095866715,vers=2.0 ![](https://cdn.nlark.com/yuque/0/2021/png/1307389/1632647266310-b03db8ab-e686-4a0f-a28b-9750c3a8410e.png) ![](https://cdn.nlark.com/yuque/0/2021/png/1307389/1632647266450-c5b1e9b1-ea6f-4096-ba4a-70b5e391798a.png) dome : mount -t cifs -o username=tommy,password=123456, rw,dir\_mode=0777,file\_mode=0777 //192.168.1.123/redhat\_disk /mnt/Windows #指定用户 mount -t cifs //192.168.14.24/windows\_share /windows\_share/ -o username=Administrator,password=10086 ,uid=1001 # 有权限 mount -t cifs //192.168.14.24/windows\_share /windows\_share/ -o username=Administrator,password=10086 ,rw,dir\_mode=0777,file\_mode=0777 # 卸载 umount /windows\_share