Ask Your Question
1

locate (and updatedb) is not finding a file

asked 2015-03-11 15:11:09 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

My locate doesn't work for me for some reason. I am using Fedora release 21. This is how I test to see if locate is working:

gavin@localhost:~$ cd
gavin@localhost:~$ touch hellothere
gavin@localhost:~$ sudo updatedb
[sudo] password for gavin: 
gavin@localhost:~$ locate hellothere
gavin@localhost:~$ sudo locate hellothere
gavin@localhost:~$

I actually deleted the database and reindexed, but that didn't help:

sudo rm /var/lib/mlocate/mlocate.db
sudo updatedb

(edited to not use /tmp, and use ~ instead)

Here is information on my filesystems:

[~/mnt]$ cat /etc/updatedb.conf                                                                                                                                                       *[master] 
PRUNE_BIND_MOUNTS = "yes"
PRUNEFS = "9p afs anon_inodefs auto autofs bdev binfmt_misc cgroup cifs coda configfs cpuset debugfs devpts ecryptfs exofs fuse fuse.sshfs fusectl gfs gfs2 hugetlbfs inotifyfs iso9660 jffs2 lustre mqueue ncpfs nfs nfs4 nfsd pipefs proc ramfs rootfs rpc_pipefs securityfs selinuxfs sfs sockfs sysfs tmpfs ubifs udf usbfs"
PRUNENAMES = ".git .hg .svn"
PRUNEPATHS = "/afs /media /mnt /net /sfs /tmp /udev /var/cache/ccache /var/lib/yum/yumdb /var/spool/cups /var/spool/squid /var/tmp"
[~/mnt]$ df -h                                                                                                                                                                        *[master] 
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3       227G   81G  146G  36% /
devtmpfs        2.9G     0  2.9G   0% /dev
tmpfs           2.9G   24M  2.9G   1% /dev/shm
tmpfs           2.9G  932K  2.9G   1% /run
tmpfs           2.9G     0  2.9G   0% /sys/fs/cgroup
tmpfs           2.9G  405M  2.5G  14% /tmp
/dev/sda3       227G   81G  146G  36% /home
/dev/sda1       477M  154M  295M  35% /boot
tmpfs           587M   48K  587M   1% /run/user/1000
/dev/sr0        1.4G  1.4G     0 100% /run/media/gavin/Fedora-Live-WS-x86_64-21-5


[~]$ cat /etc/fstab 
#
# /etc/fstab
# Created by anaconda on Tue Dec  9 20:56:27 2014
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=c660d346-c6bd-4beb-9fca-df0878258dfd /                       btrfs   subvol=root     0 0
UUID=71609ae1-3876-48df-96e3-900a45982442 /boot                   ext4    defaults        1 2
UUID=c660d346-c6bd-4beb-9fca-df0878258dfd /home                   btrfs   subvol=home     0 0
UUID=e2935984-7e92-4efc-8440-c3992f2a9f53 swap                    swap    defaults        0 0
edit retag flag offensive close merge delete

Comments

/tmp isn't evaluated by mlocate. It's volatile content, cleaned out on reboot, and not intended to be storage for anything important.

You can check the paths that are pruned from the locate database in the PRUNEPATHS line of /etc/updatedb.conf.

randomuser gravatar imagerandomuser ( 2015-03-12 01:23:32 -0600 )edit

Thanks, I didn't realize. Unfortunately, it fails for items in my home folder too. I edited my answer.

Gavin gravatar imageGavin ( 2015-03-12 08:32:29 -0600 )edit

I'll repost as a comment, since it doesn't directly apply to question anymore, but leave it in for other readers.

randomuser gravatar imagerandomuser ( 2015-03-13 01:20:07 -0600 )edit
1

I am running F21 and the above procedure works fine for me - i.e. sudo updatedb and locate return the newly added/touched file. There was no need to remove the mlocate.db file first.

  • Is your home folder mounted from a remote server using "cifs" or "nfs" perhaps?
  • Are you using one of the file systems listed in the PRUNEFS entry of your updatedb.conf file.

My default /etc/updatedb.conf ignores the following file systems:

PRUNEFS = "9p afs anon_inodefs auto autofs bdev binfmt_misc cgroup cifs coda configfs cpuset debugfs devpts ecryptfs exofs fuse fuse.sshfs fusectl gfs gfs2 hugetlbfs inotifyfs iso9660 jffs2 lustre mqueue ncpfs nfs nfs4 nfsd pipefs proc ramfs rootfs rpc_pipefs securityfs selinuxfs sfs sockfs sysfs tmpfs ubifs udf usbfs"
snowolfe gravatar imagesnowolfe ( 2015-03-14 00:25:11 -0600 )edit

@snowolfe I do have tmpfs being used, but not on my home dir. I added information above.

Gavin gravatar imageGavin ( 2015-03-14 12:19:16 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2015-04-12 06:41:58 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

It turns out I was experiencing a bug which is outlined here: https://bugzilla.redhat.com/show_bug....

The resolution is to edit this file: /etc/updatedb.conf and disable PRUNE_BIND_MOUNTS, as I've mounted /home using btrfs.

edit flag offensive delete link more

Comments

good find!

randomuser gravatar imagerandomuser ( 2015-04-12 14:05:22 -0600 )edit
0

answered 2015-03-14 08:06:45 -0600

I'd suspect that the problem is the use of 'sudo' for updating the database. Have you tried with 'su -' instead?

$ su -
# updatedb;exit
$ locate hellothere
edit flag offensive delete link more

Comments

Unlikely.

sudo elevates the users permissions to root without changing the "environment" the user is operating in, e.g. working directories, environment variables etc. The user will only need to know their own password, not the root password. sudo can be configured to restrict access to specific superuser commands, but it would fail when run if this was the case.

su - requires the user to know the root password and the dash (after the su) changes the working environment to be that of root, i.e. the working directory and environment variables will be those of root, not the user.

The working environment in both cases should be fine for running updatedb and would not affect the outcome.

snowolfe gravatar imagesnowolfe ( 2015-03-14 20:39:57 -0600 )edit

I tried using the advice of PigJuliux, unfortunately it didn't work.

Gavin gravatar imageGavin ( 2015-03-14 22:39:53 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-03-11 15:11:09 -0600

Seen: 1,421 times

Last updated: Apr 12 '15