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

Che*_*ang 30 mount

发现命令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)
Run Code Online (Sandbox Code Playgroud)

已确认挂载点/home/directory/path和凭证文件/etc/user的存在和可访问性 。相关模块和服务也已启用,即,

 ae429-1105 etc # lsmod |egrep 'fuse|cifs'
 fuse                   72589  5 
 cifs                  312131  0
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

这个问题已经被许多用户发现,例如一个例子另请注意,在我的 Ubuntu/debian 系统中执行的相同命令能够成功挂载。

问题机器中的其他信息:

ae429-1105 etc # mount.cifs --version
mount.cifs version: 6.1
Run Code Online (Sandbox Code Playgroud)

debian/ubuntu 安装的 mount.cifs 版本是 6.0

小智 17

如果您尝试从较新版本的 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
Run Code Online (Sandbox Code Playgroud)

..我的域名、用户名和密码包含在 .cifs_user 文件中。

显然,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.
Run Code Online (Sandbox Code Playgroud)

  • 非常感谢与 vers= 选项相关的解决方案!它对我有用,只是倒退......将 opensuse 从 42.3 版本升级到 15.1 后,用于安装网络驱动器的 fstab 条目在 15.1 中停止工作。我使用了选项 vers=1.0 并猜猜是什么......可能是 15.1 使用了无法找到远程目录的较新版本的 SMB 协议。 (4认同)

小智 8

您可以使用nodfs选项吗?即对于您的-o选项输入传递输入如下。

-o credentials=/etc/user,rw,iocharset=utf8,file_mode=0777,dir_mode=0777,nodfs
Run Code Online (Sandbox Code Playgroud)

即附加 ,nodfs

它对我有用。


Kla*_*aus 7

尝试安装软件包 keyutils:

sudo apt-get install keyutils
Run Code Online (Sandbox Code Playgroud)

不确定为什么这会有所帮助,也许其他人在这里有答案。但至少它对我有用:使用 keyutils,cifs 安装工作得很好。


Chr*_*ris 5

我在 Ubuntu 18.04 上遇到了这个问题。问题是我需要 keyutils 包来进行 Kerberos 身份验证(sec=krb5安装选项),它没有与 cifs-utils(提供 mount.cifs)一起安装。我不确定 Gentoo 上的包名称是否相同。(感谢https://forum.zentyal.org/index.php?topic=18601.0的解决方案。)