list the devices associated with logical volumes without using lvm2 package commands
There are two possibilities:
If you accept dmsetup
as a non-lvm package command (at openSUSE the is a separate package device-mapper
) then you can do this:
dmsetup table "${vg_name}-${lv_name}"
Or you do this:
start cmd: # ls -l /dev/mapper/linux-rootfs
lrwxrwxrwx 1 root root 7 27. Jun 21:34 /dev/mapper/linux-rootfs -> ../dm-0
start cmd: # ls /sys/block/dm-0/slaves/
sda9
Folks , If you certainly needs to dive inside it then you can give thoughts on comparing Major and minor number
ubuntu@ubuntu-OptiPlex-3010:~$ sudo dmsetup ls
vgpool-lvstuff (253, 0)
I created this logical volume using disk sda1
ubuntu@ubuntu-OptiPlex-3010:~$ sudo dmsetup deps vgpool-lvstuff
1 dependencies : (8, 1)
(8, 1) gives me the (major,minor) number of disk on which lvm is dependent which I will compare using following command.
ubuntu@ubuntu-OptiPlex-3010:~$ sudo cat /proc/partitions
major minor #blocks name
8 0 488386584 sda
8 1 305368 sda1
8 2 3150112 sda2
List all mappers and get all information for each identifier in one line using native commands:
for file in $(ls -la /dev/mapper/* | grep "\->" | grep -oP "\-> .+" | grep -oP " .+"); do echo "MAPPER:"$(F=$(echo $file | grep -oP "[a-z0-9-]+");echo $F":"$(ls "/sys/block/${F}/slaves/");)":"$(df -h "/dev/mapper/${file}" | sed 1d); done;
Result like as:
MAPPER:dm-0:sdd1:/dev/mapper/luks-00000000-0000-0000-0000-000000000000 916G 487G 384G 56% /media/whk/Secure1
MAPPER:dm-1:sde1:/dev/mapper/luks-00000000-0000-0000-0000-000000000000 916G 487G 384G 56% /media/whk/Secure2
The las out is a df -h
command.
Thanks to @hauke-laging for the comprension of the structure.