在Linux系統中,如何刪除一個卷組(VG)呢? 下面我總結了一下如何刪除卷組(VG)的具體步驟,僅供參考,若有不足,敬請指出。謝謝!在下面的例子中,我想刪除卷組VolGroup05。 html
步驟1: 查看卷組(VG)相關信息,以下所示安全
[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 ~]#
查看卷組VolGroup05包含的PV、LV信息。以下所示服務器
[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:卸載卷組的邏輯卷LV app
要卸載對應卷組VG的全部邏輯卷LV。從上面的信息能夠看出對應的卷組VolGroup05只有/dev/VolGroup05/LogVol00這個邏輯卷LVspa
[root@getlnx01uat ~]# umount /dev/VolGroup05/LogVol00
使用下面命令亦可code
[root@getlnx01uat ~]# umount /u05
若是還用進程在使用對應邏輯卷的文件,就必須強制卸載掛接點。 orm
3:刪除邏輯卷LVhtm
[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 ~]#
驗證LV是否刪除 blog
[root@getlnx01uat ~]# lvdisplay | grep "dev/VolGroup05/LogVol00" 進程
4:刪除卷組VG
[root@getlnx01uat ~]# vgremove VolGroup05
Volume group "VolGroup05" successfully removed
[root@getlnx01uat ~]#
若是採用安全的方式刪除卷組VG,則必須使用vgchange -a n VolGroup05關閉了vg_name,而後才能夠刪除它。
[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
驗證卷組(VG)是否刪除
[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:刪除物理卷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:編輯/etc/fstab,刪除對應掛載信息
若是這一步不處理,則系統重啓過程當中會遇到以下錯誤信息:
在修復模式下(Repair filesystem),文件是被保護的,不能被修改 。編輯vi /etc/fstab後並不能保存。
能夠運行下面命令,把系統文件權限修改成可讀寫(rw),而後編輯/etc/fstab,刪除掛載點信息,重啓服務器便可解決問題。
mount -o remount, rw /
參考資料: