How to Remove Logical Volume in Linux

Sometimes you may need to remove an unused logical volume in Linux. This can be done using the ‘lvremove’ command as shown below.

But make sure there is no data on the logical volume. If so, make sure to take a backup before proceeding with LV removal.

To demonstrate this, let’s remove the logical volume “lv001” from the volume group “vg01” and the LV is currently mounted on '/lvmtest'.

If you are a beginner in LVM, I recommend reading the LVM series article listed below to get familiar with it.

Let’s begin our use-case:

Use the df command to check if your LV (Logical Volume) contains any data. If yes, then backup the data.

Backup can be done in many ways, but you can perform it based on your requirements and the resources available in your environment.

# 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

Firstly, 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 are no logical volumes associated with the volume group(VG) and if the VG is no longer required, then remove that as well.

Disable the “vg01” volume group as shown below:

# 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.

Wrapping Up

In this guide, we’ve shown you how to Delete/Remove LV (Logical Volume) in Linux and also to remove the VG’s (Volume Groups) if they are no longer required.

If you found this article helpful, please do share with your friends and spread the knowledge. Please feel free to comment below if you have any queries/concerns. We will get back to you as soon as we can. Happy learning!

About Magesh Maruthamuthu

Love to play with all Linux distribution

View all posts by Magesh Maruthamuthu

Leave a Reply

Your email address will not be published. Required fields are marked *