If I do
# cd /
# ln -s /home test
# cd test
# mount --bind $PWD /mnt
the entry in /proc/mounts
is
/dev/sda2 /mnt ext4 rw,noatime,data=ordered 0 0
which is the device that is mounted to /home
and is not easily deducible from $PWD
which is /test
. How can I determine which device (i.e., /dev/sda2) is going to show up in /proc/mounts
in general given that the bind mount may be to a directory/file that is potentially "obscured" by symlinks, other bind mounts, etc?
Best Answer
If I understand your question you want to know which device was used for a given mount. For this you can use the
df
command:To find which device a particular file/directory is found on, give the file as an argument to
df
. Using your example:You can also use the
mount
command:The directory mounted for each device is the 3rd argument in the output above. So for device
/dev/sda1
would be/boot
. The other devices are making use of LVM (Logical Volume Management) and would need to be further queried to know which actual device is being used by LVM.