NOTE: This is an advanced hint, so beginners should not do this.
Even if you never use the unix locate command, OS X still runs in the background, updating the database for this command to quickly search your hard drive. It often turns out you don't want the unix locate command to search certain file systems or directories. The database it uses is updated by the locate.updatedbcommand that runs automatically as a cron job as part of your periodic maintainence. This hint is about how to tell locate.updatedb to avoid a filesystem, and it involves modestly editing a system file. My solution is to create a special Group-ID that tells updatedb not to index beyond a certain point; thus any folders or files below that initial folder with the special group ID are protected from being indexed.
MOTIVATION: I have a large 400GB FireWire drive on my computer that I use for backup images. It not only contains lots of files, but it also contains lots of hard linked files (created for differential backups). Running a find command on this filesystem can take hours. And since these are multiple backup copies of my principal directories, I dont want them in locate's database anyhow. Read on for the step-by-step solution...
42a43
> set EXCLUDE_GROUP = 399 # prune any path with a directory whose group is this name
63c64
< find ${SRCHPATHS} \( ! -fstype local -o -fstype fdesc -o -fstype devfs \) -a \
---
> find ${SRCHPATHS} \( ! -fstype local -o -fstype fdesc -o -fstype devfs -o -group ${EXCLUDE_GROUP} \) -a \
sudo patch --backup /usr/libexec/locate.updatedb mypatch
Note that the --backup flag will cause patch to create a copy of the original that you should keep in case you want to revert this. You can also use patch to revert with the -R flag).
Mac OS X Hints
http://hints.macworld.com/article.php?story=20040706191520772