Make KFind skip directories and mount points

Q I am using Kubuntu 6.06 with the Ichthux packages but my question is common to any distribution using KDE. The 'Find Files' utility searches every directory on the root (/), including the directories in the /mnt directory. This means KFind is searching my files in other distributions, and I usually have several, so KFind loses a lot of time here. Is there some way to configure find to skip /mnt? Otherwise the only solution I can think of would be to unmount /mnt every time before using KFind, but that might create problems.

A KFind is a front-end to two standard shell commands: find and locate. Unfortunately it doesn't give access to all of the options of find, such as specifying which directories or filesystems to search or skip. All you can do is give a starting point. This isn't an issue when searching your home directory, the default, but it can cause the problems you describe when trying to search the whole filesystem. Happily, in the 'Use files index' checkbox you can elect to use locate instead of find. Locate uses a database built with the updatedb command for much faster searching, although it only finds files that were present when the database was searched. Updatedb is usually run as a daily or weekly cron task. The search path of locate is configurable, so you should add /mnt to the PRUNEPATHS list in /etc/updatedb.conf. For maximum flexibility, it is worth learning the find and locate commands themselves, eg

find / /home -xdev -iname '*.pdf'

will look for all files ending in .pdf or .PDF in / or /home, but ignore other filesystems (thanks to the use of -xdev) such as /proc, /dev and those mounted under /mnt or /media. The find and locate man pages will give you a lot more information, but the main thing to remember is that locate is for a fast, name-based search while find allows far more control over the search parameters, including filename, file type and file age as well as the directories and filesystems searched. Unmounting filesystems mounted under /mnt may work, but is just as likely to fail if you have an open file or directory in any of them. Either way, it shouldn't be necessary.

Back to the list