Welcome to the most active Linux Forum on the web.
Go Back > Blogs > linux-related notes
User Name


Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Rate this Entry

It may be useful to have separate mlocate databases for removable drives

Posted 12-04-2020 at 12:52 PM by the dsc
Updated 12-04-2020 at 12:53 PM by the dsc
Tags locate, mlocate

Firstly because by default "/media" is pruned. But if you'd only remove it from there, then you'd end risking dumbly updating and erasing or rewriting stuff depending on which removable drive is plugged/mounted there.

A separate database can be created with commands along the lines of:

sudo updatedb --localpaths=/media/removable1 --output=/var/lib/mlocate/removable1.db
Apparently mlocate ignores the LOCATE_PATH environment variable, which could, apparently, allow for both files to be searched at once with the "locate" command without parameters specifying each database. Maybe it's some other thing I have going wrong, though.

Whatever is the reason why, it can be mimicked with bash aliases adding the default and additional databases:

alias locate='locate -i -d /var/lib/mlocate/mlocate.db:/var/lib/mlocate/removable1.db'
Besides mlocate, there's also plocate, which seems to be still a bit unsuitable to use with multiple databases. As far as I've understood, it uses mlocate's database, creates a smaller one for itself, which allows it to work faster. But I'm not sure it's ready to create additional of such faster databases for the separate drives. At least it's no a "transparent" experience where you don't need to do anything, I guess.

Maybe it can be done, but mlocate alone is fast already, and would end up requiring less disk space, since plocate uses builds its own databases from mlocate's. Perhaps it could be set-up so it would remove the mlocate one every time, but then the updates themselves would take longer, as it would also need to recreate a new one from scratch to update its own.
Posted in Uncategorized
Views 2861 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 02:43 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration