Disable creation of .DS_Store files on samba shares

Don’t you hate it when your file server is filled with .DS_Store files and .TemporaryItems directories? .DS_Store files are hidden files created by Mac OSX in each directory you access with Finder and stores custom attributes of a folder like icon position and background images. Since they’re ‘custom’ and besides that they’re annoying, you don’t want single suctom settings to be applied to a network share. So let’s disable those.

Open up /etc/samba/smb.conf and add the following lines to each share:

veto files = /._*/.DS_Store/
delete veto files = yes

Now restart samba.

Time to cleanup existing Mac OSX files! You can do that with this command:

find \( -name ".DS_Store" -or -name ".Trashes" -or -name "._*" -or -name ".TemporaryItems" \) -delete

You can also add the command above to a cron, to scan (f.e.) on a weekly base for these files.

Next to that, on your mac client, use this command to prevent any future creation of .DS_Store files on network shares:

defaults write DSDontWriteNetworkStores true

11 thoughts to “Disable creation of .DS_Store files on samba shares”

  1. Thank you for this! I was getting seriously frustrated having to manually clean up all this Mac crap from my shares since letting my girlfriend browse with her Mac and getting an Air myself. Just tested it doing “touch ._hello” on a share and getting “touch: ._hello: Permission denied” as a response. Muhahahahaha! :D

    I can still create .Trashes and .TemporaryItems, though. Any particular reason you’re not doing,

    veto files = /._*/.DS_Store/.Trashes/.TemporaryItems/


    Thanks again! Love it :)

    1. Hey Daniel, Nice to hear your enjoying yourself by annoying your gf ;-) (since those files mostly contain window position and in some cases app data, but are most of the time just crap anyway)
      There’s no particular reason why I left those two out, my post just contained an example. Feel free to add entries to the veto files setting. :)

      Here is some more info on the veto files setting in samba:

  2. Thank you so much for this information

    The samba related lead is exactly what I was looking for

    Give yourself a raise !!!

    Take care


  3. Just had to leave a comment to say THANK YOU!! Those files have been bugging my network shares forever and thanks to this post I can 1) prevent the creation of them and 2) delete those already pestering my view. THANKS! :D

  4. you might want to add all these to your veto files list

    these are the veto file settings that Apple includes with its samba build on Mac OS X Server

    /icon?/TheVolumeSettingsFolder/.DS_Store/.TemporaryItems/TheFindByContentFolder/.FBCindex/.FBCIndexCopy/.localized/Network Trash Folder/Temporary Items/Cleanup At Startup/.FBCLockFolder/.Trashes/._*/

  5. This is great, just what I’ve been looking for. Have you noticed any performance impact from this? I imagine the server has do do more work now, checking the filename of every file.

    1. Nah not really. Though I’m not working with major file servers right now that this was applied to. I’d say, give it a try ;)

Leave a Reply

Your email address will not be published.