[Solved] mount windows share folder failed

[Solved] mount windows share folder failed

起因是要備份 ubuntu 上面的資料,寫了一個 shell 掛上 crontab,
先將 windows share folder mount 起來,再將欲備份的檔案壓縮存放到 share folder。

mount 指令如下

>mount -t cifs //xxx.xxx.xxx.xxx/backupFiles/ /mnt/hostBackup/ -o username="USERNAME",password="PASSWORD"

納悶的是 crontab 可以正常備份,可是直接執行 mount 指令,會出現下列錯誤訊息。

"mount 遠端輸入錯誤"

解決方案:

1. apt-get install cifs-utils

2. 重新執行 mount 加上 -v
>mount -v -t cifs //xxx.xxx.xxx.xxx/backupFiles/ /mnt/hostBackup/ -o username="USERNAME",password="PASSWORD"
會看到下列錯誤訊息
ip address xxx.xxx.xxx.xxx override specified
mount.cifs kernel mount options: ip=xxx.xxx.xxx.xxx,unc=\\xxx.xxx.xxx.xxx\backupFiles,user=USERNAME,pass=********
mount error(121): Remote I/O error
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

3. man mount.cifs,看一下 man page,其中一段寫著
       vers=
           SMB protocol version. Allowed values are:

           ·   1.0 - The classic CIFS/SMBv1 protocol. This is the default.

           ·   2.0 - The SMBv2.002 protocol. This was initially introduced in Windows Vista Service Pack 1, and Windows Server 2008. Note that the initial release version of Windows Vista spoke a
               slightly different dialect (2.000) that is not supported.

           ·   2.1 - The SMBv2.1 protocol that was introduced in Microsoft Windows 7 and Windows Server 2008R2.

           ·   3.0 - The SMBv3.0 protocol that was introduced in Microsoft Windows 8 and Windows Server 2012.

           Note too that while this option governs the protocol version used, not all features of each version are available.

4. default vers=1.0,我的平台是 Windows 7,必須指定為 2.1 才對
所以完整的 mount 指令如下
>mount -v -t cifs //xxx.xxx.xxx.xxx/backupFiles/ /mnt/hostBackup/ -o username="USERNAME",password="PASSWORD",vers=2.1

5. done

留言

這個網誌中的熱門文章

相見恨晚的自動化測試開發工具 Sikuli

[IIS] 自我簽署憑證來啟用SSL

台北市安心地圖