Tuesday, 29 October 2019

Deleting Logical Volumes, Volume Groups and Physical Volumes

Click here to read how to create of the mirrored Logical Group.

Warning: ALL DATA ON LOGICAL VOLUMES, VOLUME GROUPS and PHYSICAL VOLUMES WILL BE LOST!

1.Unmount file system

[root@rifle ~]# umount /mirrored_data

2.Remove logical volume

[root@rifle ~]# umount /mirrored_data
[root@rifle ~]# lvremove /dev/vg_mirror/lv_mirror
Do you really want to remove active logical volume vg_mirror/lv_mirror? [y/n]: y
  Logical volume "lv_mirror" successfully removed

3.Remove physical volumes from the volume group and delete volume group

Check what we have:
[root@rifle ~]# vgs
  VG           #PV #LV #SN Attr   VSize  VFree
  centos_rifle   1   2   0 wz--n- <7.00g     0
  vg_mirror      2   0   0 wz--n-  3.98g  3.98g
  vg_mydata      2   1   0 wz--n- <1.54g 32.00m

Now for vg_mirror I have 2 PV and no one LV (remember step 2)

Remove /dev/sdd from vg_mirror:
[root@rifle ~]# vgreduce vg_mirror /dev/sdd
  Removed "/dev/sdd" from volume group "vg_mirror"

Note: the disk now can be used in another Volume Group.

Remove disk from the Logical Volume Manager:
[root@rifle ~]# pvremove /dev/sdd
  Labels on physical volume "/dev/sdd" successfully wiped.

Delete volume group vg_mirror:
[root@rifle ~]# vgremove vg_mirror
  Volume group "vg_mirror" successfully removed


[root@rifle ~]# pvs
  PV         VG           Fmt  Attr PSize   PFree
  /dev/sda2  centos_rifle lvm2 a--   <7.00g     0
  /dev/sdb   vg_mydata    lvm2 a--    1.03g     0
  /dev/sdc   vg_mydata    lvm2 a--  516.00m 32.00m
  /dev/sde                lvm2 ---    2.00g  2.00g

Now I have /dev/sde which does not belong to any Volume Group. Free it:

[root@rifle ~]# pvremove /dev/sde
  Labels on physical volume "/dev/sde" successfully wiped.

All Logical Volumes, Volume Groups and Physical Volumes now deleted

No comments: