在Linux上挂载Windows共享文件夹,如何开机自动挂载(mount)
使用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?目錄里,查看當(dāng)前所有文件,發(fā)現(xiàn),所屬者和所屬組都是root,嘗試著用chown和chmod命令去修改,結(jié)果是Permission denied。
在網(wǎng)上查閱了相關(guān)信息,原來參數(shù)-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,最后調(diào)整掛載命令如下:
| 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" |
?
?
?
?
掛載出現(xiàn)問題匯總:
一、掛載時,用戶/密碼錯誤
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
對應(yīng)?/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)
對應(yīng)?/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
http://www.apoyl.com/?p=1432
轉(zhuǎn)載于:https://www.cnblogs.com/fx2008/p/5056610.html
與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的在Linux上挂载Windows共享文件夹,如何开机自动挂载(mount)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [转]ActionScript 3.0入
- 下一篇: 《利用python进行数据分析》读书笔记