ILWC What is loading Privacy Statement About ILWC
Registreer
112
Removing a VG and content
martijn
linux shell lvm
In a former article I described how to create a new filesystem (within a new volumegroup). Today, just for clarity, I describe how to get rid of the FS, LV, VG, PV's and devices.

What do the Logical Volumes look like at the moment?
[root@localhost ~]# lvs
  LV         VG         Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home       fedora     -wi-ao---- 100.00g                                                    
  root       fedora     -wi-ao----  50.00g                                                    
  swap       fedora     -wi-ao---- <15.74g                                                    
  tmp        fedora     -wi-ao----  50.00g                                                    
  usr        fedora     -wi-ao----  50.00g                                                    
  var        fedora     -wi-ao---- 100.00g                                                    
  u01        oraclevg   -wi-ao----  50.00g                                                    
  u02        oraclevg   -wi-ao---- 200.00g                                                    
  u03        oraclevg   -wi-ao----  25.00g                                                    
  u04        oraclevg   -wi-ao---- 300.00g                                                    
  practicelv practicevg -wi-ao----   6.00g-- The LV we want to loose                                                    
[root@localhost ~]#


And the Volume Groups?
[root@localhost ~]# vgs
  VG         #PV #LV #SN Attr   VSize     VFree   
  fedora       1   6   0 wz--n-   365.74g    4.00m
  oraclevg     1   4   0 wz--n- <1024.00g <449.00g
  practicevg   2   1   0 wz--n-     9.99g    3.99g-- The VG we want to loose
[root@localhost ~]#


Umount the FS and then also remove the mount point.
[root@localhost ~]# umount /practice 
[root@localhost ~]# rm -rf /practice/
[root@localhost ~]#


Let's remove the Volume Group.
[root@localhost ~]# vgremove practicevg -- vgremove will first remove LV's which are on the VG
Do you really want to remove volume group "practicevg" containing 1 logical volumes? [y/n]: y
Do you really want to remove active logical volume practicevg/practicelv? [y/n]: y -- See...
  Logical volume "practicelv" successfully removed -- LV's gone
  Volume group "practicevg" successfully removed -- VG gone
[root@localhost ~]#


Now see what the LV's look like:
[root@localhost ~]# lvs
  LV   VG       Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home fedora   -wi-ao---- 100.00g                                                    
  root fedora   -wi-ao----  50.00g                                                    
  swap fedora   -wi-ao---- <15.74g                                                    
  tmp  fedora   -wi-ao----  50.00g                                                    
  usr  fedora   -wi-ao----  50.00g                                                    
  var  fedora   -wi-ao---- 100.00g                                                    
  u01  oraclevg -wi-ao----  50.00g                                                    
  u02  oraclevg -wi-ao---- 200.00g                                                    
  u03  oraclevg -wi-ao----  25.00g                                                    
  u04  oraclevg -wi-ao---- 300.00g                                                    
[root@localhost ~]# 
As you can see the LV is gone

And what do the VG's look like
[root@localhost ~]# vgs
  VG       #PV #LV #SN Attr   VSize     VFree   
  fedora     1   6   0 wz--n-   365.74g    4.00m
  oraclevg   1   4   0 wz--n- <1024.00g <449.00g
[root@localhost ~]#
And also the VG is gone

Remove the PV's
[root@localhost ~]# pvremove /dev/sda[56]-- YOu can also do that one by one....this however is quicker 
  Labels on physical volume "/dev/sda5" successfully wiped.
  Labels on physical volume "/dev/sda6" successfully wiped.
[root@localhost ~]# 


And finally remove the devices
[root@localhost ~]# fdisk /dev/sda

Welcome to fdisk (util-linux 2.32).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/sda: 4.1 TiB, 4497636065280 bytes, 8784445440 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 7C88ED82-0394-48E0-B21A-DF06AD854875

Device          Start        End    Sectors   Size Type
/dev/sda1        2048       4095       2048     1M BIOS boot
/dev/sda2        4096    2101247    2097152     1G Linux filesystem
/dev/sda3     2101248  769126399  767025152 365.8G Linux LVM
/dev/sda4   769126400 2916610047 2147483648     1T Linux filesystem
/dev/sda5  2916610048 2927095807   10485760     5G Linux filesystem
/dev/sda6  2927095808 2937581567   10485760     5G Linux filesystem

Command (m for help): d-- delete a device
Partition number (1-6, default 6): -- Accept the default: the last added device (enter)

Partition 6 has been deleted.

Command (m for help): d
Partition number (1-5, default 5): -- Accept the default: the last added device (enter)

Partition 5 has been deleted.

Command (m for help): p -- See what's the disk layout now
Disk /dev/sda: 4.1 TiB, 4497636065280 bytes, 8784445440 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 7C88ED82-0394-48E0-B21A-DF06AD854875

Device         Start        End    Sectors   Size Type
/dev/sda1       2048       4095       2048     1M BIOS boot
/dev/sda2       4096    2101247    2097152     1G Linux filesystem
/dev/sda3    2101248  769126399  767025152 365.8G Linux LVM
/dev/sda4  769126400 2916610047 2147483648     1T Linux filesystem

Command (m for help): w
The partition table has been altered.
Syncing disks.

And...as you can see...the devices are gone.