Let's assume we have lv path:
lvpath=/dev/mapper/vg2-Music
Than I split lvdisplay -c with cut:
vgname="$(lvdisplay -c "$lvpath" | cut -d ':' -f 2 )"
lvname="$(basename "$(lvdisplay -c "$lvpath" | cut -d ':' -f 1 )" )"
result:
$ echo VG: $vgname LV: $lvname
VG: vg2 LV: Music
question:
Is there more convenient way of doing this ?
Can I rely on lvdisplay -c that will always provide path in form /dev/VGname/LVname ? (In case of /dev/mapper/VGname-LVname basename sould be exchanged with sed)
Is there tool from LVM2 package to obtain LVname from path?