How to Use LVM for Flexible Disk Management
Logical Volume Manager (LVM) adds a layer of abstraction between your physical disks and filesystems, allowing you to resize volumes, create snapshots, and span storage across multiple disks on your Breeze.
Core Concepts
- Physical Volume (PV) — a raw disk or partition initialized for LVM
- Volume Group (VG) — a pool of storage from one or more PVs
- Logical Volume (LV) — a virtual partition carved from a VG
Setting Up LVM
# Initialize physical volume
sudo pvcreate /dev/sdb
# Create a volume group
sudo vgcreate breeze-vg /dev/sdb
# Create a logical volume using 80% of available space
sudo lvcreate -l 80%FREE -n data breeze-vg
# Format and mount
sudo mkfs.ext4 /dev/breeze-vg/data
sudo mkdir -p /mnt/data
sudo mount /dev/breeze-vg/data /mnt/data
Resizing Volumes
One of LVM's greatest strengths is live resizing:
# Extend the logical volume by 10GB
sudo lvextend -L +10G /dev/breeze-vg/data
# Resize the filesystem to match
sudo resize2fs /dev/breeze-vg/data
Creating Snapshots
sudo lvcreate -s -n data-snap -L 5G /dev/breeze-vg/data
Snapshots capture the state of a volume at a point in time, useful for backups or testing changes on your Breeze before committing to them.