26

I have following situation:

=$ LC_ALL=C df -hP | column -t
Filesystem              Size  Used  Avail  Use%  Mounted  on
/dev/mapper/vg0-rootlv  19G   854M  17G    5%    /
/dev/mapper/vg0-homelv  19G   343M  18G    2%    /home
/dev/mapper/vg0-optlv   19G   192M  18G    2%    /opt
/dev/mapper/vg0-varlv   19G   357M  18G    2%    /var

I'd like to know what physical disks are used by these volumes, and how much free disk space (unallocated) I have, so that I will know how much I can grow these.

5 Answers5

37

This is relatively easy. Use lvdisplay to show logical volumes, vgdisplay to show volume groups (including free space available) and pvdisplay to show physical volumes.

You should get all the data you need from those three commands, albeit with some work to figure out what all the various bits of data mean.

malcolmpdx
  • 2,250
  • 1
  • 15
  • 12
  • Thanks. I think I got all the info I wanted. It looks like VGs contain both LVs and PVs, which makes sense. –  Apr 22 '11 at 16:45
  • strictly, vg's contain pv's and lv's are constructed from vg's. Great to hear you got what you needed. – malcolmpdx Apr 22 '11 at 21:47
28

pvs, vgs and lvs are convenient easy-to-read alternatives to pvdisplay, vgdisplay and lvdisplay if you only need a summary. E.g. :

# pvs
  PV         VG     Fmt  Attr PSize   PFree 
  /dev/sda2  fedora lvm2 a--  232,59g 20,87g
5

The "maps" option is what you are after. This works at the lv level as well as pv.

So if you want to see what room an LV is taking up on a volume, do

lvdisplay -m <volumegroupname>

If you want to see the usage of PVs, do

pvdisplay -m
Paul
  • 1,228
  • 12
  • 24
3

I like to use lsblk

lsblk -ao NAME,FSTYPE,FSSIZE,FSUSED,FSUSE%

Output enter image description here

1nternetz
  • 146
  • 2
  • Good suggestion. But the output titles (`-o` options like `FSTYPE,FSSIZE,...`) aren't standard. Use `lsblk --help` to see what's available in your corner of the Internet. Sadly, RHEL7 for example doesn't have `FSUSED` or `FSUSE%`. – fbicknel Apr 19 '21 at 10:50
2

pvs -o+devices gives a concise output showing you all the PVs, what devices they're on, and at the end any free space and the device it is on.

But even more useful, to map physical extents to logical extents use: pvs --segments -o+lv_name,seg_start_pe,segtype

The output will look something like this:

  # pvs --segments -o+lv_name,seg_start_pe,segtype
  PV         VG   Fmt  Attr PSize    PFree    Start SSize LV      Start Type
  /dev/sda2  vg01 lvm2 a--   <71.02g       0      0   500 lvswap      0 linear
  /dev/sda2  vg01 lvm2 a--   <71.02g       0    500  2500 lvaudit     0 linear
[...]
  /dev/sdc1  vg01 lvm2 a--  <256.00g <185.63g     0  7518 lvdata  41890 linear
  /dev/sdc1  vg01 lvm2 a--  <256.00g <185.63g  7518   256 lvvar    2500 linear
  /dev/sdc1  vg01 lvm2 a--  <256.00g <185.63g  7774 10240 lvdata  49408 linear
  /dev/sdc1  vg01 lvm2 a--  <256.00g <185.63g 18014 47521             0 free

I can't take any credit for this. It's in the manpage for lvdisplay.

fbicknel
  • 161
  • 5