Problem Statement
What is LVM and what are its main components?
Explanation
LVM (Logical Volume Manager) provides flexible disk management. Components: Physical Volumes (PVs) are physical disks or partitions, Volume Groups (VGs) pool PVs, Logical Volumes (LVs) are virtual partitions created from VGs. Advantages: resize volumes online, span volumes across disks, snapshots for backups.
Create LVM: pvcreate /dev/sdb creates PV, vgcreate vg_data /dev/sdb creates VG, lvcreate -L 10G -n lv_data vg_data creates 10GB LV. Format and mount: mkfs.ext4 /dev/vg_data/lv_data, mount /dev/vg_data/lv_data /data.
Resize: lvextend -L +5G /dev/vg_data/lv_data adds 5GB, resize2fs /dev/vg_data/lv_data resizes filesystem. Shrink: umount first, resize filesystem, then lvreduce. Snapshots: lvcreate -L 1G -s -n snap_data /dev/vg_data/lv_data creates snapshot.
Management commands: pvs/vgs/lvs (display info), pvdisplay/vgdisplay/lvdisplay (detailed), vgextend (add PV to VG), lvremove (remove LV). Understanding LVM enables flexible storage management in enterprise environments.
