LVM: Remove a Filesystem / Logical Volume

LVM: Remove a Filesystem / Logical Volume

# Tested on RHEL 5, 6 & 7

MNTPT=/testmntpt

VG=`mount | awk '{if ( $3 == "'$MNTPT'" ) print$1}' | cut -f4 -d'/' | cut -f1 -d '-'`
LV=`mount | awk '{if ( $3 == "'$MNTPT'" ) print$1}' | cut -f4 -d'/' | cut -f2 -d '-'`


umount $MNTPT

lvremove $VG/$LV
   Do you really want to remove active logical volume testlv? [y/n]: y
     Logical volume "testlv" successfully removed

vi /etc/fstab        # Remove corresponding line
0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
How to use yum command on CentOS/RHEL
Viewed 11181 times since Wed, Oct 17, 2018
How to configure an SSH proxy server with Squid
Viewed 3278 times since Sun, Dec 6, 2020
Managing temporary files with systemd-tmpfiles on Red Hat Enterprise Linux 7
Viewed 9798 times since Sun, Nov 22, 2020
Top 20 OpenSSH Server Best Security Practices - good article
Viewed 10834 times since Mon, Oct 1, 2018
YUM CRON RHEL7: Configure automatic updates.
Viewed 2090 times since Fri, Oct 26, 2018
O’Reilly’s CD bookshelf
Viewed 13152 times since Wed, Jun 27, 2018
Method 2 – Use shell scripts How to install yum cron on a CentOS/RHEL 6.x/7.x
Viewed 4289 times since Tue, Dec 4, 2018
Open SSL Creating Certificate Signing Request — CSR Generation
Viewed 2021 times since Mon, Feb 18, 2019
6 easy steps to setup offline two factor authentication in Linux
Viewed 13506 times since Mon, Apr 6, 2020
Using etckeeper with git
Viewed 7042 times since Sun, Jun 3, 2018