Are you using Logical Volume Management on your Linux desktop or server as the default partition layout? Sick of it and want out? Unsure how to remove them? We can help! Follow along with this post as we go over in depth how to disable and remove an LVM volume group from Linux!
WARNING: deleting an LVM volume group will also delete all data on the hard drive. Before continuing with this guide, make sure all critical data is backed up!
Before we begin
Logical Volume Management is an innovative system that allows Linux users to stripe partitions, create mirrors, create snapshots, and resize volumes on the fly. Many mainstream Linux distributions use this technology as their default disk system (CentOS, Fedora, and Sabayon).
If you’re trying to delete an LVM volume group, you must use a Linux live disk for this tutorial. Removing an LVM group on Linux will not work correctly without a live system. Download the latest version of Ubuntu Linux here and plug in a 4 GB USB flash drive (or blank DVD).
Note: If you do not like Ubuntu and want to use a different Linux OS for a live USB, feel free too. Ubuntu isn’t required, and all Linux OSes can interact with LVM volumes.
When the Ubuntu ISO image is done downloading, and plug in your 4 GB flash drive into the computer. Download the latest version of the Etcher USB burning tool. Open up the Linux file manager and click on the “Downloads” folder. Then, find the Etcher ZIP file, right-click on it and select the “Extract” button.
When the Zip archive is done extracting, it’s time to open up Etcher. Double-click on the AppImage file and the program should start.
Create Ubuntu live USB
The Etcher USB app is downloaded, open and ready to go. All that’s left is to create a working Ubuntu live USB. To do that, follow the steps below.
Step 1: Click the “Select Image” button and browse for the Ubuntu ISO file.
Step 2: Click the “Select Drive” button in Etcher and click on the USB flash drive you plan to use for Ubuntu.
Step 3: Click “Flash!” to start the burning process. When done, reboot your computer and configure it to boot Ubuntu from the USB drive.
Boot up Ubuntu
Now that the Ubuntu live disk is booted up click the “Try Ubuntu” option. Selecting this choice in the live disk will give you a complete live Linux environment to work with the LVM setup on your computer.
View LVM volumes
Looking to get rid of an LVM setup on your Linux PC? You’ll need to know a little bit of information about it first. Specifically, you must understand the LV partition labels, and how they are set up on the system.
The primary way of detecting all LV partition setups on a Linux PC is by using the lvdisplay command. It can scan all of the hard drives currently connected to your Linux machine and output relevant information about LV partitions.
Open up a terminal window in the Ubuntu live disk and gain root access with sudo -s. Then, use the lvdisplay tool.
sudo -s lvdisplay
The lvdisplay command is quite quick, and when run with the right permissions (root), will print out a detailed readout of your LVM partition layout. The readout has everything from the mount point information, to each partition’s size on the disk, etc.
Save the LVM Readout
While it’s very easy to re-run lvdisplay any time you want to view your LVM information, it’s a much smarter idea to pipe the output to a file. Why? It makes the output searchable, which will come in handy later. To save the LVM output to a file, combine it with >> in the terminal.
lvdisplay >> /home/ubuntu/Documents/lvm-scan-output.txt
At any time, take a look at your LVM scan report file by running it through the cat command in terminal.
Alternatively, open the file up with your favorite GUI Linux text editor. The output saves to ~/Documents.
Delete Linux LVM volumes
To delete an active LVM partition, open up a terminal and gain root with sudo -s. Then, run the cat command, in combination with the grep command to filter out the names of the LV partitions.
sudo -s cat /home/ubuntu/Documents/lvm-scan-output.txt | grep "VG Name"
Using the lvremove command, remove all volumes from the LVM setup on the drive.
Follow the prompts and press “Y” to remove each LVM partition from the volume group. When the lvremove command finishes, all data will be gone from the hard drive, and you’ll be left with an empty LVM2 partition. Feel free to delete the partition with DD.
Note: replace SDX with your hard drive’s label. Not sure what the label is? Run lsblk.
dd if=/dev/zero of=/dev/SDX bs=512 count=1
Your LVM partitions are gone from the hard drive. Keep in mind that deleting an LVM volume group also means the operating system that was using LVM is gone as well. Reboot your computer and begin the process of re-installing a fresh copy of your Linux operating system of choice.