Listen to this Post
Logical Volume Management (LVM) is a powerful storage management system in Linux that enables flexible disk space allocation. This guide covers essential concepts, commands, and practical examples to help you master LVM.
Basic LVM Concepts
LVM consists of three main components:
- Physical Volume (PV) – A physical disk or partition initialized for LVM.
- Volume Group (VG) – A pool of one or more PVs.
- Logical Volume (LV) – A virtual partition created from a VG.
Common LVM Commands
Physical Volume (PV) Operations
pvcreate /dev/sdX Initialize a disk/partition as PV pvdisplay Show PV details pvs List all PVs pvremove /dev/sdX Remove a PV
Volume Group (VG) Operations
vgcreate vg_name /dev/sdX Create a VG from PV vgdisplay Display VG details vgs List all VGs vgextend vg_name /dev/sdY Add a PV to VG vgreduce vg_name /dev/sdX Remove a PV from VG
Logical Volume (LV) Operations
lvcreate -L 10G -n lv_name vg_name Create a 10GB LV lvdisplay Show LV details lvs List all LVs lvextend -L +5G /dev/vg_name/lv_name Extend LV by 5GB resize2fs /dev/vg_name/lv_name Resize filesystem (ext4) xfs_growfs /dev/vg_name/lv_name Resize filesystem (XFS)
Real-World LVM Examples
1. Extending an LV
Check free space in VG vgdisplay vg_name Extend LV lvextend -L +5G /dev/vg_name/lv_name Resize filesystem (for ext4) resize2fs /dev/vg_name/lv_name
2. Creating a New LV
Create a 20GB LV lvcreate -L 20G -n new_lv vg_name Format as ext4 mkfs.ext4 /dev/vg_name/new_lv Mount mkdir /mnt/new_lv mount /dev/vg_name/new_lv /mnt/new_lv
3. Removing an LV
Unmount umount /mnt/lv_name Remove LV lvremove /dev/vg_name/lv_name
You Should Know:
- Always back up data before modifying LVM structures.
- Use `lsblk` and `df -h` to verify disk layouts.
- LVM supports snapshots (
lvcreate --snapshot
). - For encrypted LVM, use LUKS (
cryptsetup
).
What Undercode Say:
LVM is a must-know for Linux admins, offering flexibility in storage management. Key takeaways:
✔ Use `pvcreate`, `vgcreate`, `lvcreate` for setup.
✔ Extend LVs with `lvextend` and `resize2fs`.
✔ Monitor with `pvs`, `vgs`, `lvs`.
✔ Snapshots help in backups.
✔ Combine LVM with RAID for redundancy.
Expected Output:
A structured, actionable guide to LVM with verified commands for Linux storage management.
For more details, check the original post: LinkedIn Post (if applicable)
References:
Reported By: Shamseer Siddiqui – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅