Mount

不能使用 mount.cifs: mount error(2): No such file or directory

  • January 20, 2022

發現命令mount.cifs無法在帶有systemd的 gentoo 系統中執行

ae429-1105 etc # mount -t cifs //file.abc.edu.au/user /home/directory/path -o credentials=/etc/user,rw,iocharset=utf8,file_mode=0777,dir_mode=0777
mount error(2): No such file or directory
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

已確認掛載點 /home/directory/path和憑證文件**/etc/user**的存在和可訪問性。相關模組和服務也已啟用,即

ae429-1105 etc # lsmod |egrep 'fuse|cifs'
fuse                   72589  5 
cifs                  312131  0

ae429-1105 etc # systemctl -t service -a |grep Samba
nmbd.service                         loaded active   running Samba NetBIOS                     name server
smbd.service                         loaded active   running Samba SMB/CIFS     server
winbindd.service                     loaded inactive dead    Samba Winbind daemon

許多使用者已經發現了這個問題,例如一個例子另請注意,在我的 Ubuntu/debian 系統中執行的相同命令能夠成功掛載。

問題機器中的其他資訊:

ae429-1105 etc # mount.cifs --version
mount.cifs version: 6.1

debian/ubuntu 中安裝的 mount.cifs 版本為 6.0

如果您嘗試從較新版本的 Windows 安裝共享,您可能需要向 mount 命令提供 vers= 選項以強制使用 3.0 版。我們的一個文件伺服器最近升級到 2012R2,那時我的掛載停止工作。將其設置為 vers=3.0 解決了該問題。像大多數 Samba/CIFS 錯誤一樣,“沒有這樣的文件或目錄”消息沒有多大幫助。

舉個例子:

# mount -t cifs //win2012r2/someshare -o cred=/home/foo/.cifs_user,vers=3.0 /mnt/tmp

..我的域、使用者名和密碼包含在 .cifs_user 文件中:

user=MyUser
password=MyPassword
domain=MyDomain

顯然,smbmount 預設使用較新版本的 SMB 協議,因為它可以正常工作,也沒有任何特殊選項。

請注意下面的預設協議版本是 1.0。

從 mount.cifs 手冊頁:

vers=arg
      SMB protocol version. Allowed values are:

      · 1.0 - The classic CIFS/SMBv1 protocol.

      · 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.

      · 3.02 or 3.0.2 - The SMBv3.0.2 protocol that was introduced in Microsoft Windows 8.1 and Windows Server 2012R2.

      · 3.1.1 or 3.11 - The SMBv3.1.1 protocol that was introduced in Microsoft Windows 10 and Windows Server 2016.

      · 3 - The SMBv3.0 protocol version and above.

      · default - Tries to negotiate the highest SMB2+ version supported by both the client and server.

      If no dialect is specified on mount vers=default is used.  To check Dialect refer to /proc/fs/cifs/DebugData

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

      The default since v4.13.5 is for the client and server to negotiate the highest possible version greater than or equal to 2.1. In kernels prior to v4.13,
      the default was 1.0. For kernels between v4.13 and v4.13.5 the default is 3.0.

引用自:https://unix.stackexchange.com/questions/120677