I was trying to figure this out but found myself clueless: How can I figure out the name of the device (e.g. /dev/sdb2) for a given file/inode? e.g.
[root@serv07 /]# ls -i /etc/passwd
38357228 /etc/passwd
Now, I know that inode 38357228 (or passwd) resides on /dev/sda2 but how can I figure that out for any given/random file(s)? Any help would be useful. Cheers!!
You can use
df
will give you something like:
-P
is--portability
to get POSIX outputJust to be convenient:
Will give you just the device
You can get the mount point for a given file with stat:
You can use this to look up what is mounted there using /proc/mounts
You can use the
stat
command. See this question on Stack Exchange for the gory details:https://stackoverflow.com/questions/4309882/device-number-in-stat-command-output