33

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.

6 Answers 6

43

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.

2
  • Thanks. I think I got all the info I wanted. It looks like VGs contain both LVs and PVs, which makes sense.
    – user13185
    Apr 22, 2011 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, 2011 at 21:47
31

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
6

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
4

I like to use lsblk

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

Output enter image description here

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, 2021 at 10:50
  • Also lsblk doesn't show me the usage of LVM thin partitions... Apr 3, 2023 at 18:26
3

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.

1

I'm run the following command (lvs is for displaying logical LVM volumes):

lvs -a

This will give you an overview of all the LVM volumes, including virtual disks when using Proxmox for instance.

It not only shows you the size of the disks/partitions, but also the disk usage (in percentages)!

Look at "Data%" column on the right-side of the output, you might need to scroll horizontally to see the percentage values.

Output:

  LV                                   VG        Attr       LSize    Pool      Origin        Data%  Meta%  Move Log Cpy%Sync Convert
  main-data                            main-data twi-aotz--  456.32g                         23.58  1.08                            
  [main-data_tdata]                    main-data Twi-ao----  456.32g                                                                
  [main-data_tmeta]                    main-data ewi-ao----    4.66g                                                                
  snap_vm-100-disk-0_smaller-footprint main-data Vri---tz-k  200.00g main-data vm-100-disk-0                                        
  snap_vm-100-disk-1_smaller-footprint main-data Vri---tz-k   32.00g main-data vm-100-disk-1                                        
  vm-100-disk-0                        main-data Vwi-aotz--  200.00g main-data               50.33 

More info: https://man7.org/linux/man-pages/man8/lvs.8.html

You must log in to answer this question.