SOLVED: Tweaking Samba/SMB2 for Mac & Androids

Trying to tweak the Samba settings on MyCloud Gen.1 running latest 04.05.xx firmware on network of Macs & Androids only.

Problem 1 - Both testparm and /var/log/samba/log.smbd throw off errors for parameters set in /etc/samba/tm_config.conf which are under the [TimeMachineBackup] section, specifically durable handles, kernel oplocks (a Global parameter…), kernel share modes, max share size & drive cache flush.

Solution 1 - Have added fruit:time machine = yes which forces these setting by share:

durable handles = yes
kernel oplocks = no
kernel share modes = no
posix locking = no

and commented out the correspending parameters.

Problem 2 - Although the MyCloud version of smbd (4.3.11) has vfs_catia, vfs_fruit & vfs_streams_xattr built-in (smbd -b), Wireshark shows that it ignores the GetInfo Request FILE_INFO/SMB2_FILE_ALL_INFO for the AAPL extensions provided by vfs_fruit:

From the Mac…

AAPL Create Context request
    Command code: Server query (1)
    Reserved: 0x00000000
    Query bitmask: 0x0000000000000007, Server capabilities, Volume capabilities, Model information
        .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ...1 = Server capabilities: True
        .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ..1. = Volume capabilities: True
        .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .1.. = Model information: True
    Client/Server capabilities: 0x000000000000000f, Supports READDIRATTR, Supports macOS copyfile, UNIX-based, Supports NFS ACE
        .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ...1 = Supports READDIRATTR: True
        .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ..1. = Supports macOS copyfile: True
        .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .1.. = UNIX-based: True
        .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... 1... = Supports NFS ACE: True

Solution 2 - I believe the AAPL extensions require “ea support = yes” in the [Global] if I want Mac support across the NAS, which I do. Is it safe to do this on MyCloud where I already have files stored?

New Mac OSX related parameters for the /etc/smb-global.conf file:

[Global]
#
# PREREQUISITES TO FUNCTION WITH OSX
#
  min protocol = SMB2
  ea support = yes
#
# NOT NEEDED WITH OSX/LINUX
#
  disable netbios = yes
  dns proxy = no
  smb ports = 445
  name resolve order = host bcast
#
# GENERAL COMPATABILITY WITH OSX SMB
# adds alternate data streams (ADS) support
#
  vfs objects = catia fruit streams_xattr
#
# STORAGE OF OSX METATDATA & RESOURCE FORK 
# in Netatalk compat xattr & ._ AppleDouble File
#
  fruit:metadata = netatalk
  fruit:resource = file
#
# FILE LOCKING
# no cross protocol locking
#
  fruit:locking = none
#
# MAP NTFS ILLEGAL CHARS TO UNICODE
#
  fruit:encoding = private
#
# SMB2+ AAPL EXTENSIONS
# file metadata - Unix mode, FinderInfo, resource fork size, permissions
#
  fruit:aapl = yes
  readdir_attr:aapl_rsize = yes
  readdir_attr:aapl_finder_info = yes
  readdir_attr:aapl_max_access = yes
  fruit:nfs_aces = yes
#
# OSX COPYFILE
#
  fruit:copyfile= yes
#
# PERFORMANCE TWEAKS
# note - error with smb2 leases
#
  smb2 leases = yes 
  kernel oplocks = no
  use sendfile = yes
#
# FILE CLEANUP
#
  delete veto files = true
  unix extensions = yes
  fruit:posix_rename = yes
#
# PARAMETERS IN SAMBA VERSION > 4.3.11?
# testparm does not check fruit parameters
#
  fruit:model = MacSamba
  fruit:veto_appledouble = yes
  fruit:zero_file_id = yes
  fruit:wipe_intentionally_left_blank_rfork = yes
#
## END OF ADDED CONFIGS
#

Benefits:

  1. NAS now responds with enhanced capabilities:
Data: AAPL Create Context response
    AAPL Create Context response
        Command code: Server query (1)
        Reserved: 0x00000000
        Query bitmask: 0x0000000000000007, Server capabilities, Volume capabilities, Model information
        Client/Server capabilities: 0x000000000000000f, Supports READDIRATTR, Supports macOS copyfile, UNIX-based, Supports NFS ACE
            .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ...1 = Supports READDIRATTR: True
            .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ..1. = Supports macOS copyfile: True
            .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .1.. = UNIX-based: True
            .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... 1... = Supports NFS ACE: True
        Volume capabilities: 0x0000000000000002, Case sensitive
            .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ...0 = Supports Resolve ID: False
            .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ..1. = Case sensitive: True
            .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .0.. = Supports full sync: False
        Model string: Samba
  1. Requests (from the Mac) and responses (from the NAS) are chained (i.e. multiple elements in one SMB packet) resulting in fewer SMB packets and quicker response. Depending on size of the directory, Finder loads in less than half the time & half the SMB2 packets.
Create Response File; GetInfo Response; Close Response

Hello Torch1,

The information interesting, if I have read correctly you managed to lose no contents on your WD my cloud drive.

And increase the transfer rate over wi fi in reducing packets.
What transfer speeds did you achieve ?

Also if possible would you make a video or screen grabs aimed at noice levels to try and improve the WD software.

PS WD you can do this too :slight_smile:

Correct - no loss of data on MyCloud drive.
1 GB (gigabyte) test file takes 22.9 secs to transfer over wireless AC (= 349 Mbps) - YMMV. Sorry - no video or screen grabs… Open Terminal app on Mac to ssh into your WD MyCloud ( ssh root@mycloud ), edit smb-global.conf with nano ( nano /etc/samba/smb-global.conf ) , make the changes I recommend, write out ( Ctl-O ), exit nano ( Ctl-X ) then restart samba ( /etc/init.d/samba restart ).

Your a genius Torch,

many thanks for the 1 gig test now were cooking.
I need to read through and take in information and wade through, but looks promising.

Thanks torch1. I’m trying these setting on my wd ex2 ultra and it gets overwritten/reset with each reboot. Any ideas?

Not really - EX2 Ultra is a different device and different firmware - you may have to poke around to find out how the smb.conf is generated. There may be a script in /usr/local/sbin/ …that is where WD put the scripts in the MyCloud. Depends how comfortable you are with linux :wink:
Just make sure you have ssh enabled and have backuped any file before you change it.

Thanks for the reply, I see some scripts in the folder you mention I can take a look there. I have used Linux very little over the years… I can do small changes.
But the main problem is after I applied the changes you suggested I’m not seeing any changes in the smb behavior. The connection is still slow and many times the files in directories don’t show up. I’m connecting using Mac with Sierra OS. I have tried some option on the MacOS end like disable smb individual packet signing and few other things but nothing worked.

Here is a copy of my smb.conf file global section and tm_config.conf. Please let me know if you have any suggestions.

[ global ]
netbios name = MyCloudEX2Ultra
server string = 2-Bay NAS
veto files = /:2eDS_Store/.bin/Network Trash Folder/.systemfile/lost+found/Nas_Prog/mir
workgroup = WORKGROUP
security = user
passdb backend = smbpasswd
ldap ssl = no
local master = no
os level = 0
preferred master = no
smb2 leases = yes
fruit:copyfile= yes
printing = bsd
printcap name = /dev/null
disable spoolss = yes
max protocol = SMB3
max xmit = 131072
max log size = 10
log level = 0
socket options = IPTOS_LOWDELAY TCP_NODELAY SO_RCVBUF=2097152 SO_SNDBUF=2097152
delete veto files = yes
unix charset = UTF8
encrypt passwords = yes
map to guest = bad user
null passwords = yes
guest account = nobody
dns proxy = no
use mmap = yes
use spnego = yes
disable netbios = no
strict allocate = yes
csc policy = disable
min receivefile size = 16k
allocation roundup size = 0
create mask = 0777
directory mask = 0777
force create mode = 0777
force directory mode = 0777
use sendfile = yes
smb passwd file = /etc/samba/smbpasswd
disable spoolss = yes
nt acl support = yes
acl map full control = yes
load printers = no
unix extensions = no
follow symlinks = yes
wide links = yes
printable = no
include = /etc/samba/tm_config.conf

[ TimeMachineBackup ]
strict sync = yes
vfs object =catia fruit streams_xattr
durable handles = yes
kernel oplocks = no
kernel share modes = no
posix locking = no
inherit acls = yes
drive cache flush = yes

First things first - what version of Samba is running on your ex2?

smbd -V

Depending on your samba version, you may be able to omit some of the entries.
At first glance, you need to have in [global]:

min protocol = SMB2
ea support = yes
vfs objects = catia fruit streams_xattr

These entries are required because the AAPL (Apple) extensions to the SMB protocol are negotiated at the first connection which may, or may not be for the TM Backup.
I suggest you delete the “max protocol = SMB3” - clients & server will negotiate highest common protocol.
In the [TMBackup] share it should read “vfs objects = catia fruit streams_xattr”.
“objects” should have an “s” at the end…

Rather than repeat a lot of info, take a look at the wiki page I created on samba wiki:
[Configure Samba to Work Better with Mac OS X - SambaWiki]

As for your Mac, did you create a /etc/nsmb.conf to change some options? Here is mine:

[default]
signing_required=no
protocol_vers_map=6
port445=no_netbios

Wow, I made changes to the [global] section and also the changes you suggested to nsmb.conf and finally my files are showing up!! Thanks so much!!! I have been searching the internet for a fix for this and have read and tried numerous suggestions in various forums and nothing had worked. I think deleting the max protocol and keeping the min protocol must have helped. I’m yet to try anything for the wiki yet, my samba version is 4.3.1 , wd ex2 uses a busybox linux version.
Also strange to see that WD has a typo in the TMBackup, some WD associates should take notice and fix this.

Now I have to figure out how to make the setting survive a reboot, I see some ideas here under the custom configuration section which I should try. Thanks again for helping me fix this.
https://openwrt.org/docs/guide-user/services/nas/cifs.server#custom_configuration_surpassing_the_uci_configuration