Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-10-2010, 06:22 AM
|
#1
|
Member
Registered: May 2006
Location: Farnham, Surrey, UK (Chile until Dec 2011)
Distribution: Fedora Core 14
Posts: 32
Rep:
|
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
|
|
|
02-10-2010, 06:34 AM
|
#2
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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.
|
|
|
02-10-2010, 06:49 AM
|
#3
|
Member
Registered: May 2006
Location: Farnham, Surrey, UK (Chile until Dec 2011)
Distribution: Fedora Core 14
Posts: 32
Original Poster
Rep:
|
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
|
|
|
02-10-2010, 12:19 PM
|
#4
|
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326
|
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>*"
|
|
1 members found this post helpful.
|
02-10-2010, 04:47 PM
|
#5
|
Member
Registered: Feb 2003
Location: Florida
Distribution: Fedora 18
Posts: 862
Rep:
|
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 09:45 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|