I made a change in /usr/libexec/locate.updatedb so that the locate database won't store anything found in either the "/Volumes" directory (which leads to the backup drive) or the "/Previous Systems" directory.
Read the rest of the hint for the how-to...
Basically I just added -regex "/Volumes" -o and -regex "/Previous Systems" -o to the find command in the locate.updatedb script. You can manually change those dirs to anything you want and add more dirs to be ignored -- just make sure you add the "or" flag (-o) to the logic.
Find the following in /usr/libexec/locate.updatedb (around line 62):
find ${SRCHPATHS} \( ! -fstype local -o -fstype fdesc -o -fstype devfs \) -a \
-prune -o -print | \
tr '/' '\001' | \
(sort -T "$TMPDIR" -f; echo $status > $errs) | tr '\001' '/' > $filelist
and add the following code between find ${SRCHPATHS} ( and ! -fstype local:
-regex "/Volumes" -o -regex "/Previous Systems" -o \
so that the new code looks like this:
find ${SRCHPATHS} \( -regex "/Volumes" -o -regex "/Previous Systems" -o \
! -fstype local -o -fstype fdesc -o -fstype devfs \) -a \
-a -prune -o -print | \
tr '/' '\001' | \
(sort -T "$TMPDIR" -f; echo $status > $errs) | tr '\001' '/' >
Then to update your locate database right away, run the following command in Terminal:
sudo /usr/libexec/locate.updatedb

