Locate command to include the external hard drive
Hi Everyone
I normally use the "locate" command to find files that I have on my local drive. However, if I wanted to do this for an external drive, how would I go about this? From what little I know about Linux, I'm guessing that it creates a reference file from which it performs the search when the command is typed. If I'm right this is updated at a given interval or when "updatedb" is used? As the external hard drive is not always mounted is it best to create another of these reference files and have a different command (e.g. locateext) or something? Or is it best to add the external hard drive's location to the list of files that get added with updatedb. I'm running Fedora 11. Sorry if I'm getting the wrong end of the stick somewhere or I'm not very clear! If you are unsure of anything then ask me! James |
Look in /etc/sysconfig/locate. Remove the directory from prunepaths. You may need to change an entry like /mnt/ to prune the directories of /mnt/ to exclude.
Suppose you have /mnt/dirA, /mnt/dirB, and /mnt/dirC. Change the entry for prunepaths to /mnt/dirB /mnt/dirC. Then /mnt/dirA will be included. If you don't have an /etc/sysconfig/locate file, then then read your daily cron script that runs updatedb nightly. It probably reads a config file at the top of the script. |
Thanks jschiwal.
There is no locate file at that location, however looking in the cron.daily/mlocate.cron file it reads: #!/bin/sh nodevs=$(< /proc/filesystems awk '$1 == "nodev" { print $2 }') renice +19 -p $$ >/dev/null 2>&1 ionice -c2 -n7 -p $$ >/dev/null 2>&1 /usr/bin/updatedb -f "$nodevs" Is the /proc/filesystems file significant? It reads: nodev sysfs nodev rootfs nodev bdev nodev proc nodev cgroup nodev cpuset nodev binfmt_misc nodev debugfs nodev securityfs nodev sockfs nodev usbfs nodev pipefs nodev anon_inodefs nodev tmpfs nodev inotifyfs nodev devpts ext3 ext4 ext4dev nodev ramfs nodev hugetlbfs iso9660 nodev mqueue nodev selinuxfs nodev rpc_pipefs nodev fuse fuseblk nodev fusectl vfat Hope this helps. James |
find mite help. locate is faster because it looks at a file that lists all the files on your hd rather than looking thru it all the time.
Code:
find <directory-you-want-searched> -name "*<string-from-filename>*" |
What I suggest is running locate with two different database files. You can specify the name and location of the database file when you run updatedb and specify the appropriate file when you use locate. Specify what partitions or directorys you want excluded on the command line. You can create an alias or a script for these.
|
All times are GMT -5. The time now is 04:45 AM. |