Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Map lvm volume to Physical volume

Tags:

linux

lvm

lsblk provides output in this fornat:

NAME                        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sr0                          11:0    1  1024M  0 rom
sda                           8:0    0   300G  0 disk
sda1                          8:1    0   500M  0 part /boot
sda2                          8:2    0 299.5G  0 part
vg_data1-lv_root (dm-0)  253:0    0    50G  0 lvm  /
vg_data2-lv_swap (dm-1)  253:1    0   7.7G  0 lvm  [SWAP]
vg_data3-LogVol04 (dm-2) 253:2    0  46.5G  0 lvm
vg_data4-LogVol03 (dm-3) 253:3    0  97.7G  0 lvm  /map1
vg_data5-LogVol02 (dm-4) 253:4    0  97.7G  0 lvm  /map2
sdb                           8:16   0    50G  0 disk

for a mounted volume say /map1 how do i directly get the physical volume associated with it. Is there any direct command to fetch the information?

like image 515
Nida Sahar Avatar asked Dec 01 '22 15:12

Nida Sahar


1 Answers

There is no direct command to show that information for a mount. You can run

lvdisplay -m

Which will show which physical volumes are currently being used by the logical volume.

Remember, thought, that there is no such thing as a direct association between a logical volume and a physical volume. Logical volumes are associated with volume groups. Volume groups have a pool of physical volumes over which they can distribute any volume group. If you always want to know that a given lv is on a given pv, you have to restrict the vg to only having that one pv. That rather misses the point. You can use pvmove to push extents off a pv (sometimes useful for maintenance) but you can't stop new extents being created on it if logical volumes are extended or created.

As to why there is no such potentially useful command...

LVM is not ZFS. ZFS is a complete storage and filesystem management system, managing both storage (at several levels of abstraction) and the mounting of filesystems. LVM, in contrast, is just one layer of the Linux Virtual File System. It provides a layer of abstraction on top of physical storage devices and makes no assumption about how the logical volumes are used.

like image 117
itsbruce Avatar answered Dec 04 '22 05:12

itsbruce