Delete Volume Groups
Overview
Lately I have run into the issue of needing to delete an LVM (Linux Volume Manager) partition after a disk was used as an OS drive for Ubuntu or some other operating system which uses Linux Volumes. I have had cases where an OS installation failed because the volume groups were not first deleted. This was confusing to me as I had not had a lot of experience with LVM partitions.
Even in the CLI, typical commands like wipefs
will not work, even if the disk is umounted.
This is because the volume groups are still in use despite the LVM partitions not being mounted. The solution is to delete the volume groups first, and then you can wipe the disk. There are some other ways to do this, but this is what has worked for me when I just want to wipe the disk and start over.
Delete Volume Groups
First, list the volume groups on your system using the following command:
sudo vgdisplay
Make sure to double check the volume groups before proceeding. Deleting a volume group will make it difficult if not impossible to get any data on that volume group. Make sure to back up any important data before proceeding.
Next, delete the volume group using the following command:
sudo vgremove <volume-group-name>
Replace <volume-group-name>
with the name of the volume group you want to delete. In my case, I will be deleting pve
.
The volume groups will now be removed
Wipe Disk
Now that the volume groups are removed, you can wipe the disk using the following command:
sudo wipefs -a /dev/sdX
Replace /dev/sdX
with the name of the disk you want to wipe. In my case, it is /dev/sdb
.
Conclusion
You have successfully deleted the volume groups and wiped the disk. You can now use the disk for a new installation or any other purpose.