MacOS tends to trash mounted disks with number of useless hidden files (e.g. ._* or .DS_Store ). There were number of recipes in the Internet, some of them were working at some of time but are not anymore.
Below notes from my fights (at a moment of writing, on MacOS High Sierra 10.13.4 (17E199).
Removing the files when they are created
I used to apply a find . -name … -print0 | xargs rm -0 combo but found that there is an built-in command to deal with these files:
$ dot_clean .
From the man:
NAME dot_clean -- Merge ._* files with corresponding native files. SYNOPSIS dot_clean [-fmnsv] [--keep=[mostrecent|dotbar|native]] [dir ...] DESCRIPTION For each dir, dot_clean recursively merges all ._* files with their corresponding native files according to the rules specified with the given arguments. By default, if there is an attribute on the native file that is also present in the ._ file, the most recent attribute will be used.
Preventing creating the files
On the MacOS side
NOTE: None of these solutions worked for me!
$ defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true $ killall Finder
As I wrote, this didn’t work at all to me.
On the SMB server side
It actually turned the only working solution for me. Just add to the share configuration section a veto file parameter, e.g.:
$ sudo vi /etc/samba/smb.conf
[jhartman] path = /home/jhartman ..... veto files = /._*/.DS_Store/
And restart:
$ sudo service smbd restart
Note, after applying this change you will not be able anymore to use dot_clean command from your Mac as any requests towards these files (including deletion) will be silently ignored by your SMB server hence files will remain untouched!