LVM (Logical Volume Manager) provides a layer of abstraction between physical storage and filesystems. Key components:
Physical Volumes (PVs): /dev/sda1, /dev/sdb2 Volume Groups (VGs): vg_staging Logical Volumes (LVs): lv_home, lv_var
- Dynamic resizing: Live expansion without unmounting (
lvextend -r -L +10G /dev/vg_staging/lv_home
) - Snapshot capability: Point-in-time backups (
lvcreate --snapshot -n snap_home -L 5G /dev/vg_staging/lv_home
) - Storage pooling: Combine multiple disks into single VG
- Thin provisioning: Over-allocate storage space efficiently
On our Ubuntu staging server, LVM introduces:
# Typical performance impact (fio benchmark): # Raw device: 450MB/s # LVM device: 420MB/s (~7% overhead) # Encrypted LVM: 320MB/s (~29% overhead)
Cryptsetup integration with LVM2:
# Setup process: cryptsetup luksFormat /dev/sdb1 cryptsetup open /dev/sdb1 crypt_storage pvcreate /dev/mapper/crypt_storage vgcreate vg_secure /dev/mapper/crypt_storage
Operation | LVM | Encrypted LVM |
---|---|---|
Sequential read | 98% | 65-75% |
Random 4K write | 95% | 50-60% |
Metadata ops | 90% | 70% |
Standard LVM recovery:
vgscan vgchange -ay fsck /dev/vg_staging/lv_root
Encrypted LVM recovery:
cryptsetup luksOpen /dev/sdb1 crypt_recover vgimport /dev/mapper/crypt_recover
Adding disk to existing setup:
# Standard LVM: pvcreate /dev/sdc1 vgextend vg_staging /dev/sdc1 # Encrypted LVM: cryptsetup luksFormat /dev/sdc1 cryptsetup open /dev/sdc1 crypt_new pvcreate /dev/mapper/crypt_new vgextend vg_secure /dev/mapper/crypt_new
Encrypted LVM requires initramfs configuration:
# /etc/crypttab: crypt_storage /dev/sdb1 none luks,discard # /etc/fstab: /dev/mapper/vg_secure-lv_root / ext4 defaults 0 1
For build servers with sensitive artifacts:
# Hybrid approach example: / ├── /boot (ext4, unencrypted) ├── / (LVM, unencrypted) └── /secure (encrypted LVM)
LVM (Logical Volume Manager) introduces an abstraction layer between physical storage and filesystems. The key components are:
Physical Volumes (PVs) → Volume Groups (VGs) → Logical Volumes (LVs)
Flexible storage management:
# Extend a filesystem without unmounting lvextend -L +10G /dev/vg00/lv_data resize2fs /dev/vg00/lv_data
Snapshot capabilities:
# Create snapshot for backup lvcreate -L 5G -s -n db_backup /dev/vg00/lv_database
Performance overhead: Additional abstraction layer impacts IOPS by ~5-15% depending on configuration.
Complexity: Recovery requires understanding multiple layers when disks fail.
Stack order matters for encrypted LVM:
Disk → LUKS Encryption → PV → VG → LV → Filesystem
Example setup during Ubuntu Server installation:
# Manual partitioning example cryptsetup luksFormat /dev/sdb1 cryptsetup open /dev/sdb1 crypt_sdb1 pvcreate /dev/mapper/crypt_sdb1 vgcreate vg_secure /dev/mapper/crypt_sdb1
Security benefits:
- Full disk encryption at rest
- Protection against physical theft
Operational challenges:
# Required for remote reboot scenarios echo "crypt_sdb1 UUID=... none luks,discard" >> /etc/crypttab
Benchmark results on Ubuntu 22.04 (NVMe SSD):
Operation | LVM | Encrypted LVM |
---|---|---|
4K Random Read | 350K IOPS | 290K IOPS |
Sequential Write | 2.1GB/s | 1.7GB/s |
Disk replacement with LVM:
pvcreate /dev/sdc1 vgextend vg00 /dev/sdc1 pvmove /dev/sdb1 /dev/sdc1 vgreduce vg00 /dev/sdb1
Encrypted LVM recovery:
cryptsetup luksOpen --header /backup/luks_header.img /dev/sdd1 crypt_recover vgchange -a y vg_secure
For staging environments where performance matters more than physical security:
- Use standard LVM without encryption
- Implement separate backup encryption
- Consider per-directory encryption for sensitive artifacts