Logical Volume Manager (LVM) and Storage Administration
LVM provides flexible disk allocation across physical hard drives, enabling online volume expansion without unmounting filesystems or service interruptions.
1. LVM Architecture Hierarchy
[ Physical Disks / Partitions: /dev/sdb1, /dev/sdc1 ]
│
▼ (pvcreate)
[ Physical Volumes (PV) ]
│
▼ (vgcreate)
[ Volume Group (VG) ] <── Pool of Physical Extents (PE, default 4MB)
│
▼ (lvcreate)
[ Logical Volume (LV) ] <── Formatted with XFS or ext4
│
▼ (mount & /etc/fstab)
[ Mount Point: /var/data ]
2. Essential Command Workflow for RHCSA
Step 1: Create Physical Volumes
# Initialize block devices as LVM physical volumes
pvcreate /dev/vdb1 /dev/vdb2
pvs # Display brief summary
pvdisplay # Display detailed attributes
Step 2: Create or Extend Volume Groups
# Create volume group 'vg_data' with standard extent size
vgcreate vg_data /dev/vdb1
# Extend an existing volume group when adding new disks
vgextend vg_data /dev/vdb2
vgs
Step 3: Create Logical Volumes
# Create 10GB logical volume named 'lv_reports'
lvcreate -n lv_reports -L 10G vg_data
# Create logical volume using 50 extents
lvcreate -n lv_temp -l 50 vg_data
lvs
Step 4: Format and Mount Persistently
# Format with XFS filesystem
mkfs.xfs /dev/vg_data/lv_reports
# Find UUID for /etc/fstab entry
blkid /dev/vg_data/lv_reports
# Append to /etc/fstab:
# UUID=xxxx-xxxx /data xfs defaults 0 0
mount -a # Test fstab immediately without rebooting!
3. High-Yield Task: Online Expansion with lvextend -r
[!TIP] The single most critical LVM command for RHCSA is
lvextend -r:# Add 500MB and automatically resize the underlying filesystem (XFS or ext4) in one atomic step: lvextend -r -L +500M /dev/vg_data/lv_reports # Or set target absolute size to 15GB: lvextend -r -L 15G /dev/vg_data/lv_reportsThe
-r(--resizefs) flag invokesxfs_growfsfor XFS orresize2fsfor ext4 automatically while keeping the filesystem mounted online!
4. XFS vs ext4 Expansion Rule
- XFS: Can be grown online, but cannot be shrunk (attempting to shrink will corrupt the filesystem).
- ext4: Can be grown online and shrunk offline (unmounted).
Cross-reference: See NFS Client Mounting and On-Demand automounting with autofs for automounting remote shares and persistent local storage.