177

Is there a Linux command to easily find out which partition/mount a directory or file is on?

(This is probably a RTM question, and I feel guilty for asking it, but somehow, I can't find a good answer on google just yet..)

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
ina
  • 19,167
  • 39
  • 122
  • 201
  • 7
    @TylerCollier google sent me here... so please stop these dramass! – Erdem Ece Dec 12 '14 at 13:59
  • 1
    @ErdemEce that's my point. ina mentioned RTFM, but Google (and what it links to) counts as a manual now :-) – Tyler Collier Dec 12 '14 at 23:47
  • UNIX exchange version: http://unix.stackexchange.com/questions/11311/how-do-i-find-on-which-physical-device-a-folder-is-located – Ciro Santilli OurBigBook.com Mar 21 '15 at 08:56
  • 1
    getting the mount for a directory to troubleshoot a low diskspace error in order to restart a jenkins node that runs the CI loop for your team's web stack seems awfully like a tool used primarily in programming... – worc Apr 09 '15 at 18:07
  • @worc Agree. I have exactly the same issue and got my solution here as the accepted answer below. – Metric Crapton Jun 16 '15 at 17:51
  • 1
    The various program ways to achieve this are described well at https://unix.stackexchange.com/a/313502/103306 – Josip Rodin Dec 05 '17 at 09:56

1 Answers1

265
df -P file/goes/here | tail -1 | cut -d' ' -f 1
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358