How to find out mount/partition a directory or file is on? (Linux Server) [closed]
Asked Answered
O

1

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..)

Odom answered 18/7, 2010 at 4:48 Comment(6)
@TylerCollier google sent me here... so please stop these dramass!Plaster
@ErdemEce that's my point. ina mentioned RTFM, but Google (and what it links to) counts as a manual now :-)Swivel
UNIX exchange version: unix.stackexchange.com/questions/11311/…Translate
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...Hypermetropia
@Hypermetropia Agree. I have exactly the same issue and got my solution here as the accepted answer below.Pyrrho
The various program ways to achieve this are described well at unix.stackexchange.com/a/313502/103306Nymphomania
S
266
df -P file/goes/here | tail -1 | cut -d' ' -f 1
Silkaline answered 18/7, 2010 at 4:50 Comment(6)
I get following when I run above command. /dev/mapper/vg_mymachine-lv. how do I know on which primary partition it belongs too. i.e. sda1, sda2, hda1 etc?Peekaboo
By looking at your LVM configuration.Silkaline
Great command! I wouldn't use the piping though. Getting to know information about space (at the same time you get to know about which partition your folder/file is on) is quite amusing as well :)Jubilee
Very nice; here's the same thing done with awk: df -P /home | tail -1 | awk '{ print $1}'Lorraine
Gotta admit, I really dislike pure command answers, can you make an edit and explain the options/params used?Djokjakarta
to check websites which are located on /var/www/html df -P /var/www/html | tail -1 | cut -d' ' -f 1Indicator

© 2022 - 2024 — McMap. All rights reserved.