红联Linux门户
Linux帮助

cifs自动挂载

发布时间:2015-09-03 21:36:52来源:linux网站作者:ty3219

公司服务器上使用cifs提供了一个共享空间。

修改配置,每次开机的时候都自动挂载。

修改配置前可以先手动挂载看参数是否正确:


ubuntu 12.04

sudo mount.cifs //192.168.1.1/your/file/path /media/local/mount/point/   -o user=your-name-on-server,password=password,uid=your-name-on-ubuntu,gid=your-name-on-local,sec=ntlmv2  

成功后,修改/etc/fstab

//192.168.1.1/your/file/path   /media/local/mount/point/       cifs    user=your-name-on-server,password=password,uid=your-name-on-ubuntu,gid=your-name-on-local,sec=ntlmv2     0       0 

重启即可。


fedora14

sudo mount.cifs //192.168.1.1/your/file/path /media/local/mount/point/ -o user=your-name-on-server,password=password,uid=your-name-on-ubuntu,gid=your-name-on-local 

成功后,修改/etc/fstab

//192.168.1.1/your/file/path  /media/local/mount/point/       cifs    user=your-name-on-server,password=password,uid=your-name-on-ubuntu,gid=your-name-on-local     0       0 

重启即可。


注意:

1、ubuntu挂载失败

在ubuntu下挂载可能会提示:

mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

cat /var/log/syslog

kernel: [ 7594.398736] CIFS VFS: Send error in SessSetup = -13
kernel: [ 7594.398836] CIFS VFS: cifs_mount failed w/return code = -13

这时需要在选项中增加sec=xxxx

xxxx该怎么确定,可以试试
smbclient //192.168.1.1/your/file/path -U your-name-on-server

Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.0.23c-2]
Server not using user level security and no password supplied.
Server requested LANMAN password (share-level security) but 'client lanman auth = no' or 'client ntlmv2 auth = yes'
tree connect failed: NT_STATUS_ACCESS_DENIED

但在fedora下则不需要sec这个参数,暂时无解。


2、其他挂载方法

编辑一个脚本

#!/bin/sh 
sshfs your-name-on-server@192.168.1.1/your/file/path /media/local/mount/point/ 
-o allow_other 

运行即可。


CIFS通过autofs自动挂载:http://www.linuxdiyf.com/linux/1855.html