7

Using a mount -t cifs -v <address> returns with Host is Down error when connecting to a server running SMB 2.0 (with SMB 1.0 disabled). A workaround is to specify vers=2.0 to the argument list of mount. This works fine if you're mounting via command line and have the ability to specify this argument. But, when using a GUI or some program that calls mount on your behalf, this argument is not specified.

Is there a way to make SMB 2.0+ the default for all mount -t cifs calls, regardless what calls it? Perhaps in smb.conf?

Currently running Arch Linux.

EDIT: Added min protocol = SMB2 to /etc/samba/smb.conf and restarted the service. Both mount and smbclient still require the SMB version to be specified before connecting to the server.

EDIT2: Adding client min protocol = SMB2 and client max protocol = SMB3 allows smbclient to connect to the server without specifying the version argument. But, mount still doesn't respect the newly added lines in smb.conf.

2 Answers 2

5
+100

Unfortunately the kernel's cifs filesystem module does not read /etc/samba/smb.conf at all. The CIFS client module that allows mounting of Windows fileshares is completely separate from Samba.

The default protocol level in the cifs module was changed to SMB3 in vanilla kernel version 4.13, and a multi-dialect negotiation patch (effectively setting the default to "SMB2.1 or later") was added to the vanilla kernels in September 2017.

I'm pretty sure that the "enterprise" Linux distributions have backported the patch to earlier kernels, but on Arch your only option may be to upgrade to kernel version 4.13 or later.

Here's a link to the relevant patch in kernel.org Git. The commit ID might be helpful in tracking the patch in specific kernel versions.

2
  • Thanks for this. I don't suppose you know if it's been incorporated in recent Debian kernels do you? Jul 1, 2018 at 19:20
  • 1
    Debian 9 (the current stable) is at kernel 4.9.88-1+deb9u1 (although named linux-image-4.9.0-6-amd64) , and unfortunately the only CIFS patch it seems to have is for CVE-2018-1066. Debian testing has kernel 4.16.*, so it already has the patch via upstream.
    – telcoM
    Jul 2, 2018 at 10:53
0

As part of researching this issue I have written a script that adjusts the CIFS parameters for the mount command.

#!/bin/bash
#
# Force SMB2.0 mount. We prefix the options list because a later explicit
# "vers=..." option overrides the one we add.
########################################################################
#
args=()

# Only consider checking options if we have a CIFS mount
[[ "$*" =~ '-t cifs' ]] && cifs=yes || cifs=

options=
for arg in "$@"
do
    if [[ $next == 'options' ]]
    then
        # Prefix version to options string
        arg="vers=2.0,$arg"
        next=
    fi

    args+=("$arg")

    # CIFS options check
    if [[ $cifs == 'yes' ]]
    then
        [[ $arg == '-o' ]] && next=options
    fi
done

logger -p user.notice -t "${0/*\/}" "intercepted $0 ${args[*]}"
exec "$0.real" "${args[@]}"

Install this script as /bin/mount.sh. Then run these commands

chmod a+x /bin/mount.sh
mv /bin/mount /bin/mount.real && ln -fs mount.sh /bin/mount

Uninstall it with

test -L /bin/mount && rm -f /bin/mount && mv -f /bin/mount.real /bin/mount
rm -f /bin/mount.sh

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .