Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

It's a big file for me and I'd like to put it on a different hard drive than my root partition is on.

Like to add: I'd like this to work for the automatic runs of updatedb. I checked the man pages for updatedb.conf and couldn't see anything there that would let me change the path.

share|improve this question

3 Answers 3

up vote 1 down vote accepted

In Ubuntu the default database location is compiled into the mlocate binary, so it's hard to change it. You can set the LOCATE_PATH variable, but the database file mentioned there will be only used as an additional database, not the default one.

As a workaround - how big is your .db file? On my system it is 5 MiB, is this a real problem? Wouldn't it be easier to prune some paths you don't need to search via locate (see man updatedb.conf) and make the file smaller this way?

share|improve this answer
    
Thanks that's the best idea. I found out it was large because it was indexing my backup directory (which has pretty frequent "snapshots" of links). Once I pruned those paths the size dropped dramatically. –  evencoil Feb 25 '11 at 9:05

You can check if your version of updatedb supports --output FILE parameter and make it an alias for your bash sessions and specify it on your cron jobs.

You must also use locate with --database FILE parameter

As stated by evencoil there's no possibility of using a symbolic link because updatedb recreates the file on each invocation.

share|improve this answer
    
The linking solution doesn't seem to work since updatedb recreates the file in the default directory. I guess I could go around and add a bunch of flags to the commands, but it makes it even more difficult to change later. I wonder if there is some sort of environment variable that would be a simple fix? –  evencoil Feb 23 '11 at 14:51
    
for systemwide usage don't now. For your bash session there's "alias". Place alias updatedb=updatedb --output /path/to/file and the same for locate in your .bashrc file –  theist Feb 23 '11 at 15:00
    
The system-wide is really what I'm looking for since there's a system cron job that updates the database everyday. –  evencoil Feb 23 '11 at 15:24
    
use the locate alias in .bashrc and place the option --output file in the cron job? as an idea –  theist Feb 23 '11 at 15:35

Just using a symlink comes to mind.

  1. Move mlocate.db to your other drive, let's say it ends up at /some/path/mlocate.db.
  2. Go to the correct folder

    cd /var/lib
    
  3. Create a symlink

    ln -s /some/path/mlocate.db mlocate.db
    

Note that I haven't tested this, but the reasoning behind it sounds correct enough to me. In case it doesn't behave as expected, just revert your actions by removing the symlink and moving the actual file back to its location.

share|improve this answer

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.