Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 2 down vote accepted

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
share|improve this answer
    
Thanks, i was hoping in a similar option, actually, and i did not notice i could do something like this! :) – Paul Nov 30 '12 at 15:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.