LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 02-10-2010, 07:22 AM   #1
jraclarke
Member
 
Registered: May 2006
Location: Farnham, Surrey, UK (Chile until Dec 2011)
Distribution: Fedora Core 14
Posts: 32

Rep: Reputation: 15
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
 
Old 02-10-2010, 07:34 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
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.
 
Old 02-10-2010, 07:49 AM   #3
jraclarke
Member
 
Registered: May 2006
Location: Farnham, Surrey, UK (Chile until Dec 2011)
Distribution: Fedora Core 14
Posts: 32

Original Poster
Rep: Reputation: 15
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
 
Old 02-10-2010, 01:19 PM   #4
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,029

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
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.
Old 02-10-2010, 05:47 PM   #5
SharpyWarpy
Member
 
Registered: Feb 2003
Location: Florida
Distribution: Fedora 18
Posts: 862

Rep: Reputation: 90
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Booting Linux on an external USB hard drive (not a memory stick, a hard drive) comcastuser Linux - Hardware 4 01-13-2010 07:59 PM
grub basic video command to boot a external SATA hard drive james2b Linux - General 2 08-22-2009 05:45 PM
ubuntu installed on external hard drive, can't startup without external hard drive. Vanostaajen Linux - Software 23 01-20-2009 10:59 AM
external enclosure for an internal hard drive vs external USB hard drive powah Linux - Hardware 1 03-10-2006 10:03 AM
please someone help me.. to locate my USB external hard drive haryoh Linux - Software 2 10-14-2005 11:20 AM


All times are GMT -5. The time now is 03:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration