LVM, How can i add it.
Introduction
Logical Volume Manager (LVM) is widely used in Linux environments for flexible storage management. While creating and managing LVM is straightforward, real-world production issues require strong troubleshooting skills.
In interviews and real-time environments, you are expected not only to know commands but also to diagnose problems quickly and fix them without downtime or data loss.
This guide covers practical, interview-level troubleshooting scenarios that reflect real production issues.
Scenario 1: Logical Volume Full
Problem
An application stops working due to disk space exhaustion.
df -h
Output shows:
/dev/vg_data/lv_app 100%
Solution
Check available space in Volume Group:
vgdisplay vg_data
If free space is available:
lvextend -L +5G /dev/vg_data/lv_app
resize2fs /dev/vg_data/lv_app
Key Insight
Extending the Logical Volume alone is not enough. You must resize the filesystem.
Scenario 2: No Free Space in Volume Group
Problem
Volume Group has no free space.
vgdisplay
Output:
Free PE / Size: 0
Solution
Add a new disk:
fdisk /dev/sdc
pvcreate /dev/sdc1
vgextend vg_data /dev/sdc1lvextend -L +10G /dev/vg_data/lv_app
resize2fs /dev/vg_data/lv_app
Key Insight
LVM allows seamless scaling by adding new disks without downtime.
Scenario 3: Filesystem Not Resized
Problem
After extending LV, disk size does not change.
Root Cause
Filesystem not resized.
Solution
resize2fs /dev/vg_data/lv_app
For XFS filesystem:
xfs_growfs /mountpoint
Scenario 4: Missing Physical Volume
Problem
One disk fails.
pvdisplay
Shows missing PV.
Solution
vgreduce --removemissing vg_data
Advanced Recovery
lvconvert --repair /dev/vg_data/lv_app
Scenario 5: Live Data Migration
Problem
Disk replacement required without downtime.
Solution
pvmove /dev/sdb1 /dev/sdc1
vgreduce vg_data /dev/sdb1
Key Insight
LVM supports live data migration.
Scenario 6: Unable to Unmount Filesystem
Problem
umount /data
Error:
device is busy
Solution
lsof +D /data
kill -9 <PID>
Or:
umount -l /data
Scenario 7: Wrong Logical Volume Extended
Problem
Incorrect LV extended.
Solution (EXT4)
umount /data
e2fsck -f /dev/vg_data/lv_wrong
resize2fs /dev/vg_data/lv_wrong 5G
lvreduce -L 5G /dev/vg_data/lv_wrong
Warning
- Never shrink mounted filesystem
- XFS cannot be reduced
Scenario 8: Volume Group Not Active After Reboot
Problem
Logical volumes not visible after reboot.
Solution
vgscan
vgchange -ay
Scenario 9: Duplicate UUID Issue
Problem
Cloned disk causes UUID conflict.
Solution
pvchange --uuid /dev/sdb1
vgcfgrestore vg_data
Scenario 10: Snapshot Full
Problem
Snapshot runs out of space.
Solution
lvextend -L +2G /dev/vg_data/lv_snap
Or recreate:
lvremove /dev/vg_data/lv_snap
lvcreate -L 5G -s -n lv_snap /dev/vg_data/lv_app
Conclusion
LVM troubleshooting is a critical skill for Linux administrators and DevOps engineers. Real-world issues often require quick thinking, proper diagnosis, and safe execution of commands.
Mastering these scenarios will help you:
- Handle production incidents confidently
- Perform zero-downtime storage operations
- Succeed in technical interviews
Consistent hands-on practice is the key to mastering LVM in real environments.
