Remove a LVM

by Mike on December 9, 2008

in Hardware

If you want to remove a logical volume you will need to follow an exact sequence.  Remove the logical volume, then remove the volume group and finally remove the physical volume.  The logical volume will need to be unmounted for the process to take place.

Warning: If you do not follow this process exactly you will not be able to clean it up even if you delete the partitions with fdisk because it will leave traces of the physical volumes on the machine.  It really makes it a mess if you do not clean up correctly…so …be careful to follow this procedure.

This assuming that your volume group is named vg2 and the logical volume that you created is called data.  It also assumes that the physical volume that is used for vg2 is /dev/hd5.  You will certainly need to modify the settings for your situation.

lvremove /dev/vg2/data

vgremove vg2

pvremove /dev/hdc5

Here is the actual sequence.
# lvremove /dev/vg2/data
Can’t remove open logical volume “data”
In this situation you will need to unmount the logical volume you want to remove.

# umount /data
# lvremove /dev/vg2/data
Do you really want to remove active logical volume “data”? [y/n]: y
Logical volume “data” successfully removed
# vgremove data
Volume group “data” not found
# vgremove vg2
Volume group “vg2″ successfully removed
# pvremove /dev/hdc5
Labels on physical volume “/dev/hdc5″ successfully wiped

Previous post:

Next post: