CentOS 7.x LVM Remove physical volume from volume group
From Notes_Wiki
Home > CentOS > CentOS 7.x > System Administration > File system management > LVM > CentOS 7.x LVM Remove physical volume from volume group
To remove physical volume from volume group, there should be at least as many free Physical Extents (PE) in VG as present in that particular Pysical volume. Then we can move all used PE from Physical volume to other physical volumes in same VG and reduce "Used PE" count for physical volume to be removed to zero. Once used PE count is zero we can remove PV via vgreduce command.
Overall steps are:
- Check for free PE in VG using:
- vgs
- vgdisplay <VG-Name>
- If there are not enough PE in VG then you can add another PV to increase the free PV count for the pvmove to be used in next step. Refer CentOS 7.x Live extend size of ext4 on top of LVM without umount
- Check current usage of PV using:
- pvgdisplay <PVDevicename>
- For example
- pvdisplay /dev/sdb1
- Based on the output such as:
- Total PE 927671
- Free PE 15
- Allocated PE 927656
- Goal is to change "Allocated PE" count to 0. While Total PE and Free PE count will become equal.
- Move the used / allocated PE to other PVs using:
- pvmove <PV-Device-name>
- This will take time proportional to move of data from one PV to all other PVs. Hence if PV is large and IOPS are low this can take really long time
- Finally revalidate that PV Allocated PE count is zero using:
- pvgdisplay <PVDevicename>
- Remove the unused PV from VG using:
- vgreduce <VG-Name> <VG-DeviceName>
Refer:
Home > CentOS > CentOS 7.x > System Administration > File system management > LVM > CentOS 7.x LVM Remove physical volume from volume group