Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to list all the physical volume associated with logical volume.

I know lvdisplay, pvscan, pvdisplay -m could do the job. but I don't want to use these commands. Is there any other way to do it without using lvm2 package commands?

Any thoughts on comparing the major and minor numbers of devices?

share|improve this question
1  
The kernel numbers for a LV are not related to the base device(s). They can even change from one boot to the next. –  Hauke Laging Jul 4 '13 at 12:03

2 Answers 2

up vote 2 down vote accepted

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
share|improve this answer
    
@captain My /dev/mapper/linux-rootfs has been created with LVM. dmsetup uses just the part after /dev/mapper/. The LV rootfs in the VG linux gets the DM name linux-rootfs. –  Hauke Laging Jul 4 '13 at 12:54
    
@ Hauke Laging Let me correct it I created volume named 'test' using dmsetup and tried command ls /sys/block/dm-0/slaves/.I am not seeing any output. –  Pilot Jul 4 '13 at 13:03
    
@captain And your test is dm-0? –  Hauke Laging Jul 4 '13 at 13:06
    
@captain Strange. I am not familiar enough with the sysfs details in order to explain that. You could make that a separate question. –  Hauke Laging Jul 4 '13 at 13:12
1  
My mistake.ls /sys/block/dm-0/slaves/ worked for me. –  Pilot Jul 12 '13 at 6:18

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
share|improve this answer
    
@Hauke Laging check this as well –  Pilot Jul 17 '13 at 3:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.