标签:
使用mount命令在Ubuntu上挂接Windows的共享文件夹
sudo mount //192.168.0.1/linux /mnt/win -o username=user,password=pass dir_mode=777 file_mode=777
说明:
//192.168.0.1/linux windows共享文件夹路径
/mnt/win ubuntu中的挂载点
---------------------------------------------------------------------------------------------------------
按照一般的思路,我们先将文件夹挂载上去,命令如下:
1 |
mkdir /mnt/share_software |
2 |
mount //192.9.206.43/share_software /mnt/share_software -o username= "edures" ,password= "tj$123" |
然后进入到 /mnt/share_software 目录里,查看当前所有文件,发现,所属者和所属组都是root,尝试着用chown和chmod命令去修改,结果是Permission denied。
在网上查阅了相关信息,原来参数-o还可以加入以某个账号的uid和gid的方式挂载,挂载成功后该目录下的所有文件属性都属于这个账号了,
比如说,我想让 /mnt/share_software 所属用户、用户组分别为 www、www。首先,得通过如下命令查找出 用户www的uid,和用户组www的guid分别为多少:
1 |
[root@localhost ~] # cat /etc/passwd |
2 |
...... |
3 |
www:x:501:501::/home/www:/bin/sh |
4 |
mysql:x:502:502::/home/mysql:/usr/sbin/nologin |
5 |
mongodb:x:503:503::/home/mongodb:/usr/sbin/nologin |
6 |
...... |
如上所示,www的uid为501,gid为501,最后调整挂载命令如下:
1 |
#先删除掉先前的挂载 |
2 |
umount /mnt/share_software |
3 |
4 |
#挂载后,让Linux目录所属用户和用户组分别为 www:www |
5 |
mount //192.9.206.43/share_software /mnt/share_software -o username= "edures" ,password= "tj$123" ,uid= "501" ,gid= "501" |
开机自动挂载:
在文件 /etc/rc.local 中(用root用户)追加如下上述命令:
1 |
mount //192.9.206.43/share_software /mnt/share_software -o username= "edures" ,password= "tj$123" ,uid= "501" ,gid= "501" |
挂载出现问题汇总:
一、挂载时,用户/密码错误
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
对应 /var/log/messages 记录
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/messages 记录
1 |
Oct 12 16:20:06 localhost kernel: CIFS VFS: cifs_mount failed w/ return code = -6 |
2 |
Oct 12 16:20:17 localhost kernel: CIFS VFS: cifs_mount failed w/ return code = -6 |
3 |
Oct 12 16:20:17 localhost kernel: CIFS VFS: cifs_mount failed w/ return code = -6 |
有时候还是会挂载失败,提示登录失败,那就后输入密码吧:
mount //192.9.206.43/share_software /mnt/share_software -o username="edures",uid="500",gid="500"
再输入密码 tj$123
【附】Linux挂载Linux: mount -t nfs 172.16.8.113:/mnt/reslib /mnt/reslib -o proto=tcp -o nolock
参考:
http://carllai.blog.51cto.com/1664997/1351447
http://www.cnblogs.com/52linux/archive/2012/03/07/2384400.html
在Linux上挂载Windows共享文件夹,如何开机自动挂载(mount)
标签:
原文地址:http://www.cnblogs.com/fx2008/p/5056610.html