All of lore.kernel.org
 help / color / mirror / Atom feed
* find device of a known mountpoint
@ 2017-03-31  9:00 Rüdiger Meier
  2017-03-31  9:19 ` Karel Zak
  0 siblings, 1 reply; 9+ messages in thread
From: Rüdiger Meier @ 2017-03-31  9:00 UTC (permalink / raw)
  To: util-linux

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-03-31 11:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-31  9:00 find device of a known mountpoint Rüdiger Meier
2017-03-31  9:19 ` Karel Zak
2017-03-31 10:03   ` Rüdiger Meier
2017-03-31 10:41     ` Rüdiger Meier
2017-03-31 10:54       ` Karel Zak
2017-03-31 11:20         ` Rüdiger Meier
2017-03-31 10:09   ` [PATCH] test: fix mountpoint device check in libmount/loop Ruediger Meier
2017-03-31 10:57     ` Karel Zak
2017-03-31 11:01     ` Rüdiger Meier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.