Say I need to do:

find / -name somefile.txt

and say root partition / is mounted on /dev/sda5; however, let's say I also have 250GB partitions (/dev/sda6, /dev/sda7) mounted in /media - AND another location that I cannot currently remember. Say, also, that I know the file I'm looking for is on /dev/sda5.

Obviously, the above command will also descend in /media and that other directory which represent the big partitions, wasting time in looking for the file in the wrong place.

Is there a way to instruct find (or other command) to search only / on /dev/sda5, and NOT to descend to directories if they are on different partitions?

2 Answers 2


Use the -xdev argument to find

-xdev Don’t descend directories on other filesystems.

  • 1
    Thanks much - just for reference, the syntax would be: <pre>find / -xdev -name somefile.txt</pre>
    – sdaau
    Jun 11, 2010 at 13:43
  • 1
    For mac users: find -x / -name somefile.txt
    – CodeReaper
    Jan 31, 2014 at 9:58
  • 1
    Searching the manpage for --one-file-system a la du did me no good either. At least they both begin with -x I suppose. And it means "cross devices" I think. Jun 1, 2018 at 0:16

The POSIX standard defines the -xdev ”primary“:

it shall cause find not to continue descending past directories that have a different device ID

This is implemented in GNU's find (i.e. the findutils; docs).
GNU find also allows you to use -mount as ”an alternate name for -xdev, for compatibility with some other versions of find.

On BSD systems and macOS the option is -x instead. They (imho confusingly) call -xdev to be ”deprecated“. You can, however, use -mount instead. [manpages of FreeBSD and macOS]

other tools, just FYI

If you're using ripgrep (rg) like rg --files, you can use the --one-file-system option, which does the same like find's -xdev option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.