4

I changed my configuration so locate is also searching through external harddisks that are mounted in /media.

My /etc/updatedb.conf:

PRUNE_BIND_MOUNTS="yes"
# PRUNENAMES=".git .bzr .hg .svn"
PRUNEPATHS="/tmp /var/spool /home/.ecryptfs /media/Win8"
PRUNEFS=...(rest is default)

my main HDD i always use is

/media/rubo77/Data

if it is connected, and I run updatedb it is indexed, but each time I atart my computer with detached HDD the dayly /etc/cron.daily/mlocate is clearing that up.

I would like to be able to find files on the detached device too. If I don't want to I can always use locate -e that only shows currently existing files.

How can I tell locate to keep the index for files in media if the drive is not mounted so I can locate files on the detached device?

1 Answer 1

2

It seems to me you have multiple options here:

  1. Clearly the best way to do exactly what you want would be to tell cron to wait until the drive is mounted before updating the database. I imagine someone much more familiar with cron and/or bash then I am could tell you how.

  2. What you could definitely do, although it isn't exactly what you want, is to create a new database just for the removable drive. See this closely related question for detailed instructions on how to do that. Then you can just have to manually update the database when the drive is mounted.

  3. If the contents of the drive don't change often, there are a lot of alternatives. For me, I have many different external drives so for each one I will often pipe a command like ls -RD1 to a text file, and then I can just use grep and other tools whenever I want.

2
  • 1
    Nice workarounds, But still the best solution would be a "keep" flag for locate or such. Maybe I should make a feature request to the developers
    – rubo77
    Oct 8, 2014 at 8:36
  • 4
    This solves it for me: I add these aliases in ~/.bashrc file: alias updatedb-external='sudo updatedb -l 0 -o ~/.externalharddisk.db -U /media/externalharddisk' and alias locate-external='locate -d ~/.externalharddisk.db:'
    – rubo77
    Sep 3, 2015 at 5:49

You must log in to answer this question.

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