Table of Contents
Introduction to lvremove command
lvremove command removes logical volumes in the volume group. lvremove asks for confirmation before removing any active logical volume. The removal of logical volume will also remove its dependent snapshots.
Are you new to LVM and still learning how it works?
We have written detailed articles covering different areas of managing logical volumes, which you can follow using the below links:
Manage Logical Volume in Linux - One STOP Solution
Understand LVM Architecture
Create LVM during installation RHEL/CentOS 7/8
How to use LVM Snapshot for Backup and Restore
Create Mirrored Logical Volume
Create Striped Logical Volume
Syntax for lvremove command
The syntax for
lvremove command is as follows:
$ sudo lvremove option LV
Different examples to use lvremove command
1. Remove the logical volume in the volume group
You can use
lvremove command to remove the specified logical volume in the volume group.
For example, the following command removes the logical volume
lvol1 in the volume group
$ sudo lvremove vol_grp/lvol1
It asks for confirmation before removing any active logical volume.
umountcommand to unmount the mount point.
2. Remove the logical volume without confirmation
--force option of lvremove command removes active logical volumes without asking for confirmation.
$ sudo lvremove -f vol_grp/lvol2
$ sudo lvremove --force vol_grp/lvol2
3. Remove all logical volumes in the volume group
If you specify only the volume group name as an argument to
lvremove command, it removes all logical volumes in that volume group.
This command removes all logical volumes in the volume group
$ sudo lvremove vol_grp
4. Remove logical volume that contains a filesystem in use
Sometimes, when removing a logical volume, you might get the error saying "filesystem in use".
golinux@ubuntu-PC:~$ sudo lvremove vol_grp/lvol6 Logical volume vol_grp/lvol6 contains a filesystem in use.
In that case, check if the logical volume is mounted in the system.
golinux@ubuntu-PC:~$ sudo mount | grep lvol6 /dev/mapper/vol_grp-lvol6 on /golinux type ext3 (rw,relatime)
If it is mounted, you have to unmount the mount point.
golinux@ubuntu-PC:~$ sudo umount /golinux
Then you can remove the logical volume using the
golinux@ubuntu-PC:~$ sudo lvremove vol_grp/lvol6 Do you really want to remove and DISCARD active logical volume vol_grp/lvol6? [y/n]: y Logical volume "lvol6" successfully removed
This article teaches you to use lvremove command for removing logical volumes in the Linux system. It is one of the useful commands to manage logical volumes in the volume group. If you have any queries, please let us know in the comment section below.