Disk Management with LVM
Intermediate15 min
Manage logical volumes, extend filesystems, and monitor disk health using LVM and standard disk utilities.
Prerequisites
- -Linux shell access
- -Root or sudo access
- -LVM installed
Steps
1
View physical volumes
List all physical volumes in the LVM system.
$ sudo pvs
2
View volume groups and free space
Check volume groups and how much space is available for new logical volumes.
$ sudo vgs
3
List logical volumes with details
View all logical volumes and their sizes.
$ sudo lvs -o lv_name,vg_name,lv_size,lv_attr
4
Extend a logical volume and resize the filesystem
Add more space to an existing logical volume and grow the filesystem to use it.
$ sudo lvextend -L +10G /dev/vg0/lv_data && sudo resize2fs /dev/vg0/lv_data
Use -l +100%FREE to use all remaining free space in the volume group.
For XFS filesystems, use 'xfs_growfs /mount/point' instead of resize2fs.
5
Check filesystem health
Verify filesystem integrity. Must be run on unmounted or read-only filesystems.
$ sudo fsck -n /dev/vg0/lv_data
Never run fsck on a mounted read-write filesystem. Use -n for a read-only check.
Full Script
FAQ
Discussion
Loading comments...