Linux: Extended LVM Reporting Commands
scottalanmiller last edited by
We can get handy summary information about an LVM system using pvs, vgs and lvs and in many cases these are all that we will need. But we can get far more data using the long form LVM commands pvdisplay, vgdisplay and lvdisplay. In this article we will take a look at these long form options.
First, pvdisplay using the same setup that we used in the last article:
# pvdisplay --- Physical volume --- PV Name /dev/vdb VG Name vg_data PV Size 37.25 GiB / not usable 2.97 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 9536 Free PE 0 Allocated PE 9536 PV UUID dpmeat-4CXc-gQwr-cSVq-uQDg-giTW-HRFf58 --- Physical volume --- PV Name /dev/vda2 VG Name centos PV Size 18.14 GiB / not usable 4.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 4642 Free PE 10 Allocated PE 4632 PV UUID WzMBk3-cge9-3Ege-fMcr-Mlho-syIV-ogMDxV
In this example we see our two physical volumes (PVs) and a great deal about them. What is totally new to us here is the idea of an *extent which is the storage term used inside of LVM and is roughly analogous to the idea of "blocks". LVM storage is handled at the extent level and in this case you can see that each extent is 4MB in size. So any allocation is handled only to the granularity of an extent. PE represents Physical Extents and Free PE and Allocated PE numbers are therefore self evident beyond that point.
Using vgdisplay we get a similar level of detail but about our volume groups.
# vgdisplay --- Volume group --- VG Name vg_data System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size 37.25 GiB PE Size 4.00 MiB Total PE 9536 Alloc PE / Size 9536 / 37.25 GiB Free PE / Size 0 / 0 VG UUID HKnURf-S2se-nfGC-dSAB-Or7R-hlqt-DCMq2u --- Volume group --- VG Name centos System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 18.13 GiB PE Size 4.00 MiB Total PE 4642 Alloc PE / Size 4632 / 18.09 GiB Free PE / Size 10 / 40.00 MiB VG UUID xt6lfk-wQp9-54Hl-TJhK-C5tH-Ry8r-ow9seW
As you can see we get a lot of data about our VGs. Much of what we see here is very detailed information about metadata and six lines just telling us how many LVs are associated with the group. What is interesting is that we see that we can control access with read/write options at the VG level which can be useful for locking an entire VG down to read only access.
Our last long form command is lvdisplay which is, by far, the most common of these longer commands.
# lvdisplay --- Logical volume --- LV Path /dev/vg_data/lv_data LV Name lv_data VG Name vg_data LV UUID sSkLXS-hojO-QeOB-Yanb-0c84-MUP3-cBfDig LV Write Access read/write LV Creation host, time localhost.localdomain, 2016-07-11 17:21:15 -0400 LV Status available # open 1 LV Size 37.25 GiB Current LE 9536 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2 --- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID pdm5cH-ktaU-2ooK-QkoH-hWyi-TREx-j5x6kA LV Write Access read/write LV Creation host, time localhost.localdomain, 2016-07-11 13:48:30 -0400 LV Status available # open 2 LV Size 1.86 GiB Current LE 477 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1 --- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID npOvsP-vstX-AcNW-q7Vv-czN5-WEI9-wVATuk LV Write Access read/write LV Creation host, time localhost.localdomain, 2016-07-11 13:48:31 -0400 LV Status available # open 1 LV Size 16.23 GiB Current LE 4155 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0
This command really allows us to dig into our Logical Volumes and see what is going on. It handily shows us the official path to the LV so that instead of searching for it we could look it up here or automate finding it via a script. Creation information is available here as well, which can be useful for documentation or looking up system change history.
However, for all of these commands, nearly all of the details included are far too much "under the hood" for normal administration tasks and so these commands are rarely used. We will, almost exclusively, work with the summary commands instead, but knowing that these are here is important and they are easy to use even if they provide too much information for normal use. The details here are so extreme that you can easily go through a full career without ever needing to dig into them specifically. When needed, however, they are available to us.
Part of a series on Linux Systems Administration by Scott Alan Miller