Check logical volume mount point (command line)

Just use lsblk. It prints all disks and their corresponding mount points. Including LVM, MD RAID, etc.


You may use this tool:

findmnt

To find all mount points or pipe it through grep, if you know device name, e.g.:

findmnt | grep hdd_vg

To find a specific UUID, just use:

findmnt -rn -S UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -o TARGET

To use this simple method, one needs to know the UUID of the partition.

Therefore the step by step guide would be:

ls -l /dev/mapper/

Then looking up its partition UUID with:

blkid /dev/dm-0

And finally just look up the mount point:

findmnt -rn -S UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -o TARGET

Example outputs:

ls -l /dev/mapper/

gives me:

total 0
crw------- 1 root root 10, 236 Nov 13 05:15 control
lrwxrwxrwx 1 root root       7 Nov 13 05:18 mint--vg-root -> ../dm-0
lrwxrwxrwx 1 root root       7 Nov 13 05:18 mint--vg-swap_1 -> ../dm-1

then:

blkid /dev/dm-0

gives me:

/dev/dm-0: UUID="32ee47f8-02df-481d-b731-6e67734999ca" TYPE="ext4"

and finally:

findmnt -rn -S UUID=32ee47f8-02df-481d-b731-6e67734999ca -o TARGET

gives me:

/

Which is the actual mount point in this VM.


Having the UUID of a logical volume, find out whether it's mounted and where.

  1. Find out volume group name and logical volume name:

sudo lvs -o vg_name,name,uuid

This will list all known logical volumes, with their UUIDs, names and the names of the volume group containing them. Remember the ‹vgname› and ‹lvname› corresponding to the given UUID.

  1. Now list all mounted device-backed file systems, and find your logical volume:

findmnt -l | grep ' /dev/\S\+'

Simple script:

UUID='B3629a-B11c-4aec-bE1f-rUdk-a6d2-dd0a6bc'
LVName="$(
  sudo lvs -o vg_name,name,uuid |
  grep "$UUID" |
  sed -e 's/^\s*\(\S\+\)\s\+\(\S\+\).*/\1-\2/'
)"
if [ -z "$LVName" ] ; then
  echo "Cannot find logical volume with UUID=$UUID"
else
  MountPoint="$(
    findmnt -l |
    grep " /dev/mapper/$LVName" |
    awk '{ print $1 }'
  )"
  if [ -z "$MountPoint" ] ; then
    echo "Logical volume /dev/mapper/$LVName with UUID $UUID is not mounted"
  else
    echo "Logical volume /dev/mapper/$LVName with UUID $UUID is mounted on $MountPoint"
  fi
fi