mlocate can't search from database file for unmounted drive

Bug #382330 reported by PGScooter
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
mlocate (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Binary package hint: mlocate

I built a database file using updatedb. I then unmounted the drive and tried to search that file using the command
sudo locate -d extwd -i *.mp3

This yielded no results. By chance I tried the exact same command later and it worked because the drive was mounted. It appears as though the -e option were being implemented.

Please see this thread for reference:
http://ubuntuforums.org/showthread.php?t=1174996

I'm using Ubuntu 64-bit 9.04.
version of mlocate: 0.21.1

Thank you.

Revision history for this message
Cruncher (ubuntu-wkresse) wrote :

Confirmed for Karmic, mlocate 0.21.1-2.
It appears "-e" is always assumed for non-native filesystems:

- "mlocate" will correctly find non-existing files on an ext3 filesystem, and correctly suppress them with "-e" enabled.
- for vfat filesystems (and probably ntfs-3g, too?), non-existing files are *always* suppressed. This is not only the case for individual files that have been moved/removed, but also if the filesystem is unmounted.

Revision history for this message
StephenR0 (s9999) wrote :

I have a similar problem with Maverick. I use external journals with ext4 file systems. Those disks are normally not spinning. I run updatedb weekly to create a separate database for those disks. But if I use locate and find files on those disks, they spin up. That's exactly what I didn't want it to do. Could this be given some attention? Thanks.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in mlocate (Ubuntu):
status: New → Confirmed
Revision history for this message
Dave Duback (dwduback) wrote :

Yes, I have confirmed this, for Ubuntu 13.04 and mlocate 0.25.

I found that the PRUNEPATHS variable in /etc/updatedb.conf includes /media. For me, the default mount point for a USB device with a label (hard drive OR stick) is /media/dave/{disk label} with me as user dave. I removed '/media' from PRUNEPATHS in /etc/updatedb.conf and now get the proper results when searching databases for devices not currently mounted.

The trick here will be making sure a device is not mounted to /media at the time the cron job for updatedb runs, or find a way to run mlocate without a check for the current existence of a path before reporting a result. In the source for mlocate version 0.25, the implication is that -e (check for existence) defaults to FALSE but this was not EXPLICIT in the declaration.

The PRUNEPATHS variable is stored in the header of a .db file. The anamoly seems to be if you specify /media/user/usbdrive as the root for updatedb (updatedb -U /media/user/usbdrive), and /media is in PRUNEPATHS at that time, the database is generated correctly (all files catalogged), but subsequent searches fail if /media is in /etc/updatedb.conf.

Again, when I removed '/media' from PRUNEPATHS in /etc/updatedb.conf, my existing set of nineteen databases scanned from mount points /media/dave/{disk label} is properly scanned.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.