Way to tell which device a file is located on

filesmount

If I have a file /abc/def/ghi/jkl, is there a way to tell which device it is located on, or should I parse /etc/mtab and see what matches /abc/def/ghi/jkl better?

Best Answer

df will tell you device name and mount point, and ls will tell you device numbering:

paul $ pwd
/home/paul/SandBox/Toys/hSort
paul $ ls -l ReadMe
-rw-r--r-- 1 paul paul 296 Jan  8  2020 ReadMe

paul $ df ReadMe
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda9      103818480 3796556  94725184   4% /home

paul $ ls -l /dev/sda9
brw-rw---- 1 root disk 8, 9 Jul 12 12:10 /dev/sda9
Related Question