LVM Object Mapping

Latest response

Probably a silly question, but it got asked of me today... Is there a good utility for mapping how a PV is used within a VG?

I'm generally fairly anal-retentive about how I lay out data - such that having a tool to create a pretty picture of how my PVs' extents are consumed hasn't been generally necessary. Worst case, I could always parse the /etc/lvm/backup files to backtrack things.

That said, VxVM used to have tools that would chart out how disks were cut up into subdisks and how those subdisks were used within the volumes of a  diskgroup. Just wondering if there are cognates within LVM2. I looked at pvs/lvs/vgs, but, they don't reall provide a nice, neat and self-explanatory mapping.


I generally use 'lvs -a -o +devices [<vg>]' to see the mapping of logical volumes to physical volumes:

[root@jrummy6-64-clust ~]# lvs -a -o +devices test
  LV             VG   Attr      LSize    Pool Origin Data%  Move Log Cpy%Sync Convert Devices                        
  lv1            test rwi---r-- 1012.00m                                              lv1_rimage_0(0),lv1_rimage_1(0)
  [lv1_rimage_0] test Iwi---r-- 1012.00m                                              /dev/mapper/mpathi(1)          
  [lv1_rimage_1] test Iwi---r-- 1012.00m                                              /dev/mapper/mpathj(1)          
  [lv1_rmeta_0]  test ewi---r--    4.00m                                              /dev/mapper/mpathi(0)          
  [lv1_rmeta_1]  test ewi---r--    4.00m                                              /dev/mapper/mpathj(0)          

You can also use system-config-lvm if you want a graphical representation of how things are laid out, although I generally don't recommend using it to actually manage your volumes, as it sometimes doesn't handle some of the more advanced layouts very well.

Have a look at the man pages for pvs, vgs, lvs and you can see the optional columns you can specify with -o.  These commands typically can give you pretty much any information you need, you just have to know which options to specify.

Let me know if you have any questions.


John Ruemker, RHCA

Senior Software Maintenance Engineer

Global Support Services

Red Hat, Inc.

Cool. I'd tried just doing an `lvs --segments` and doing an `lvs -vvv`. The latter gave me all the info I wanted (and more), but would have required a considerable level of parsing. Guess I'll have to see if the o options can give an output similar to the section of `lvs -vvv` where it gives you the extent-ranges for the PVs within volumes.

w00t: `lvs -a -o +devices,seg_start_pe,seg_size` does the trick!

Actually, even better: `pvs --segments -o +lv_name,seg_start_pe,segtype` gets me:

# pvs --segments -o +lv_name
  PV         VG         Fmt  Attr PSize   PFree Start SSize LV
  /dev/sda2  VolGroup00 lvm2 a--   24.84G    0      0   128 rootVol
  /dev/sda2  VolGroup00 lvm2 a--   24.84G    0    128   227 optVol
  /dev/sda2  VolGroup00 lvm2 a--   24.84G    0    355    64 homeVol
  /dev/sda2  VolGroup00 lvm2 a--   24.84G    0    419    64 tmpVol
  /dev/sda2  VolGroup00 lvm2 a--   24.84G    0    483   128 varVol
  /dev/sda2  VolGroup00 lvm2 a--   24.84G    0    611   128 auditVol
  /dev/sda2  VolGroup00 lvm2 a--   24.84G    0    739    56 swapVol
  /dev/sda3  VolGroup00 lvm2 a--    5.00G 3.50G     0    48 varVol
  /dev/sda3  VolGroup00 lvm2 a--    5.00G 3.50G    48   112

Guess I shoulda dug harder in vgs/lvs/pvs man pages. :p