Extending LVM Storage by Adding a New Disk in CentOS
Add a new physical disk to the system. The system should detect it as /dev/sdb.
Create a physical volume (PV) from the new disk:
pvcreate /dev/sdb
Verify the PV was created:
pvs
Display detailed PV information:
pvdisplay
Extand the existing volume group (VG) by adding the new PV:
vgextend vg_template /dev/sdb
Check the VG details to confirm available free space:
vgdisplay
Extand the logical volume (LV) to use all available free space:
lvextend -l +100%FREE /dev/mapper/vg_template-lv_root
Determine the filesystem type before resizing:
df -Th
For ext4 filesystems, resize with:
resize2fs /dev/mapper/vg_template-lv_root
For XFS filesystems, use:
xfs_growfs /dev/mapper/vg_template-lv_root
Verify the extended storage capacity:
df -Th
Troubleshoooting Disk Filter Issues
If pvcreate fails with "Device excluded by a filter":
parted /dev/sda print
Reinitialize the disk label (WARNING: destroys all data):
parted /dev/sda
(parted) mklabel loop
(parted) print