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 Create a Linux Swap File
Viewed 3612 times since Fri, Jun 8, 2018
Linux - How to get Memory information
Viewed 2783 times since Fri, Jun 8, 2018
LVM: Reduce SWAP size by shrinking existing Logical Volume
Viewed 7605 times since Sat, Jun 2, 2018
Method 2 – Use shell scripts How to install yum cron on a CentOS/RHEL 6.x/7.x
Viewed 5274 times since Tue, Dec 4, 2018
CONFIGURE OCFS2
Viewed 9706 times since Sat, Jun 2, 2018
Applescript: Run or Call a Shell Script
Viewed 5476 times since Tue, Aug 6, 2019
Improve security with polyinstantiation
Viewed 14977 times since Fri, May 15, 2020
RHEL: Displaying system info (firmware, serial numbers... )
Viewed 13771 times since Sun, May 27, 2018
LVM: Create a new Logical Volume / Filesystem
Viewed 3009 times since Sat, Jun 2, 2018
How To Add Swap Space on Ubuntu 16.04
Viewed 3359 times since Fri, Jun 8, 2018