Sunday, November 9, 2008

Locate Configuration Example

Keep things found is not an easy skill to master. The disk drive turns into a deep and dark jungle after the first few weeks on road. Traditional *nix command 'locate' helps us find files quickly by matching against a previously generated database. There are quite a few locate implementations available such as the GNU Findutils, slocate and mlocate, they have quite a few new features and security enhancements.

Unlike its first cousin the 'find' command, locate queries are faster but the exact matches are dependent on the freshness of the database. Also redundancy issue creeps in if you are not watchful. For example, searching with 'locate Simple.pm' gives undesirable results spread across all mounted partitions on this computer. /mnt/old-drive/usr/share/perl/5.8.4/Filter/Simple.pm # old Linux distro /usr/share/perl/5.8.8/Filter/Simple.pm # Current OS (Ubuntu/Debian) /mnt/windows/Perl/lib/Filter/Simple.pm # Windoze XP

Now lets see if we can remedy this by disabling locate indexing of mounted partitions and mounted Windows XP partition as well. Add '/mnt' to the PRUNEPATHS variable and 'vfat' to the PRUNEFS variable to the /etc/updatedb.conf file.

PRUNE_BIND_MOUNTS="yes" PRUNEPATHS="/tmp /var/spool /mnt " PRUNEFS="NFS nfs nfs4 afs binfmt_misc proc smbfs autofs iso9660 ncpfs coda devpts ftpfs devfs mfs shfs sysfs cifs lustre_lite tmpfs usbfs udf rpc_pipefs vfat"

Next time the 'updatedb' command is run to create the locate database it avoids indexing all the directory paths listed under PRUNEPATHS and file systems in PRUNEFS options.

No comments:

Post a Comment

You can leave a comment here using your Google account, OpenID or as an anonymous user.

Popular Posts