How to remove logical and physical volume from Volume Group in Linux

Remove Logical Volume from Volume Group

NOTE: Make sure the logical volume to be removed is unmounted.

Syntax:

# lvremove /path/to/lvm

Once the logical volume is unmounted run the below command from the terminal

# lvremove /dev/NewGroup/office  
Do you really want to remove active logical volume office? [y/n]: y  
  Logical volume "office" successfully removed  

Verify the changes (As you see "office" logical volume is successfully deleted)

[root@test2 ~]# lvdisplay  
  --- Logical volume ---  
  LV Path                /dev/NewGroup/root  
  LV Name                root  
  VG Name                NewGroup  
  LV UUID                52mm9d-feyC-AWVH-NTMC-VwNa-Ns1p-cJc8vJ  
  LV Write Access        read/write  
  LV Creation host, time test2.example, 2014-03-14 02:37:58 +0530  
  LV Status              available  
  # open                 1  
  LV Size                9.92 GiB  
  Current LE             2539  
  Segments               1  
  Allocation             inherit  
  Read ahead sectors     auto  
  - currently set to     256  
  Block device           253:0

  --- Logical volume ---  
  LV Path                /dev/NewGroup/swap  
  LV Name                swap  
  VG Name                NewGroup  
  LV UUID                48hszS-I0uT-Zsxr-jnoY-yEbj-hfBJ-isofU7  
  LV Write Access        read/write  
  LV Creation host, time test2.example, 2014-03-14 02:38:00 +0530  
  LV Status              available  
  # open                 1  
  LV Size                1.95 GiB  
  Current LE             500  
  Segments               1  
  Allocation             inherit  
  Read ahead sectors     auto  
  - currently set to     256  
  Block device           253:1

Remove Physical Volume from Volume Group

Verify the physical volume to be removed

# vgdisplay -v  
    Finding all volume groups  
    Finding volume group "VolGroup"  
  --- Volume group ---  
  VG Name               VolGroup  
  System ID  
  Format                lvm2  
  Metadata Areas        2  
  Metadata Sequence No  25  
  VG Access             read/write  
  VG Status             resizable  
  MAX LV                0  
  Cur LV                2  
  Open LV               2  
  Max PV                0  
  Cur PV                2  
  Act PV                2  
  VG Size               10.81 GiB  
  PE Size               4.00 MiB  
  Total PE              2767  
  Alloc PE / Size       2265 / 8.85 GiB  
  Free  PE / Size       502 / 1.96 GiB  
  VG UUID               uH5AP5-b24E-92h7-nL8b-7Bio-fXe3-pstWIW

  --- Logical volume ---  
  LV Path                /dev/VolGroup/root  
  LV Name                root  
  VG Name                VolGroup  
  LV UUID                Qn8TnI-TLNm-rl4Y-ORnd-zU3p-2Kj1-ALSLAg  
  LV Write Access        read/write  
  LV Creation host, time ,  
  LV Status              available  
  # open                 1  
  LV Size                6.85 GiB  
  Current LE             1753  
  Segments               2  
  Allocation             inherit  
  Read ahead sectors     auto  
  - currently set to     256  
  Block device           253:0

  --- Logical volume ---  
  LV Path                /dev/VolGroup/swap  
  LV Name                swap  
  VG Name                VolGroup  
  LV UUID                M1ucwx-2sjb-o9Q4-a2td-aPvi-FO1C-ggHuPn  
  LV Write Access        read/write  
  LV Creation host, time ,  
  LV Status              available  
  # open                 1  
  LV Size                2.00 GiB  
  Current LE             512  
  Segments               1  
  Allocation             inherit  
  Read ahead sectors     auto  
  - currently set to     256  
  Block device           253:1

  --- Physical volumes ---  
  PV Name               /dev/sda2  
  PV UUID               uYfzd6-4jh1-YTP7-I3hx-WdSJ-4mTR-HZcdtq  
  PV Status             allocatable  
  Total PE / Free PE    2509 / 244

  PV Name               /dev/sdb1  
  PV UUID               Am341r-9WLV-NgWo-Un0Y-sVLQ-fyXM-0zyDix  
  PV Status             allocatable  
  Total PE / Free PE    258 / 258

As you can see my VolGroup contains /dev/sda2 and /dev/sdb1 partition. Let us try to remove /dev/sdb1

To remove a Physical Volume first we need to remove it from the Volume group using below syntax

Syntax:

# vgreduce name_of_vol_grp  path/of/pv  
# vgreduce VolGroup /dev/sdb1  
  Removed "/dev/sdb1" from volume group "VolGroup"

Once reduce from volgroup we can easily remove the PV using below command

# pvremove /dev/sdb1  
  Labels on physical volume "/dev/sdb1" successfully wiped

I hope I made my self clear. Please let me know your success and failures.

Related Articles
How to extend/resize LVM and Volume Group in Red Hat Linux 6
How to rename Logical Volume and Volume Group in Linux