A filesystem is a section of a disk, either on the local host or
mounted from a remote host over a network. Searching network
filesystems can be slow, so it is common to make find avoid
them.
There are two ways to avoid searching certain filesystems. One way is
to tell find to only search within the same filesystem as the
start-point currently being searched:
Ignore files on other devices. Do not visit or search inside mount
points. Do not search inside directories within other file systems
even if they are the target of a symbolic link and find is
following symbolic links (e.g. due to the ‘-L’ or ‘-H’
option).
Visit mount points but not their children (that is,
don’t descend into directories on other devices).
Using -mount -xdev has the same effect as ‘-mount’.
Here we see that normally, find will search inside a file
system which is mounted at ‘tree/bound1’:
$ find tree -printf 'device: %5D path: %p\n' device: 40 path: tree device: 64770 path: tree/bound1 device: 64770 path: tree/bound1/on-another-fs
If we specify ‘-xdev’ then we will visit the mount point but not search inside it:
$ find tree -xdev -printf 'device: %5D path: %p\n' device: 40 path: tree device: 64770 path: tree/bound1
If we specify ‘-mount’ we will not visit the mount point at all:
$ find tree -mount -printf 'device: %5D path: %p\n' device: 40 path: tree
We used the ‘%D’ directive of ‘-printf’ in those examples to shows the device number for each item, to illustrate that the files are on different devices. See Print File Information.
The other way to avoid particular filesystems is to check the type of filesystem each file is on, and not descend directories that are on undesirable filesystem types:
True if the file is on a filesystem of type type. The valid filesystem types vary among different versions of Unix; an incomplete list of filesystem types that are accepted on some version of Unix or another is:
autofs ext3 ext4 fuse.sshfs nfs proc sshfs sysfs ufs tmpfs xfs
You can use ‘-printf’ with the ‘%F’ directive to see the types of your filesystems. ‘-fstype’ is usually used with ‘-prune’ to avoid searching remote filesystems (see Directories).