Linux – How to find the physical volume(s) that hold a logical volume in LVM

linuxlvm

I have a volume group (VG) that contains two physical volumes (PV).
Several logical volumes (LV) in the VG are likely to use extents on both PVs.

Is there a way to tell which LVs occupy space on which PVs?

Best Answer

The pvdisplay command has a -m option to show the mapping of physical extents to logical volumes and logical extents.

I have set up the following situation on a test machine:

  • 3 disks of 1GB each added to the system and used as physical volumes for vg_test
  • 6 logical volumes made with various sizes (ranging from 300M to 1.1G) so that they are spread over the physical volumes

Running pvdisplay -m on this machine results in the following output:

[root@centos6 ~]# pvdisplay -m
  --- Physical volume ---
  PV Name               /dev/sdb
  VG Name               vg_test
  PV Size               1.00 GiB / not usable 4.00 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              255
  Free PE               5
  Allocated PE          250
  PV UUID               eR2ko2-aKRf-uCfq-O2L0-z6em-ZYT5-23YhKb

  --- Physical Segments ---
  Physical extent 0 to 74:
    Logical volume  /dev/vg_test/one
    Logical extents 0 to 74
  Physical extent 75 to 149:
    Logical volume  /dev/vg_test/two
    Logical extents 0 to 74
  Physical extent 150 to 249:
    Logical volume  /dev/vg_test/four
    Logical extents 0 to 99
  Physical extent 250 to 254:
    FREE

  --- Physical volume ---
  PV Name               /dev/sdc
  VG Name               vg_test
  PV Size               1.00 GiB / not usable 4.00 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              255
  Free PE               10
  Allocated PE          245
  PV UUID               rByjXK-NA6D-ifnY-lKdF-eFWg-Ndou-psGJUq

  --- Physical Segments ---
  Physical extent 0 to 124:
    Logical volume  /dev/vg_test/three
    Logical extents 0 to 124
  Physical extent 125 to 224:
    Logical volume  /dev/vg_test/five
    Logical extents 0 to 99
  Physical extent 225 to 244:
    Logical volume  /dev/vg_test/six
    Logical extents 255 to 274
  Physical extent 245 to 254:
    FREE

  --- Physical volume ---
  PV Name               /dev/sdd
  VG Name               vg_test
  PV Size               1.00 GiB / not usable 4.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              255
  Free PE               0
  Allocated PE          255
  PV UUID               TCJnZM-0ss9-o5gY-lgD3-7Kq6-18IH-sN04To

  --- Physical Segments ---
  Physical extent 0 to 254:
    Logical volume  /dev/vg_test/six
    Logical extents 0 to 254

As you can see, You get a nice overview of where the extents for each of the 6 logical volumes are.