How do I blacklist certain directories in Samba?

I am exporting a directory via Samba to my home theater PC. Unfortunately XBMC is also displaying some working directories that I happen to be sharing inside that directory.

I would like to find a way to have Samba ignore certain directories so that they are not shared with the other PCs.

This is purely for vanity reasons so the solution doesn't need to be totally perfect (So a workaround would be fine, it doesn't have to be production quality)


I'm thinking veto files is the option you're looking for.

Edit /etc/samba/smb.conf with root rights. Under the particular share /var/test, the following setting will exclude any descendant sub-directory or file matching foo or *bar* (beware, / means OR):

[myshare]
  path = /var/test
  veto files = /foo/*bar*/

Then, you need to restart Samba with stop and start (not reload):

sudo /etc/init.d/samba stop
sudo /etc/init.d/samba start

Note: Shares created through Nautilus GUI are defined in individual files in /var/lib/samba/usershare but veto files can't be applied there. If it's your case:

  • Either add veto files to the [global] section of /var/lib/samba/usershare. This will affect to all your global shares.
  • Or delete the existing share definition file under /var/lib/samba/usershare and re-create it manually under /etc/samba/smb.conf. You can't copy paste; instead, follow the guide.

hide files = file1/file2/$*/System Volume Information also hides the folder from share