CentOS / RHEL : How to remove unused Physical Volume(PV) from Volume Group (VG) in LVM

To remove any physical volume in a volume group vgreduce command can be used. The vgreduce command shrinks the volume group by removing one or more PVs. We can then either use these free PVS in another VG or remove them from the LVM configuration.

Removing the PV

1. Before removing a physical volume from a volume group, you can make sure that the physical volume is not used by any logical volumes by using the pvdisplay command.

# pvdisplay /dev/sdb1 -m
  --- Physical volume ---
  PV Name               /dev/sdb1
  VG Name               vg_os2
  PV Size               558.88 GiB / not usable 4.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              143072
  Free PE               40672
  Allocated PE          102400
  PV UUID               EPwws6-yxK0-7Ycb-IbFC-iYzE-5vNk-eQ7mYl

  --- Physical Segments ---
  Physical extent 0 to 51199:
    Logical volume      /dev/vg_os2/lv_data
    Logical extents     0 to 51199

As shown in the commnad output above, the PV /dev/sdb1 is in use in the LV /dev/vg_os2/lv_data. If the physical volume you want to delete have some data, you can move it using the pvmove command and then delete the LV. refer the posts below to migrate the data and remove LV:

2. Use the vgreduce command to remove the physical volume. The following command removes the physical volume /dev/hda1 from the volume group my_volume_group.

# vgreduce vg_os2 /dev/sdb1
Related Post