Wednesday, November 8, 2017

Can't remove final physical volume  from volume group (Linux)

I have:
[root@localhost ~]# vgs
  VG       #PV #LV #SN Attr   VSize   VFree 
  VolGroup   1   0   0 wz--n- 279.36g 279.36g
  centos     1   3   0 wz--n-  <3.64t   3.04t
[root@localhost ~]# pvs
  PV         VG       Fmt  Attr PSize   PFree 
  /dev/sda3  centos   lvm2 a--   <3.64t   3.04t
  /dev/sdb1  VolGroup lvm2 a--  279.36g 279.36g
 and want to remove VolGroup and add /dev/sdb1 into centos VG:
[root@localhost ~]# pvremove /dev/sdb1
  PV /dev/sdb1 is used by VG VolGroup so please use vgreduce first.
  (If you are certain you need pvremove, then confirm by using --force twice.)
  /dev/sdb1: physical volume label not removed.
[root@localhost ~]# vgreduce VolGroup /dev/sdb1
  Can't remove final physical volume "/dev/sdb1" from volume group "VolGroup"

To overcome that issue we'll first inactivate "VolGroup" and then remove that VG:
[root@localhost ~]# vgchange -an VolGroup
  0 logical volume(s) in volume group "VolGroup" now active
[root@localhost ~]# vgremove VolGroup
  Volume group "VolGroup" successfully removed 

Verifying and adding PV to a VG:
[root@localhost ~]# vgs
  VG     #PV #LV #SN Attr   VSize  VFree
  centos   1   3   0 wz--n- <3.64t 3.04t
[root@localhost ~]# pvs
  PV         VG     Fmt  Attr PSize   PFree 
  /dev/sda3  centos lvm2 a--   <3.64t   3.04t
  /dev/sdb1         lvm2 ---  279.36g 279.36g
[root@localhost ~]# vgextend centos /dev/sdb1
  Volume group "centos" successfully extended
[root@localhost ~]# vgs
  VG     #PV #LV #SN Attr   VSize VFree
  centos   2   3   0 wz--n- 3.91t 3.31t
[root@localhost ~]# pvs
  PV         VG     Fmt  Attr PSize   PFree 
  /dev/sda3  centos lvm2 a--   <3.64t   3.04t
  /dev/sdb1  centos lvm2 a--  279.36g 279.36g


2 comments: