Linux

安裝 cifs:“不支持操作”

  • January 7, 2022

類似的問題不同,我什至無法連接 smbclient。

samba 共享在 Windows 中執行良好並且自動執行,但在 Linux 中我根本無法安裝它,並且錯誤消息充其量是神秘的。這是我的 samba.conf:

[global]
   dos charset = CP437
   netbios name = REDACTED
   server string = Lab
   server role = standalone server
   map to guest = Bad User
   obey pam restrictions = Yes
   smb passwd file = /var/etc/private/smbpasswd
   private dir = /var/etc/private
   max log size = 51200
   server min protocol = SMB2
   time server = Yes
   deadtime = 15
   max open files = 11070
   hostname lookups = Yes
   load printers = No
   printcap name = /dev/null
   disable spoolss = Yes
   dns proxy = No
   pid directory = /var/run/samba
   panic action = /usr/local/libexec/samba/samba-backtrace
   idmap config * : backend = tdb
   acl allow execute always = Yes
   create mask = 0666
   directory mask = 0777
   directory name cache size = 0
   kernel change notify = No
   map archive = No
   map readonly = no
   store dos attributes = Yes
   strict locking = No

[common]
   comment = Lab Common share
   path = /mnt/pool/common
   read only = No
   inherit acls = Yes
   hosts allow = XXX.XXX.XX.X/24, XXX.XX.XX.X/24 <-- redacted
   hide dot files = No
   veto files = /.snap/.windows/.zfs/
   vfs objects = zfsacl, streams_xattr, aio_pthread
   zfsacl:acesort = dontcare
   nfs4:chown = yes
   nfs4:acedup = merge
   nfs4:mode = special
   recycle:subdir_mode = 0700
   recycle:directory_mode = 0777
   recycle:touch = yes
   recycle:versions = yes
   recycle:keeptree = yes
   recycle:repository = .recycle/%U

錯誤資訊是:

[as@localhost ~]$ sudo mount -t cifs -o username=removed,password=removed  //server.ip.address/common /media/windowsshare/
mount error(95): Operation not supported

一個完全無用的消息。

啟用調試的 dmesg:

[237179.795551] fs/cifs/cifsfs.c: Devname: //132.239.27.172/common flags: 0
[237179.795563] fs/cifs/connect.c: Username: lauria
[237179.795565] fs/cifs/connect.c: file mode: 0x1ed  dir mode: 0x1ed
[237179.795600] fs/cifs/connect.c: CIFS VFS: in cifs_mount as Xid: 44 with uid: 0
[237179.795600] fs/cifs/connect.c: UNC: \\132.239.27.172\common
[237179.795605] fs/cifs/connect.c: Socket created
[237179.795606] fs/cifs/connect.c: sndbuf 16384 rcvbuf 87380 rcvtimeo 0x1b58
[237179.795897] fs/cifs/fscache.c: cifs_fscache_get_client_cookie: (0xffff8803e0aa4800/0xffff880035d25580)
[237179.795898] fs/cifs/connect.c: Demultiplex PID: 25817
[237179.795902] fs/cifs/connect.c: CIFS VFS: in cifs_get_smb_ses as Xid: 45 with uid: 0
[237179.795903] fs/cifs/connect.c: Existing smb sess not found
[237179.795907] fs/cifs/cifssmb.c: Requesting extended security.
[237179.795910] fs/cifs/transport.c: For smb_command 114
[237179.795912] fs/cifs/transport.c: Sending smb: smb_len=78
[237179.801062] fs/cifs/connect.c: RFC1002 header 0x25
[237179.801067] fs/cifs/misc.c: checkSMB Length: 0x29, smb_buf_length: 0x25
[237179.801090] fs/cifs/transport.c: cifs_sync_mid_result: cmd=114 mid=1 state=4
[237179.801093] fs/cifs/cifssmb.c: Dialect: 65535
[237179.801094] fs/cifs/cifssmb.c: negprot rc -95
[237179.801097] fs/cifs/connect.c: CIFS VFS: leaving cifs_get_smb_ses (xid = 45) rc = -95
[237179.801100] fs/cifs/fscache.c: cifs_fscache_release_client_cookie: (0xffff8803e0aa4800/0xffff880035d25580)
[237179.801262] fs/cifs/connect.c: CIFS VFS: leaving cifs_mount (xid = 44) rc = -95
[237179.801263] CIFS VFS: cifs_mount failed w/return code = -95

我嘗試了許多不同的-sec選項——它們都失敗了,所有的錯誤資訊都是一樣的。smbclient 也沒有幫助:

smbclient //132.239.27.172/common -U username%password
protocol negotiation failed: NT_STATUS_INVALID_NETWORK_RESPONSE

這在 Windows 上如何工作,但在 linux 上卻完全不行?

好的,“我”想通了——出於某種原因,添加“vers=3.0”使其工作。我不知道為什麼沒有這個會出現問題,或者為什麼它會起作用。但如果其他人在使用他們的 freenas 設置時遇到此問題,以供將來參考。

填寫@Ken 和@Paul 的答案:高於v1 時需要指定SMB 版本:

mount -t cifs \
 -o username=USERNAME,vers=3.0 \
 //server/share \
 /mnt/point

自 2.5.42 起,Linux cifs 核心客戶端已包含在核心中。cifs 協議(以及相關的早期 SMB 方言)是預設協議(“vers=1.0”),但可以通過指定“vers=2.0”來選擇對較新方言(SMB2.02、SMB2.1 和 SMB3 和 SMB3.02)的支持或安裝時的“vers=2.1”或“vers=3.0”或“vers=3.02”。– https://wiki.samba.org/index.php/LinuxCIFSKernel

對於 smbclient,咒語是-m, --max-protocol=LEVEL

smbclient -L server -U username -m SMB2

我沒有找到 smbclient 允許的級別列表。根據 Marc Muehlfeld 在這個執行緒中的說法,Windows 使用的版本是:

  • SMB 2.0 由 Vista/2008 引入
  • Win7/2008R2 的 SMB 2.1
  • SMB 2.2 又名 Win8/2012 的 3.0
  • SMB 3.02 由 8.1/2012R2

有幾種不同的mount錯誤消息可以追溯到不匹配的協議級別。一個非詳盡的列表(隨時編輯答案並添加更多):

mount error(13): Permission denied
mount error(95): Operation not supported
mount error(121): Remote I/O error

最後,我看到一些評論表明sec=ntlmv2不應該再遵循使用該選項和類似建議的經常引用的建議。所以至少不要混搭secvers.

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