Re: find device of a known mountpoint

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 31, 2017 at 12:41:22PM +0200, Rüdiger Meier wrote:
> On 03/31/2017 12:03 PM, Rüdiger Meier wrote:
> > 
> > 
> > On 03/31/2017 11:19 AM, Karel Zak wrote:
> > > On Fri, Mar 31, 2017 at 11:00:24AM +0200, Rüdiger Meier wrote:
> > > > $ 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.
> > > 
> > >   $ findmnt -no SOURCE /tmp/xyz/symlink/mnt
> > >   /dev/loop0
> > 
> > Thank's. Now I remember that you have told me that already one day. :)
> 
> BTW is there also a way to get "findmnt -n -o SOURCE" working if the
> argument is not a mount point but a regular file on another mount
> point? (In opposite of my initial question.)

$ findmnt --target /home/kzak/.bash_profile 
TARGET SOURCE    FSTYPE OPTIONS
/home  /dev/sda3 ext4   rw,relatime,data=ordered

Note that it's probably better to use (for the previous example) the
option --mountpoint if you want to be sure that the path is
interpreted as mountpoint and never as a regular file.

> I don't like that all these questions here are answered using "df".
> http://unix.stackexchange.com/questions/90252/how-to-get-mount-point-of-filesystem-containing-given-file
> 
> http://unix.stackexchange.com/questions/128471/determine-what-device-a-directory-is-located-on

 Well... :-)

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
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



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux