Prevent MacOS from making .* and ._* files

Whenever I plug someone's FAT32 flash drive into my computer, MacOS loves to add all sorts of hidden files.

A couple of these include:
.Spotlight-V100/
.Trashes/
.fseventsd/
.DS_Store

When they get the drive back, they see all this cruft. How can I prevent this from happening?

Thanks!


Solution 1:

These files and directories are created by various applications:

.DS_Store - Created by Finder when you open a directory. It stores information about the folder (view options, icon positions, etc).

.fseventsd - created by the fseventsd daemon. It contains data about file system events such as modifications, deletion, creation, etc.

.Spotlight-V100 - stores indexing information for spotlight in the form of metadata.

.Trashes - A folder containing files that have been sent to trash but not yet deleted from the volume.

In order to prevent them all from being created, you have to modify the behaviour of each application individually. That would include adding an exception to Spotlight, Disabling Finder's caching feature (if possible), changing the fseventsd daemon and so on. I'm not sure if it's even possible to add exclusions or disable all of these features. If you don't need to write to the disk, I'd just mount it as read only to make things easier.

Solution 2:

Leopard & Snow Leopard make these files hidden. Mac OS X can be told not to put these files on network drives using:

defaults write com.apple.desktopservices DSDontWriteNetworkStores true