linux 挂载windows 共享文件夹

工作需要,能在linux 访问windows系统 共享文件夹内容。花了半天时间研究了下。毕竟linux 不熟 ,以前也没接触过 。期间掉了不少坑,特此记录 。

1、前期环境

1、windows系统 下共享某个文件,具体地址假设: 192.168.201.01/test/share

2、挂载

1、安装cifs-utils

apt-get update && apt-get install cifs-utils

2、/etc/fstab 后面新增( 能开机自动挂载)

//192.168.201.01/test/share  /mnt/temp   cifs  defaults,username=username,password=password   0    0

3、执行挂载命令

mount -t  cifs -o username=username,password=password //192.168.201.01/test/share  /mnt/temp

说明: username 及password 可输入的是linux 的登录用户名密码 。

3、报错说明

期间遇到了好几个坑,百度了一大堆才解决问题。很多信息都不适用了。

3.1 、 错误一 :

mount: wrong fs type, bad option, bad superblock on 192.168.201.01/test/share,
       missing codepage or helper program, or other error
       (for several filesystems (e.g. nfs, cifs) you might
       need a /sbin/mount.<type> helper program)

       In some cases useful info is found in syslog - try
       dmesg | tail or so.

解决方案:下载 cifs-utils

 apt-get update && apt-get install cifs-utils

3.2、错误二:

mount: can't find /mnt/temp in /etc/fstab

解决方案 :/etc/fstab 后面新增

192.168.201.01/test/share      /mnt/temp               cifs                defaults    0    0

3.3 、 错误三

mount.cifs: bad UNC (192.168.201.01/test/share)

解决方案 :

1、检查username 、password 是否错误 。
2、linux 系统目录不能有反斜杠 \ .
3、192.168.201.01 前面是否添加 //

我报错因为 未写用户名密码 。


版权声明:本文为u013092590原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。