Seach locate database for external drive while drive offline

Questions about applications and software
Forum rules
Before you post please read how to get help

Seach locate database for external drive while drive offline

Postby albe.mann on Sun Jul 19, 2009 6:30 am

Hi.

I switched from Windows to Mint Gloria a couple of weeks ago and am slowly rebuilding my tool stack now. I am having problems with locate and sincerely hope someone can help me.

On Windows I used the locate clone Locate32 for quickly searching my external drives while they were off. I have so far not been able to do the same with Gloria. I have created a database of the external drive with
Code: Select all
sudo updatedb -o external.red.db -U /media/external%red

And I have added this database file to LOCATE_PATH.
Unfortunately, locate only finds files when the indexed drive is online. How can I search the database when the indexed drive is offline?
albe.mann
Level 1
Level 1
 
Posts: 4
Joined: Sun Jul 19, 2009 5:49 am

Linux Mint is funded by ads and donations.
 

Re: Seach locate database for external drive while drive offline

Postby lagagnon on Sun Jul 19, 2009 11:30 am

albe.mann wrote:How can I search the database when the indexed drive is offline?


You need to use "locate -d dbpathname". Did you try that?
User avatar
lagagnon
Level 7
Level 7
 
Posts: 1888
Joined: Wed Jun 17, 2009 7:38 pm
Location: an island in the Pacific...

Re: Seach locate database for external drive while drive offline

Postby albe.mann on Tue Jul 21, 2009 2:34 pm

Yes, I did. It makes no difference.
albe.mann
Level 1
Level 1
 
Posts: 4
Joined: Sun Jul 19, 2009 5:49 am

Re: Seach locate database for external drive while drive offline

Postby DrHu on Tue Jul 21, 2009 5:09 pm

albe.mann wrote:On Windows I used the locate clone Locate32 for quickly searching my external drives while they were off

I suppose I shouldn't doubt this, but I am curious how windows magic works
How does it enable you to search a file that you cannot get to, the drive where the file is located is off-line ?

albe.mann wrote:And I have added this database file to LOCATE_PATH.
Unfortunately, locate only finds files when the indexed drive is online

Makes perfect sense, how would you expect to be able to read a file from an external disk, if that disk is not available to you, that is it is off-line (not mounted)
http://linux.about.com/od/commands/l/blcmdl1_locate.htm

Possibilities..
Or you could try sending your locate data to a virtual file system
http://freshmeat.net/articles/virtual-f ... inary-file
http://www.cyberciti.biz/faq/explain-vi ... le-system/
--but I think even trying that will not work, I cannot find the magic coffee beans so far..
Last edited by DrHu on Tue Jul 21, 2009 5:39 pm, edited 1 time in total.
User avatar
DrHu
Level 17
Level 17
 
Posts: 7002
Joined: Wed Jun 17, 2009 8:20 pm

Re: Seach locate database for external drive while drive offline

Postby albe.mann on Tue Jul 21, 2009 5:34 pm

DrHu wrote:
albe.mann wrote:And I have added this database file to LOCATE_PATH.
Unfortunately, locate only finds files when the indexed drive is online

Makes perfect sense, how would you expect to be able to read a file from an external disk, if that disk is not available to you, that is it is off-line (not mounted)


Well, I expect it to be able to locate offline files because the database file created by updatedb contains information about the files' position.


DrHu wrote:
albe.mann wrote:On Windows I used the locate clone Locate32 for quickly searching my external drives while they were off

I suppose I shouldn't doubt this, but I am curious how windows magic works
How does it enable you to search a file that you cannot get to, the drive where the file is located is off-line ?


I do not want to search the files' contents, I want to locate them. For instance, I read about an artist on the web. Now I have a large music collection on an external drive. I want to find out if I have any music by this artist already, not using any ID3 tags, just plain folder and file names. It is very convenient not to have to turn on the external drive in order to find this out.

It seems that locate used to have the options "--existing" and "--non-existing" that modified its behavior: http://unixhelp.ed.ac.uk/CGI/man-cgi?locate+1 The mlocate that comes with Gloria seems to always check that the files exist.
albe.mann
Level 1
Level 1
 
Posts: 4
Joined: Sun Jul 19, 2009 5:49 am

Re: Seach locate database for external drive while drive offline

Postby DrHu on Tue Jul 21, 2009 5:42 pm

You could also use something like tracker, Ubuntu..
http://www.herikstad.net/2009/04/slow-u ... acker.html
https://wiki.ubuntu.com/Tracker
http://www.manpages.spotlynx.com/gnu_li ... edb.conf.5

I don't think you understand; this was your command
    sudo updatedb -o external.red.db -U /media/external%red
so where is the file you want to use located on your mounted file system
    The usual location for updatedb is /var/lib/mlocate/mlocate.db
http://www.labtestproject.com/basic_lin ... db_command
--maybe you can configure updatedb

I checked your link, I didn't see any --existing switch
http://en.wikipedia.org/wiki/GNU_locate
slocate
    GNU locate is a Unix utility to find files on filesystems. It searches through a prebuilt database of files generated by updatedb and compressed using incremental encoding. It is significantly faster than find, but requires the database to be updated regularly.
    It can also be used to index network filesystems.
mlocate
    mlocate is a new locate implementation. The ‘m’ stands for “merging”: updatedb reuses the existing database to avoid rereading most of the file system, which makes updatedb faster and does not trash the system caches as much.
Last edited by DrHu on Tue Jul 21, 2009 6:18 pm, edited 3 times in total.
User avatar
DrHu
Level 17
Level 17
 
Posts: 7002
Joined: Wed Jun 17, 2009 8:20 pm

Re: Seach locate database for external drive while drive offline

Postby albe.mann on Tue Jul 21, 2009 6:08 pm

DrHu wrote:I don't think you understand; this was your command
    sudo updatedb -o external.red.db -U /media/external%red
so where is the file you want to use located on your mounted file system


Sorry, if I did not explain myself properly. Let's assume I have a file /media/external%red/foo.mp3. The drive is online. I use sudo updatedb -o external.red.db -U /media/external%red to create a database of the external drive. Now I turn the external drive off. I want to use something like
Code: Select all
locate -d external.red.db foo

in order to find out that I have a file foo.mp3 in /media/external%red. However, all I get is ... nothing. As soon as I turn the drive back on, locate -d external.red.db foo works like a charm.

If I open the file external.red.db with nano, I can see the entry /media/external%red/foo.mp3. It just does not get printed, if the drive is offline. I presume locate checks whether the file exists at runtime.


DrHu wrote:I checked your link, I didn't see any --existing switch


You might have overlooked it.

Code: Select all
     -e, --existing
         Only print out such names that currently exist (instead of  such
         names  that  existed  when the database was created).  Note that
         this may slow down the program a lot, if there are many  matches
         in the database.   If you are using this option within a program,
         please note that it is possible for the file to be deleted after
         locate has checked that it exists, but before you use it.

       -E, --non-existing
         Only  print  out such names that currently do not exist (instead
         of such names that existed when the database was created).  Note
         that  this  may  slow  down the program a lot, if there are many
         matches in the database.
albe.mann
Level 1
Level 1
 
Posts: 4
Joined: Sun Jul 19, 2009 5:49 am

Re: Seach locate database for external drive while drive offline

Postby DrHu on Tue Jul 21, 2009 6:23 pm

OK, I see it now..your link

It might have to do with which locate command is running, which configuration, and if there are any other options
--you might have to pick one or the other and see what can be done (locate or mlocate)

I don't know if it is locate or updatedb that is the problem
--how they function..
If the default location of updatedb is still being used, even after your command line, in which case it should be simple to just overwrite the /var/lib/mlocate/mlocate.db file, and see if that operation succeeds for an unmounted drive..
User avatar
DrHu
Level 17
Level 17
 
Posts: 7002
Joined: Wed Jun 17, 2009 8:20 pm

Linux Mint is funded by ads and donations.
 

Return to Software & Applications

Who is online

Users browsing this forum: bgentry and 21 guests