Skip to main content

LVM

LVM functions by layering abstractions on top of physical storage devices. The basic layers that LVM uses, starting with the most primitive, are.

  • Physical Volumes:
    • Description: Physical block devices or other disk-like devices (for example, other devices created by device mapper, like RAID arrays) are used by LVM as the raw building material for higher levels of abstraction. Physical volumes are regular storage devices. LVM writes a header to the device to allocate it for management.
  • Volume Groups:
    • Description: LVM combines physical volumes into storage pools known as volume groups. Volume groups abstract the characteristics of the underlying devices and function as a unified logical device with combined storage capacity of the component physical volumes.
  • Logical Volumes:
    • Description: A volume group can be sliced up into any number of logical volumes. Logical volumes are functionally equivalent to partitions on a physical disk, but with much more flexibility. Logical volumes are the primary component that users and applications will interact with.

Create a volume group

pvcreate /dev/sda1 /dev/sdb1
vgcreate vol_group_name /dev/sda1 /dev/sdb1
lvcreate -l 100%FREE -n drive_name vol_group_name

View info on group

pvscan
pvdisplay
vgdisplay
lvdisplay

Mount Hidden LVM (Perfect for rescue env)

pvscan                 
vgscan                 
vgchange -ay           
lvscan    
mount /dev/VolGroup00/LogVol00 /mnt

Grow XFS/EXT4 GPT LVM

Create new partition

GDisk
n
– Create a new partition
Verify partition start
Verify partition end
8E00
– Set the partition type to Linux LVM
w
– Write the changes to disk

Refresh partition

partprobe

Set new partition as LVM

pvcreate /dev/<partitionDeviceName>

 

Extend volume group

vgextend <volumeGroupName> /dev/<partitionDeviceName>

Increase volume

lvextend -l +100%FREE /dev/<volumeGroupName>/<logicalVolumeName>

Grow XFS

xfs_grow /dev/<volumeGroupName>/<logicalVolumeName>

or

Grow EXT4

resize2fs /dev/<volumeGroupName>/<logicalVolumeName>

Other Doc: