Linux Administrator

How to Remove Volume Group and Physical Volume on LVM

Essentially, adding and removing LVM will dependably includes these three logic “layers” which are Physical Volumes (PV, Volume Group (VG) and Logical Volumes (LV).

In this article I will show you how to remove volume group and physical volume on LVM.

Check the Physical Volume (PV)

First of all check the physical volume using pvdisplay command.

# pvdisplay
  --- Physical volume ---
  PV Name               /dev/md127
  VG Name               vg1
  PV Size               1.09 TiB / not usable 2.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              285839
  Free PE               129679
  Allocated PE          156160
  PV UUID               LDzKxp-YlnO-d1N0-eY0f-oU4t-Dcln-2cCCfe

Check the Volume Group (VG)

Next, check the volume group using vgdisplay.

# vgdisplay
  --- Volume group ---
  VG Name               vg1
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               1.09 TiB
  PE Size               4.00 MiB
  Total PE              285839
  Alloc PE / Size       156160 / 610.00 GiB
  Free  PE / Size       129679 / 506.56 GiB
  VG UUID               WZUJLZ-jG8i-0pmZ-9YQv-fM5H-etoT-USv6xO

Check the Logical Volume (LV)

Now check the logical volume details using lvdisplay.

# lvdisplay
  --- Logical volume ---
  LV Path                /dev/vg1/var_lib_mysql
  LV Name                var_lib_mysql
  VG Name                vg1
  LV UUID                f80SUA-M1TC-0Jeu-DIW8-WfGh-bbeO-3a4X3f
  LV Write Access        read/write
  LV Creation host, time srv.localhost.com, 2017-11-29 22:50:54 -0600
  LV Status              available
  # open                 1
  LV Size                600.00 GiB
  Current LE             153600
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     4096
  Block device           253:0

As above you can see we have one physical volume /dev/md127 , volume group vg1 and one logical volume var_lib_mysql.

Now we want to remove vg1 and and physical volume /dev/md127.

Before removing PV and VG first of all we will remove lv then vg and finally remove PV.

Let’ follow the sequence to remove VG and LV.

Remove Logical Volume

As above you can see we have one lv called var_lib_mysql first of all we will remove lv. Unmount the file system using below command. In my case my lv is mounted on /var/lib/mysql.

# umount /var/lib/mysql/
# lvremove /dev/vg1/var_lib_mysql
lvremove -- do you really want to remove "/dev/vg1/var_lib_mysql"? [y/n]: y
lvremove -- doing automatic backup of volume group "vg1"
lvremove -- logical volume "/dev/vg1/var_lib_mysql" successfully removed

Remove Volume Group (VG)

After successfully removed LV now remove VG using vgremove command.

# vgremove vg1
  Volume group "vg1" successfully removed

Remove Physical Volume (PV)

Then finally remove the physical volume using pvremove command like below.

# pvremove /dev/md127
  Labels on physical volume "/dev/md127" successfully wiped
Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment