Remove Logical Volume

From Linux User Group at WUR
Jump to: navigation, search

In this example, we will use a logical volume Ldata in volume group Vdata, mounted to mount point /data.

To remove a logical volume, first you must ensure that the machine will not attempt to mount a device that no longer exists on boot. On modern RHEL7 machines, this will freeze during the next boot and go into maintenance mode, which is a potential headache. So, to not have that happen, edit /etc/fstab and comment it out or remove the line entirely:

# vi /etc/fstab

#/dev/Vdata/Ldata      /data           ext4    defaults    0 0

Next, unmount it:

# umount /data

You should now see that a mount -a will not remount the device. You may want to remove the mount point folder as well:

# rmdir /data

Even though the LV is unmounted, the kernel will still keep the device operational, and will prompt you if you are certain you want to remove an active logical volume. To stop this prompt, you can deactivate the LV with:

# lvchange -an /dev/Vdata/Ldata

This also makes sure that the device truly is not in use. If you are having trouble deactivating the LV, then you may need to look at the untested section below, or restart the machine to clean up the device handles. If you don't do this, you'll see the following prompt after executing this command to remove the LV:

# lvremove Vdata/ackbar

Do you really want to remove active logical volume Vdata/Ldata? [y/n]: y
  Logical volume "Ldata" successfully removed

The logical volume is now removed.