Linux挂载Windows共享
在Linux下挂载Windows共享出现一个奇怪的问题:
mount -t cifs -o username=bak,password=bak //192.168.10.3/f$/backup/ /backup/ 提示 mount: //192.168.10.3/f$/backup/ is not a valid block device
但是
mount -t cifs -o username=bak,password=bak //192.168.10.3/f$ /backup/
就是正常的。
其实这是因为Linux默认无法识别cifs,需要安装cifs-utils
yum -y install cifs-utils mount -t cifs -o username=bak,password=bak //192.168.10.3/f$/backup/ /backup/
这个时候就可以正常挂载了。
这个时候修改/etc/fstab,增加(以下是只读挂载)
//192.168.10.3/f$/backup /backup cifs ro,username=bak,password=bak 1 2 可写挂载 //192.168.10.3/f$/backup /backup cifs rw,username=bak,password=bak 1 2
如果需要指定某个用户权限的话
//192.168.10.3/f$/backup /backup cifs rw,username=bak,password=bak,uid=500,gid=800 1 2
指定用户gid和uid
出现的错误信息及处理:
一、挂载时,用户/密码错误
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
/var/log/message信息
Oct 12 16:20:01 localhost kernel: Status code returned 0xc000006d NT_STATUS_LOGON_FAILURE
Oct 12 16:20:01 localhost kernel: CIFS VFS: Send error in SessSetup = -13
Oct 12 16:20:01 localhost kernel: CIFS VFS: cifs_mount failed w/return code = -13
二、没有分享目录
Retrying with upper case share name
mount error(6): No such device or address
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
查看/var/log/message记录
Oct 12 16:20:06 localhost kernel: CIFS VFS: cifs_mount failed w/return code = -6
Oct 12 16:20:17 localhost kernel: CIFS VFS: cifs_mount failed w/return code = -6
Oct 12 16:20:17 localhost kernel: CIFS VFS: cifs_mount failed w/return code = -6
注意:如果是数字开头比如我在windows下的共享目录为
\\192.168.2.10\102\public 手动mount挂载是可以的,但是放在/etc/fstab是不行,默认会被转义。
因此最好的方法就是使用//192.168.2.10/102/public去配置