If the LVM volume (logical volume) is no longer required to use by LVM on the system.
You can remove/delete it with the lvremove command using the following steps.
But make sure the LVM volume does not contain any data.
If yes, please make sure to back up that data before proceeding with LVM removal.
To demonstrate this, we will remove “lv001” from the volume group “vg01”. The LV is mounted on the mount point /lvmtest.
- Part-1: How to Create/Configure LVM (Logical Volume Management) in Linux
- Part-2: How to Extend/Increase LVM’s (Logical Volume Resize) in Linux
- Part-3: How to Reduce/Shrink LVM’s (Logical Volume Resize) in Linux
- Part-4: How to Remove Physical Volume from a Volume Group in LVM
Use the df command to check if the LVM volume is containing any data. If yes, then backup the data.
# df -h /lvmtest Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg01-lv001 15360M 34M 15326M 4% /lvmtest
Alternatively, you can verify this using the lvs or lvdisplay command as follows.
# lvs or # lvdisplay /dev/mapper/vg01-lv001
Firs delete the entry of the mount point from the /etc/fstab file.
# vi /etc/fstab … /dev/mapper/vg01-lv001 /lvmtest ext4 defaults 0 0 …
Unmount the mount point using the umount command.
# umount /lvmtest
Disable the “lv001” logical volume.
# lvchange -an /dev/vg01/lv001 or # lvchange -an /dev/mapper/vg01-lv001
Finally delete the “lv001” logical volume.
# lvremove /dev/vg01/lv001 or # lvremove /dev/mapper/vg01-lv001 Do you really want to remove active logical volume "lv001"? [y/n]: y Logical volume "lv001" successfully removed
If there is no logical volumes associated with volume group and no more required, then remove that as well.
Disable the “vg01” volume group.
# vgchange -an vg01
Delete the “vg01” volume group.
# vgremove vg01 Volume group "officevg" successfully removed
Delete physical volumes used for volume group “vg01”.
# pvremove /dev/sdb /dev/sdc Labels on physical volume "/dev/sdb" successfully wiped. Labels on physical volume "/dev/sdc" successfully wiped.