LVM: Remove an existing Volume Group

LVM: Remove an existing Volume Group

# Tested on RHEL 5, 6 & 7

VG=testvg

vgdisplay -v $VG
    Using volume group(s) on command line.
  --- Volume group ---
  VG Name               testvg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  60
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               508.00 MiB
  PE Size               4.00 MiB
  Total PE              127
  Alloc PE / Size       64 / 256.00 MiB
  Free  PE / Size       63 / 252.00 MiB
  VG UUID               MgAY7y-AVfr-FOFP-5RVO-jHA8-Obel-UK2M9k

  --- Logical volume ---
  LV Path                /dev/testvg/testlv
  LV Name                testlv
  VG Name                testvg
  LV UUID                uwa2U4-C2J4-pjPK-CYT4-jvMO-qgj7-gabWBN
  LV Write Access        read/write
  LV Creation host, time ciento3.localdomain, 2016-02-25 14:19:41 +0100
  LV Status              available
  # open                 1
  LV Size                256.00 MiB
  Current LE             64
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:8

  --- Physical volumes ---
  PV Name               /dev/sde1
  PV UUID               jgt69o-8OoG-3WNo-9ens-GBD2-vrqu-yRHDUB
  PV Status             allocatable
  Total PE / Free PE    127 / 63



# Before removing Volume Group remember that data (if any) won't be recoverable. Take into
# account any filesystem/logical volume belonging to volume group. Such is my case; I will
# destroy volume group and all related objects
 
vgremove $VG
   Do you really want to remove volume group "testvg" containing 1 logical volumes? [y/n]: y
     Can't remove open logical volume "testlv"

df -h
   [...]
   /dev/mapper/testvg-testlv
                         248M   11M  226M   5% /testmntpt

umount /testmntpt

rmdir
/testmntpt

vgremove $VG
   Do you really want to remove volume group "testvg" containing 1 logical volumes? [y/n]: y
   Do you really want to remove active logical volume testlv? [y/n]: y
     Logical volume "testlv" successfully removed
     Volume group "testvg" successfully removed
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 Find Largest Top 10 Files and Directories On Linux / UNIX / BSD find
Viewed 3739 times since Mon, Oct 29, 2018
O’Reilly’s CD bookshelf
Viewed 12347 times since Wed, Jun 27, 2018
RHEL: Rebuilding the initial ramdisk image
Viewed 7188 times since Sat, Jun 2, 2018
How to convert RAW image to VDI and otherwise
Viewed 14843 times since Wed, Oct 3, 2018
Check Detailed CPU Information In Linux With CoreFreq [Advanced]
Viewed 2263 times since Thu, Apr 18, 2019
CentOS / RHEL : Configure yum automatic updates with yum-cron service
Viewed 3454 times since Fri, Oct 26, 2018
RHCS6: Show/Add GFS2/GFS journals
Viewed 12636 times since Sun, Jun 3, 2018
Linux RAID Mdadm Cheat Sheet
Viewed 5323 times since Fri, May 15, 2020
Logrotate Example for Custom Logs
Viewed 2501 times since Sun, Jan 12, 2020
Secure Remote Logging to Central Log Server Using RSYSLOG on CentOS 6 / CentOS 7 and stunnel
Viewed 3579 times since Sun, Dec 6, 2020