I have a strange question, and i am not sure this is something doable at all, thats why i am asking it to the SuperUser :)

So, imagine that you have your filesystem with some mount points for additional partitions.

say something like

/drives/driveA/partitionA /drives/driveA/partitionB /drives/driveB/partitionA ... etc.

now, if all these partitions are mounted in their respective mountpoints, running updatedb would index all the content in their filesystem. Good.

Now, I am trying to set up a sort of low consumption, low hard disk wearing file server, where i would like to use automount, where i would like to have files indexed, but where i dont want to run the indexing on these additional drives every day.

So what i want to achieve is to run updatedb in such a way that some paths (in my case those paths above) could be excluded from the indexing, BUT at the same time without trashing the previous content indexed for those paths.

i see that updatedb has several "pruning" options, that let us exclude certain paths from the indexing process. But this also implies discarding all the content information related to those paths. Instead i would like to exclude certain paths, retaining what has been previously already indexed in those paths.

Does anyone have an idea how to achieve this with mlocate, or what other tool to use for this? thanks

1 Answer 1


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.


# 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
# locate -i glass -d /home/jaroslav/.locate/media-music.db \
                  -d /var/lib/mlocate/mlocate.db  | wc -l
  • Thanks, i was hoping in a similar option, actually, and i did not notice i could do something like this! :)
    – Pa_
    Commented Nov 30, 2012 at 15:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .