Yes. You can see Showing Only Interesting Mount Points/Filtering Non-Interesting Types or Listing Directories under /
that are Not Under the Same Mountpoint for some example usage, but there's also a brief rundown below. The command you are asking about is findmnt
(though lsblk
might also serve):
lsblk -f /dev/sda[12]
NAME FSTYPE LABEL UUID MOUNTPOINT
sda1 vfat ESP F0B7-5DAE /esp
sda2 btrfs sys 94749918-bde1-46e6-b77c-b66e0368ecdb /
Now, as you can see, /dev/sda1
is mounted on /esp
. I wonder if it is mounted elsewhere as well?
findmnt /dev/sda1
TARGET SOURCE FSTYPE OPTIONS
/esp /dev/sda1 vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro
/boot /dev/sda1[/EFI/arch_root] vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro
Aha. I see. A subfolder is also --bind
mounted over boot. Ok...
sudo umount /boot /esp
findmnt /dev/sda1
Nothing. What the hell?
echo "$?"
1
Ohhh... Well, that's nice. Hmmm...
for d in 1 2
do findmnt "/dev/sda$d" >/dev/null
printf "/dev/sda$d%.$((6>>!$?))s%s\n"\
" isn't" " currently mounted."
done
/dev/sda1 isn't currently mounted.
/dev/sda2 is currently mounted.
Oh, yeah, that's really nice.
for d in /dev/sd*
do findmnt -noSOURCE,TARGET "$d"
done
/dev/sda2[/arch_root] /
Now let's put sda1 back where it belongs and try that again...
sudo mount -a
for d in /dev/sd*
do findmnt -noSOURCE,TARGET "$d"
done
/dev/sda1 /esp
/dev/sda1[/EFI/arch_root] /boot
/dev/sda2[/arch_root] /
But where did I find this magical command?
man mount | sed -e:n -e'/findmnt/!d;N;/\n$/q;bn'
For more robust and customizable output use findmnt
(8), especially in your scripts. Note that control characters in the mountpoint name are replaced with ?
.