由於我最近獲得了新的 Mac Pro(運行 Catalina 10.15.2),我使用 10 GBit 乙太網路將其連接到我的 Debian 10 / Proxmox 伺服器。
然而,當連接到共享時,我只能獲得 150-300 MB/s 的讀取/寫入效能。
這是我目前的 smb.conf:
[global]
netbios name = server
realm = MY.DOMAIN
security = ADS
workgroup = MYDOMAIN
wins server = my.domain.test
winbind enum users = Yes
winbind enum groups = Yes
winbind use default domain = Yes
winbind refresh tickets = Yes
winbind nested groups = No
idmap config MYDOMAIN:backend = ad
idmap config MYDOMAIN:schema_mode = rfc2307
idmap config MYDOMAIN:range = 10000-20000
log file = /var/log/samba/log.%m
log level = 1
printcap name = /etc/printcap
load printers = no
username map = etc/samba/user.map
vfs objects = recycle acl_xattr catia fruit streams_xattr
map acl inherit = yes
store dos attributes = yes
oplocks = no
# Enable the recycle bin
recycle:repository = /tank/storage/.recycle/%U
recycle:touch = Yes
recycle:keeptree = Yes
recycle:versions = Yes
recycle:noversions = *.tmp,*.temp,*.o,*.obj,*.TMP,*.TEMP
recycle:exclude = *.tmp,*.temp,*.o,*.obj,*.TMP,*.TEMP
recycle:excludedir = /recycle,/tmp,/temp,/TMP,/TEMP
# Apple
fruit:aapl = yes
fruit:encoding = native
fruit:locking = none
fruit:metadata = stream
fruit:resource = file
[share1]
path = /tank/share1
read only = no
valid users = @"MYDOMAIN\share1-Access"
[share2]
path = /tank/share2
read only = no
valid users = @"MYDOMAIN\share2-Access"
[timemachine]
path = /tank/timemachine
read only = no
valid users = @"MYDOMAIN\timemachine-Access"
oplocks = no
fruit:aapl = yes
fruit:time machine = yes
[downloads]
path = /tank/downloads
read only = no
valid users = @"MYDOMAIN\downloads-Acccess"
[cloud-backup]
path = /tank/cloud-backup
read only = no
writeable = yes
valid users = @"MYDOMAIN\cloud-backup-Access"
答案1
SMB3 在 macOS Big Sur 及更高版本上的實作具有多通道支援(看這篇文章)。這有助於大大提高性能;但是,在 Samba 4.15 之前,server multi channel support = Yes
每次安裝共用的用戶端重新啟動時,/etc/samba/smb.conf 中的設定都會導致出現恐慌。
一段時間以來,我一直在 macOS 客戶端 (/etc/nsmb.conf) 上使用以下設定:
signing_required = no
protocol_vers_map=6
port445=no_netbios
我還在 Samba 中停用了許多我不需要的功能:
[global]
allow dns updates = disabled
client min protocol = SMB3_11
dcerpc endpoint servers = rpcecho
delete veto files = Yes
disable netbios = Yes
disable spoolss = Yes
dns forwarder = 192.168.1.1
dns proxy = No
enhanced browsing = No
# Next line requires catia (needed if no Windows clients?)
fruit:encoding = native
fruit:metadata = stream
# Do not use NFS access control entries
fruit:nfs_aces = No
# Enable extended attributes (requires streams_xattr)
fruit:resource = xattr
# Next line is already the default
;fruit:zero_file_id = Yes
host msdfs = No
inherit acls = Yes
inherit permissions = Yes
lm announce = No
load printers = No
log file = /var/log/samba/log.smbd
log level = 1
logging = file
max log size = 10000
# Next 2 lines defer mDNS config to Avahi (better for icon and Time Machine)
mdns name = mdns
multicast dns register = No
name resolve order = host bcast
pam password change = Yes
panic action = /usr/share/samba/panic-action %d
passwd chat = "*New Password:*" %n\n "*Reenter New Password:*" %n\n "*Password changed.*"
passwd program = /usr/bin/passwd %u
printcap cache time = 0
printcap name = /dev/null
printable = No
printing = bsd
restrict anonymous = 2
rpc_daemon:spoolssd = disabled
rpc_server:epmapper = disabled
rpc_server:winreg = disabled
rpc_server:lsarpc = disabled
rpc_server:samr = disabled
rpc_server:netlogon = disabled
rpc_server:netdfs = disabled
rpc_server:dssetup = disabled
rpc_server:wkssvc = disabled
rpc_server:spoolss = disabled
rpc_server:svcctl = disabled
rpc_server:ntsvcs = disabled
rpc_server:eventlog = disabled
rpc_server:initshutdown = disabled
rpc_server:mdssvc = disabled
server max protocol = SMB3_11
server min protocol = SMB3_11
# Next line experimental until 4.15 - macOS clients support multi-channel SMB3
;server multi channel support = Yes
server role = standalone server
server services = rpc, smb
server string = %h server (Samba 4.13.14, Ubuntu 21.10)
show add printer wizard = No
smb ports = 445
unix password sync = Yes
use sendfile = Yes
veto files = /._*/.DS_Store/
vfs objects = catia fruit streams_xattr
[homes]
browseable = No
comment = Home Directory
fruit:time machine = No
guest ok = No
spotlight = No
valid users = %S
writable = Yes
[Backup]
comment = Time Machine
fruit:time machine = Yes
guest ok = No
path = /external/%U
spotlight = No
valid users = %U
writable = Yes
將來,我計劃重新啟用伺服器多通道支援。不想安裝從原始碼編譯 Samba 4.15 所需的所有相依性。
順便說一句,我發現本文如果您使用的是 ZFS,那麼這很有趣(我根據以 Tank/ 開頭的目錄名稱懷疑)。
答案2
SMB 在 Mac 上的表現非常糟糕,而且一直都是如此。我的建議:不要擔心,只需安裝 netatalk 即可;您將毫無問題地獲得 1GB/s 的速度。或是使用NFS,也能達到1GB/s沒有問題。然而 Netatalk 是最安全的選擇,有些應用程式可能透過 NFS 表現奇怪。另外,Netatalk 在身分驗證、檔案權限等方面的行為與 Samba 一致。
我甚至使用“Hackintoshes”比較了性能:運行 Windows 的同一台機器通過 SMB 達到 900MB/s,但作為 Mac 運行時達到 250MB/s;但透過 Appleshare 可以達到 1GB/s。