Delete a volume group (VG) under CentOS)

Source: Internet
Author: User

Delete a volume group (VG) under CentOS)

In Linux, how does one delete a volume group (VG? The following describes how to delete a volume group (VG) for reference only. Thank you! In the following example, I want to delete the volume group VolGroup05.

Step 1: view the volume group (VG) information, as shown below

[root@getlnx01uat ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
 97G 36G 57G 39% /
/dev/mapper/VolGroup01-LogVol00
 79G 33G 43G 44% /u01
/dev/mapper/VolGroup02-LogVol00
 197G 182G 5.4G 98% /u02
/dev/mapper/VolGroup03-LogVol00
 197G 57G 130G 31% /u03
/dev/mapper/VolGroup04-LogVol00
 138G 118G 14G 90% /u04
/dev/mapper/VolGroup05-LogVol00
 178G 48G 121G 29% /u05
/dev/sda1 99M 23M 71M 25% /boot
tmpfs 2.0G 0 2.0G 0% /dev/shm
[root@getlnx01uat ~]# vgscan
 Reading all physical volumes. This may take a while...
 Found volume group "VolGroup05" using metadata type lvm2
 Found volume group "VolGroup04" using metadata type lvm2
 Found volume group "VolGroup03" using metadata type lvm2
 Found volume group "VolGroup02" using metadata type lvm2
 Found volume group "VolGroup01" using metadata type lvm2
 Found volume group "VolGroup00" using metadata type lvm2
[root@getlnx01uat ~]# 

View the PV and LV information contained in the volume group VolGroup05. As shown below

[root@getlnx01uat ~]# vgdisplay -v VolGroup05
 Using volume group(s) on command line
 Finding volume group "VolGroup05"
 --- Volume group ---
 VG Name VolGroup05
 System ID 
 Format lvm2
 Metadata Areas 1
 Metadata Sequence No 2
 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 179.97 GB
 PE Size 32.00 MB
 Total PE 5759
 Alloc PE / Size 5759 / 179.97 GB
 Free PE / Size 0 / 0 
 VG UUID UNFxZH-lAGM-vqF3-jtNK-yuKT-enUX-WwL7FQ
 
 --- Logical volume ---
 LV Name /dev/VolGroup05/LogVol00
 VG Name VolGroup05
 LV UUID kCTJnc-D3zQ-QiJp-TfPh-ivWs-WKyW-VvGTod
 LV Write Access read/write
 LV Status available
 # open 1
 LV Size 179.97 GB
 Current LE 5759
 Segments 1
 Allocation inherit
 Read ahead sectors auto
 - currently set to 256
 Block device 253:2
 
 --- Physical volumes ---
 PV Name /dev/sdg5 
 PV UUID VbSwjS-9ckQ-ZfWf-bl8g-oPWQ-TMBi-H6oMWv
 PV Status allocatable
 Total PE / Free PE 5759 / 0

2: unmount the logical Volume LV of the volume group

All logical volumes of the corresponding volume group VG must be detached. From the above information, we can see that the corresponding volume group VolGroup05 only has the logical Volume LV/dev/VolGroup05/LogVol00.

[root@getlnx01uat ~]# umount /dev/VolGroup05/LogVol00

You can also use the following command:

[root@getlnx01uat ~]# umount /u05

If the process is still using the file of the corresponding logical volume, the mount point must be forcibly uninstalled.

3: delete the logical Volume LV

[root@getlnx01uat ~]# lvremove /dev/VolGroup05/LogVol00
Do you really want to remove active logical volume LogVol00? [y/n]: y
 Logical volume "LogVol00" successfully removed
[root@getlnx01uat ~]# 

Verify that the LV is deleted

[Root @ getlnx01uat ~] # Lvdisplay | grep "dev/VolGroup05/LogVol00"

4: Delete the volume group VG

 
[root@getlnx01uat ~]# vgremove VolGroup05 
 Volume group "VolGroup05" successfully removed
[root@getlnx01uat ~]# 

If you delete the volume group VG securely, you must disable vg_name using vgchange-a n VolGroup05 before deleting it.

[root@getlnx01uat ~]# vgchange -a n VolGroup05
 0 logical volume(s) in volume group "VolGroup05" now active
[root@getlnx01uat ~]# vgremove VolGroup05 
 Volume group "VolGroup05" successfully removed

Verify whether the volume group (VG) is deleted

[root@getlnx01uat ~]# vgscan
 
Reading all physical volumes. This may take a while...
 
Found volume group "VolGroup04" using metadata type lvm2
 
Found volume group "VolGroup03" using metadata type lvm2
 
Found volume group "VolGroup02" using metadata type lvm2
 
Found volume group "VolGroup01" using metadata type lvm2
 
Found volume group "VolGroup00" using metadata type lvm2
 
[root@getlnx01uat ~]# 

5. delete a physical volume PV.

[root@getlnx01uat ~]# pvremove /dev/sdg5 
 Labels on physical volume "/dev/sdg5" successfully wiped
[root@getlnx01uat ~]# pvscan
 PV /dev/sde5 VG VolGroup04 lvm2 [139.97 GB / 0 free]
 PV /dev/sdd5 VG VolGroup03 lvm2 [199.97 GB / 0 free]
 PV /dev/sdc5 VG VolGroup02 lvm2 [199.97 GB / 0 free]
 PV /dev/sdb5 VG VolGroup01 lvm2 [79.97 GB / 0 free]
 PV /dev/sda2 VG VolGroup00 lvm2 [51.88 GB / 0 free]
 PV /dev/sdf5 VG VolGroup00 lvm2 [59.97 GB / 0 free]
 Total: 6 [731.72 GB] / in use: 6 [731.72 GB] / in no VG: 0 [0 ]

6. edit/etc/fstab and delete the mount information.

If this step is not processed, the system will encounter the following error during the restart process:

In Repair filesystem, files are protected and cannot be modified. Editing vi/etc/fstab cannot be saved.

You can run the following command to modify the System File Permission to read/write (rw), edit/etc/fstab, delete the mount point information, and restart the server to solve the problem.

mount -o remount, rw / 

References:

Http://wenku.baidu.com/view/459150d85022aaea998f0f20.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.