Hi,
I wonder whether we have a command which tells me the device
corresponding to a known mount point. I want to avoid grepping the
output of mount because it may not unique (regarding mounts on shared
bind mounts) and because the original mount point may include symlinks
which are canonicalized by the kernel.
Example:
$ truncate -s100M /tmp/img
$ losetup /dev/loop0 /tmp/img
$ mkfs.ext2 /dev/loop0
$ mkdir /tmp/mnt
$ ln -s /tmp /tmp/xyz/symlink
$ mount /dev/loop0 /tmp/xyz/symlink/mnt
$ mount | grep loop
/dev/loop0 on /tmp/mnt type ext2 ...
I need a command which outputs "/dev/loop0" when "/tmp/xyz/symlink/mnt"
is given.
So far I found df as the only solution (but ugly and maybe GNU-only).
And it would succeed for any input file, not only mountpoints.
$ df -P /tmp/xyz/symlink/mnt | awk 'NR==2{print $1}'
/dev/loop0
Our mountpoint(1) looks like the right tool but prints the device
numbers only
$ mountpoint -d /tmp/xyz/symlink/mnt
7:0
So how could I do this in a non-ugly way?
cu,
Rudi
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html