In this post I want to show how we can remove LVM Volume Groups (VGs) and Logical Volumes (LVs) in Linux.




Remove Logical Volumes

In order to remove a volume group, we first need to remove its associated logical volumes. If the logical volume is still mounted, we first need to unmount the volume before we can remove the logical volume.

Below I want to remove the logical volume named data3 which is assigned to the volume group named data_vg. So first I need to unmount it.

# umount /data3


Now I can remove the logical volume by executing the lvremove command.

# lvremove /dev/<volume group>/<logical volume>
# lvremove /dev/data_vg/data3



Remove Volume Groups

As mentioned before we can remove a volume group, we first need to remove its associated logical volumes.

To continue with the example and volume group named data_vg above, I will first need to remove both remaining and associated logical volumes named data1 and data2 from the volume group in order to remove it.

When the volume group now doesn’t contain any logical volumes, we can remove it by using the vgremove command.

# vgremove <volume group>
# vgremove data_vg



Physical Volumes

Creating a new volume group requires to add disks (block devices) to the volume group as storage. Disks in LVM terminology are so called physical volumes (PVs).

About how to create new volume groups and logical volumes you can read my following post:



Removing Physical Volumes from a Volume Group

In order to assign a disk (block device) to a volume group, we first need to initialize the disks as LVM physical volumes which will add some LVM metadata to the disks.

When we now want to remove such a physical volume (disk) from LVM to clear the previous initialization and LVM metadata, the disk cannot be part of a volume group and we first need to remove it from the volume group if still assigned to.

We can therefore use the vgreduce command as shown below.

# vgreduce <volume group> /dev/sdX
# vgreduce data_vg /dev/sdd




Removing Physical Volumes

Now as the physical volume /dev/sdd is not used and assigned to a volume group, we can finally remove the LVM label from by using the pvremove command. We just remove the LVM label in case we don’t require the device for LVM anymore.

# pvremove /dev/sdd





Links

Removing Physical Volumes from a Volume Group
https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/6/html/logical_volume_manager_administration/VG_remove_PV

Removing Physical Volumes
https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/6/html/logical_volume_manager_administration/pv_remove

Removing Logical Volumes
https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/6/html/logical_volume_manager_administration/lv_remove

Removing Volume Groups
https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/6/html/logical_volume_manager_administration/vg_remove