I've had the same issue, maybe little "deeper": up to the mount point level. In case anyone is interested, here are two functions I'm using, for querying both ways.
######## FIND THE LVPATH of an existing FS. Query the lvm using FS' mount point fileSystem_to_lvPath(){ #Call like this: fileSystem_to_lvPath /tmp #and should return somethig similar to: /dev/vg00/tmp #Relevant commands for debug: blkid, lsblk, dmsetup, lvdisplay, lvs FS_TO_QUERY=$1 #Find DeviceMapper_MajorMinorNumber for specific fs DeviceMapper_MajorMinorNumber=$(lsblk --noheadings --output TYPE,MAJ:MIN,MOUNTPOINT | grep -w lvm | grep -w $FS_TO_QUERY | awk '{print $2}') #VG=$(lvs --noheadings --separator : --options lv_kernel_major,lv_kernel_minor,vg_name,lv_name,lv_path | grep $DeviceMapper_MajorMinorNumber | awk -F : '{print $3}') #LV=$(lvs --noheadings --separator : --options lv_kernel_major,lv_kernel_minor,vg_name,lv_name,lv_path | grep $DeviceMapper_MajorMinorNumber | awk -F : '{print $4}') LV_PATH=$(lvs --noheadings --separator : --options lv_kernel_major,lv_kernel_minor,vg_name,lv_name,lv_path | grep $DeviceMapper_MajorMinorNumber | awk -F : '{print $5}') echo $LV_PATH #echo "$VG/$LV" }
and the reverse query:
######## FIND THE FS (and FS' mountpoint) of an existing LVPATH: lvPath_to_fileSystem(){ LV_PATH=$1 #Call like this: lvPath_to_fileSystem /dev/vg00/opt #and should return something like: /opt #Relevant commands for debug: blkid, lsblk, dmsetup, lvdisplay, lvs #Find DeviceMapper_MajorMinorNumber for specific lv_path DeviceMapper_MajorMinorNumber=$(lvs --noheadings --separator : --options lv_kernel_major,lv_kernel_minor,vg_name,lv_name,lv_path | grep $LV_PATH | awk -F : '{print $1":"$2}') FS=$(lsblk --noheadings --output TYPE,MAJ:MIN,MOUNTPOINT | grep -w lvm | grep -w $DeviceMapper_MajorMinorNumber | awk '{print $3}') echo $FS }