Linux挂载SMB网络磁盘报mount error(95): 错误
在我们的使用场景中,会遇到挂在网络磁盘作为存储,本文章主要想记录其问题现象及处理过程,作为分享。
#挂在smbC盘需要安装的依赖: yum install cifs-utils

直接挂载磁盘,直接报错:mount error(95): Operation not supported
通过查询相关资料,发现是由于SMB协议版本导致,我们需要在挂在命令中指定版本即可,命令如下:
mount -t cifs -o username='***',password='***',iocharset=utf8,vers=2.0 //{IP地址}/{目录路径} /{挂载路径} mount -t cifs -o username='***',password='***',iocharset=utf8,vers=1.0 //{IP地址}/{目录路径} /{挂载路径} mount -t cifs -o username='***',password='***' //{IP地址}/{目录路径} /{挂载路径}
我们可以先尝试2.0,不行报错的话继续尝试剩下的两个版本,如果都不行,就需要排查服务端了,报这个错误就是smb版本兼容性问题.
加入开机自动挂载,在 /etc/fstab文件下加入下面的一行内容,
//{IP地址}/{目录路径} /{挂载目录} cifs defaults,username=***,password=***,iocharset=utf8,vers=2.0 0
加入后完整配置文件如下所示:
[root@localhost data]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Mon Mar 14 22:17:25 2022 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/centos-root / xfs defaults 0 0 UUID=a029ae60-4e72-466b-886b-f4045370f3d9 /boot xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0 //{IP地址}/{目录路径} /{挂载目录} cifs defaults,username=***,password=***,iocharset=utf8,vers=2.0 0
开机启动添加小知识:
1)在挂载windows文件夹时,路径中存在空格怎么办
解决方案:使用\040
替代空格,成功挂载。一个样例如下:
//{IP地址}/Work\040file/ /data cifs defaults,username=***,password=***,iocharset=utf8,vers=2.0 0 0
2)挂载路径存在中文,乱码咋办
解决方案:defaults添加 iocharset=utf8参数即可,方式可以参考上面的内容。
以上就是挂载SMB远程目录到Linux的问题说明。

































