Skip to content
# Storage & disks

LVM basics: volumes you can resize later

Physical volumes, volume groups and logical volumes β€” and how to grow one.

Why LVM

A plain partition is fixed in size. LVM adds a layer that pools one or more disks (physical volumes) into a volume group, then carves out logical volumes from that pool that can be resized later without repartitioning.

Create the stack

Turn a raw disk into a physical volume, add it to a volume group, then create a logical volume from that group's free space.

bash
sudo pvcreate /dev/sdb
sudo vgcreate data-vg /dev/sdb
sudo lvcreate -L 50G -n data-lv data-vg
sudo mkfs.ext4 /dev/data-vg/data-lv

Grow a logical volume

Extend the logical volume first, then grow the filesystem on top of it to match. resize2fs works for ext4; XFS uses xfs_growfs instead and can only grow online, never shrink.

bash
sudo lvextend -L +20G /dev/data-vg/data-lv
sudo resize2fs /dev/data-vg/data-lv

Check current sizes

pvs, vgs and lvs give a one-line summary of physical volumes, volume groups and logical volumes respectively β€” the fastest way to see how much room is left to grow into.

bash
sudo pvs
sudo vgs
sudo lvs