安装错误时未指定方言,如何使用 autofs/Fedora 26、Drobo FS 设置 vers=1.0

安装错误时未指定方言,如何使用 autofs/Fedora 26、Drobo FS 设置 vers=1.0

我们正在使用带有 4.13.9 内核和 NIS 的 Fedora 26,并且我意识到了默认 CIFS/Samba 版本现在为 3.0。但是我们使用较旧的 Drobo FS,他们的支持人员说它仅适用于 SMB 版本 1.0。我们没有安装 Drobo,/etc/fstab因为它有时会在启动时失败,因此我们使用 autofs/automount。我们有一个正在运行的 cron 作业,应该会调用/etc/auto.cifs并记录以下配置文件的内容。我添加了vers=1.0所有我能想到的地方。下面的命令结果ypcat -k显示选项似乎没有传递给mount命令。我是否在某个地方缺少配置文件?我已经 grep 了所有内容/etc以查找所有出现的mount或 CIFS,但除了注释之外什么都没有返回。也许我遗漏了一些对我来说并不明显但可能对阅读本文的人来说很明显的东西......

cat /etc/auto.cifs 
#!/bin/bash
# Automount config file for drobo network storage device
#
# This file must be executable to work! chmod 755!

key="$1"
# Note: create a cred file for each windows/Samba-Server in your network
#       which requires password authentification.  The file should contain
#       exactly two lines:
#          username=user
#          password=*****
#       Please don't use blank spaces to separate the equal sign from the
#       user account name or password.
credfile="/etc/auto.smb.$key"
# Note: Use cifs instead of smbfs:
mountopts="-fstype=cifs,vers=1.0,file_mode=0600,dir_mode=0700,uid=root,gid=root,wsize=8192"
smbclientopts="-m SMB1"
for P in /bin /sbin /usr/bin /usr/sbin
do
        if [ -x $P/smbclient ]
        then
                SMBCLIENT=$P/smbclient
                break
        fi
done
[ -x $SMBCLIENT ] || exit 1
if [ -e "$credfile" ]
then
        mountopts=$mountopts"vers=1.0,credentials=$credfile"
        smbclientopts="-A "$credfile
else
        smbclientopts="-N"
fi
$SMBCLIENT $smbclientopts -gL $key 2>>/var/log/autofs.log \
   | awk -v key="$key" -v opts="$mountopts" -F'|' -- '
        BEGIN   { ORS=""; first=1 }
        /Disk/  { if (first) { print opts; first=0 };
                  gsub(/ /, "\\ ", $2);
                           sub(/\$/, "\\$", $2);
                                       print " \\\n\t /" $2, "://" key "/" $2 }
        END     { if (!first) print "\n"; else exit 1 }
        '

下面是:

cat /etc/auto.smb
#!/bin/bash

# This file must be executable to work! chmod 755!

# Automagically mount CIFS shares in the network, similar to
# what autofs -hosts does for NFS.

# Put a line like the following in /etc/auto.master:
# /cifs  /etc/auto.smb --timeout=300
# You'll be able to access Windows and Samba shares in your network
# under /cifs/host.domain/share

# "smbclient -L" is used to obtain a list of shares from the given host.
# In some environments, this requires valid credentials.

# This script knows 2 methods to obtain credentials:
# 1) if a credentials file (see mount.cifs(8)) is present
#    under /etc/creds/$key, use it.
# 2) Otherwise, try to find a usable kerberos credentials cache
#    for the uid of the user that was first to trigger the mount
#    and use that.
# If both methods fail, the script will try to obtain the list
# of shares anonymously.

get_krb5_cache() {
    cache=
    uid=${UID}
    for x in $(ls -d /run/user/$uid/krb5cc_* 2>/dev/null); do
        if [ -d "$x" ] && klist -s DIR:"$x"; then
        cache=DIR:$x
            return
        fi
    done
    if [ -f /tmp/krb5cc_$uid ] && klist -s /tmp/krb5cc_$uid; then
        cache=/tmp/krb5cc_$uid
        return
    fi
}

key="$1"
opts="-fstype=cifs -m SMB1"

for P in /bin /sbin /usr/bin /usr/sbin
do
    if [ -x $P/smbclient ]
    then
        SMBCLIENT=$P/smbclient
        break
    fi
done

[ -x $SMBCLIENT ] || exit 1

creds=/etc/creds/$key
if [ -f "$creds" ]; then
    opts="$opts"',vers=1.0,uid=$UID,gid=$GID,credentials='"$creds"
    smbopts="-A $creds"
else
    get_krb5_cache
    if [ -n "$cache" ]; then
        opts="$opts"',vers=1.0,multiuser,cruid=$UID,sec=krb5i'
        smbopts="-k"
        export KRB5CCNAME=$cache
    else
        opts="$opts"',vers=1.0,guest'
        smbopts="-N"
    fi
fi

$SMBCLIENT $smbopts -gL "$key" 2>/dev/null| awk -v "key=$key" -v "opts=$opts" -F '|' -- '
    BEGIN   { ORS=""; first=1 }
    /Disk/  {
          if (first)
            print opts; first=0
          dir = $2
          loc = $2
          # Enclose mount dir and location in quotes
          # Double quote "$" in location as it is special
          gsub(/\$$/, "\\$", loc);
          gsub(/\&/,"\\\\&",loc)
          print " \\\n\t \"/" dir "\"", "\"://" key "/" loc "\""
        }
    END     { if (!first) print "\n"; else exit 1 }
    '

但是在运行时:

ypcat -k auto.cifs

$SMBCLIENT $smbclientopts -gL $key 2>>/var/log/autofs.log    | awk -v key="$key" -v opts="$mountopts" -F'|' -- '
[ -x $SMBCLIENT ] || exit 1
credfile="/etc/auto.smb.$key"
do
done
else
fi
for P in /bin /sbin /usr/bin /usr/sbin
if [ -e "$credfile" ]
key="$1"
mountopts="fstype=cifs,file_mode=0600,dir_mode=0700,uid=root,gid=root"
smbclientopts=""
then

以下是一些调试 autofs 日志:

Oct 31 16:12:20 workstation automount[5234]: handle_packet_missing_indirect: token 508, name drobo-down, request pid 10165
Oct 31 16:12:20 workstation automount[5234]: attempting to mount entry /drobo-up/drobo-down
Oct 31 16:12:20 workstation automount[5234]: lookup_mount: lookup(yp): looking up drobo-down
Oct 31 16:12:20 workstation automount[5234]: lookup_mount: lookup(yp): drobo-down -> -fstype=cifs,rw,user,suid,credentials=/etc/auto.smb.drobo-up ://drobo-up/drobo-down
Oct 31 16:12:20 workstation automount[5234]: parse_mount: parse(sun): expanded entry: -fstype=cifs,rw,user,suid,credentials=/etc/auto.smb.drobo-up ://drobo-up/drobo-down
Oct 31 16:12:20 workstation automount[5234]: parse_mount: parse(sun): gathered options: fstype=cifs,rw,user,suid,credentials=/etc/auto.smb.drobo-up
Oct 31 16:12:20 workstation automount[5234]: parse_mount: parse(sun): dequote("://drobo-up/drobo-down") -> ://drobo-up/drobo-down
Oct 31 16:12:20 workstation automount[5234]: parse_mount: parse(sun): core of entry: options=fstype=cifs,rw,user,suid,credentials=/etc/auto.smb.drobo-up, loc=://drobo-up/drobo-down
Oct 31 16:12:20 workstation automount[5234]: sun_mount: parse(sun): mounting root /drobo-up, mountpoint drobo-down, what //drobo-up/drobo-down, fstype cifs, options rw,user,suid,credentials=/etc/auto.smb.drobo-up
Oct 31 16:12:20 workstation automount[5234]: do_mount: //drobo-up/drobo-down /drobo-up/drobo-down type cifs options rw,user,suid,credentials=/etc/auto.smb.drobo-up using module generic
Oct 31 16:12:20 workstation automount[5234]: mount_mount: mount(generic): calling mkdir_path /drobo-up/drobo-down
Oct 31 16:12:20 workstation automount[5234]: mount_mount: mount(generic): calling mount -t cifs -o rw,user,suid,credentials=/etc/auto.smb.drobo-up //drobo-up/drobo-down /drobo-up/drobo-down
Oct 31 16:12:20 workstation kernel: No dialect specified on mount. Default has changed to a more secure dialect, SMB2.1 or later (e.g. SMB3), from CIFS (SMB1). To use the less secure SMB1 dialect to access old servers which do not support SMB3 (or SMB2.1) specify vers=1.0 on mount.
Oct 31 16:12:20 workstation automount[5234]: >> mount error(112): Host is down
Oct 31 16:12:20 workstation automount[5234]: >> Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
Oct 31 16:12:20 workstation kernel: CIFS VFS: cifs_mount failed w/return code = -112
Oct 31 16:12:20 workstation automount[5234]: mount(generic): failed to mount //drobo-up/drobo-down (type cifs) on /drobo-up/drobo-down
Oct 31 16:12:20 workstation automount[5234]: dev_ioctl_send_fail: token = 508
Oct 31 16:12:20 workstation automount[5234]: failed to mount /drobo-up/drobo-down
Oct 31 16:12:20 workstation automount[5234]: handle_packet: type = 3
Oct 31 16:12:20 workstation automount[5234]: handle_packet_missing_indirect: token 509, name drobo-down, request pid 10182
Oct 31 16:12:20 workstation automount[5234]: dev_ioctl_send_fail: token = 509
Oct 31 16:12:20 workstation automount[5234]: handle_packet: type = 3
Oct 31 16:12:20 workstation automount[5234]: handle_packet_missing_indirect: token 510, name drobo-down, request pid 10165
Oct 31 16:12:20 workstation automount[5234]: dev_ioctl_send_fail: token = 510

添加 fstab 内容:

猫/etc/fstab

#
# /etc/fstab
# Created by anaconda on Tue Aug 16 10:22:50 2011
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
# /dev/mapper/vg_server-LogVol00 /                       ext4    defaults        1 1 UUID=01bbe54b-06d4-4537-aa87-9c9618996000 /boot    ext4    defaults        1 2 /dev/mapper/vg_server-LogVol02 /home     ext4    defaults        1 2 /dev/mapper/vg_server-LogVol03 /usr/local              ext4    defaults        1 2 /dev/mapper/vg_server-LogVol01 swap                    swap    defaults        0 0 tmpfs                   /dev/shm                tmpfs   defaults        0 0 devpts                  /dev/pts           devpts  gid=5,mode=620  0 0 sysfs                   /sys               sysfs   defaults        0 0 proc                    /proc              proc    defaults        0 0

答案1

我找到了添加vers=1.0选项的位置。在主 NIS 服务器上,我们为每个校园的两个 Drobo 单元提供了几个文件:

cat /etc/auto.drobo-uptown

drobo-downtown -fstype=cifs,vers=1.0,rw,user,suid,credentials=/etc/auto.smb.drobo-uptown ://drobo-uptown/drobo-downtown

但是另一件让我困惑的事情是,我必须make -C /var/yp在对上述文件进行更改后运行,然后 NIS 域中的其他工作站/服务器才能开始看到更改。

还进行了更改cifs-utils 文档,以及 setcifsacl 中的小错误修复

相关内容