Description

In Linux, Logical Volume Manager (LVM) is a device mapper target that provides logical volume management for the Linux kernel. LVM is used for the following purposes:

LVM can be considered as a thin software layer on top of the hard disks and partitions, which creates an abstraction of continuity and ease-of-use for managing hard drive replacement, repartitioning and backup.

(source: WikiPedia)

Theory

LogicalVolumenManager.jpg

Command's

Volume group

To view the free space of your volume group, or the physical storage, run vgdisplay. As you can see, I got 52GB in use and 170GB free.

root@scrat:~# vgdisplay 
  --- Volume group ---
  VG Name               scrat-vg
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               222.82 GiB
  PE Size               4.00 MiB
  Total PE              57042
  Alloc PE / Size       13436 / 52.48 GiB
  Free  PE / Size       43606 / <170.34 GiB
  VG UUID               e3grIy-rsTn-iUN6-Qpp2-wnnX-R2HP-s3BM7B

Logical volume

We can also see the logical volumes inside the volume group. This is the lvdisplay command. As you can see, the volume has a size of almost 9GB.

root@scrat:~# lvdisplay 
  --- Logical volume ---
  LV Path                /dev/scrat-vg/root
  LV Name                root
  VG Name                scrat-vg
  LV UUID                m5R02p-mx2h-gbTU-sWsv-n2n6-ov5b-Y8Y9f7
  LV Write Access        read/write
  LV Creation host, time scrat, 2020-04-23 18:34:58 +0200
  LV Status              available
  # open                 1
  LV Size                10.00 GiB
  Current LE             2216
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:1

Resize

You can resize the logical volume. You only change the partition size, not the formatting! The + is for the amount of data you want to add tothe volume. Without it's the total amount the volume has to become.

root@scrat:~# lvextend -L+5G /dev/scrat-vg/root
  Rounding size to boundary between physical extents: 4.90 GiB
  Size of logical volume centos/var changed from 10.00 GiB (1280 extents) to 15.00 GiB (2560 extents).
  Logical volume var successfully resized

Grow filesystem

To let the filesystem grow, online, use for ext3/4:

resize2fs /dev/scrat-vg/root

For xfs based filesystems:

xfs_growfs /dev/scrat-vg/root

Howto/LVM (last edited 2020-04-30 15:55:15 by Sciuro)