Create several indexes
Use mlocate to search several database files simultaneously. Whatever you want to exclude should not be scanned in the first place. Forget about mounted vs non-mounted exclusion rules, and make indexes for the important locations.
The provided example can be adopted to your situation with little effort...
Generally speaking, you can create several index files with updatedb
and update them simultaneously or one by one as frequently you want (via crond
, for example).
If there is a global /etc/updatedb.conf, then it is probably wise to exclude paths that will have their own indexes - since scanning (creating index) the same location more than once will yield multiple results while scanning (searching) for the same location.
After creating binary "dictionaries" for all locations, configure a function in the shell;
function fooLocate { /usr/bin/locate \ -d /var/tmp/default.mlocate.db \ -d /my-stuff/mlocate-index2.db $@ }
Relevant documentation
(do a man updatedb
too)
man locate *scroll scroll scroll*
-d, --database DBPATH Replace the default database with DBPATH. DBPATH is a :-separated list of database file names. (...) An empty database file name is replaced by the default database. A database file name - refers to the standard input. Note that a database can be read from the standard input only once.
Example
# updatedb -o /home/jaroslav/.locate/media-music.db -U /mnt/media/media/ \ -n images \ -n movies \ -n steamapps \ -n pr0n -v # locate -i glass -d /home/jaroslav/.locate/media-music.db| wc -l 35 # locate -i glass -d /home/jaroslav/.locate/media-music.db \ -d /var/lib/mlocate/mlocate.db | wc -l 363