Remove Physical Volume from Volume Group

Snow Crash asked:

How do you remove a PV from a VG?

Here’s what I’ve tried:

# vgreduce vg_iscsi /dev/sdb1
Physical volume "/dev/sdb1" still in use

# lvs
LV         VG       Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root       centos   -wi-ao----   6.67g                                                    
  swap       centos   -wi-ao---- 820.00m                                                    
  lvm02      vg2      -wi-a----- 800.00m                                                    
  lv_iscsi_1 vg_iscsi -wi-ao----  52.00m  


# lvremove lv_iscsi_1
  Volume group "lv_iscsi_1" not found
  Cannot process volume group lv_iscsi_1

From the lvremove man page I assumed this command simply requires a LV. E.g.

       lvremove — remove a logical volume

       lvremove  [-A|--autobackup {y|n}] [--commandprofile ProfileName] [-d|--debug]
       [-h|--help] [-S|--select Selection]  [-t|--test]  [-v|--verbose]  [--version]
       [-f|--force] [--noudevsync] [LogicalVolume{Name|Path}...]

What am I missing?

My answer:

The vgreduce command is correct, but you can’t remove a physical volume from the volume group until it’s empty. That is what the error message that you received means.

As the man page states:

       To move all Physical Extents that are used by simple Logical Volumes on
       /dev/sdb1 to free Physical Extents elsewhere in the Volume Group use:

       pvmove /dev/sdb1

Once the PV is empty, you can then repeat the vgreduce command to remove it.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.