Stop OSX writing .DS_Store and ._ files on network shares

All our fileservers are Windows. Most of the files are manipulated in OSX. This isn't likely to change soon since, irrespective of who is accountable for most of the bytes, Windows are far and away the most populous in terms of hosts.

.DS_Store files are apple's way of storing the finder preferences for a particular directory. They contain things like background image, sort order, window size and position, and are written when any value for the current directory deviates from that of the parent, which includes every time it is moved.
._ files are Apple's way of storing attributes supported by HFS and HFS+ on less featureful filesystems (like NTFS and FAT).

To prevent OSX writing .DS_Store files to SMB shares, run the following:

  1. defaults write com.apple.desktopservices DSDontWriteNetworkStores true

This sets a per-profile value, so must be run as each user.
Preventing ._ files is a bit more tricky, but it can be done in/for the shell with:

  1. export COPY_EXTENDED_ATTRIBUTES_DISABLE=true

To prevent Samba accepting these files, enter the following into smb.conf

  1. veto files = /.DS_Store/

And read LavaLite's bit on it