How to stop OS X from writing Spotlight and Trash files to memory cards and USB sticks? When plugging a USB stick into a Mac, OS X creates a number of hidden files on the stick, including a Spotlight index and Trash folder.

Example from the terminal for a USB stick "Untitled":

$ ls -a /Volumes/Untitled
.Spotlight-V100
.Trashes
._.Trashes
.disk
.fseventsd


It even does this on the xD memory card for my camera, so after having copied my pictures and deleted them from the card, the card is still full.

Is it possible to turn this off for USB and memory cards, so OS X either writes these files to the primary disk or doesn't write them at all?
For just a particular mounted volume - like a flash drive called yourUSBstick in this example - these commands will remove existing cruft, stop Spotlight indexing now and in the future, stop the related fsevents logging, and disable the Trash feature.

mdutil -i off /Volumes/yourUSBstick
cd /Volumes/yourUSBstick
rm -rf .{,_.}{fseventsd,Spotlight-V*,Trashes}
mkdir .fseventsd
touch .fseventsd/no_log .metadata_never_index .Trashes
cd -


Other unfamiliar stuff you may still see you probably want to keep, like Apple double "._*" files and other Apple DS cruft relating to icons and window placement.