CentOS下删除一个卷组(VG)
在Linux系统中,如何删除一个卷组(VG)呢? 下面我总结了一下如何删除卷组(VG)的具体步骤,仅供参考,如有不足,敬请指出。谢谢!在下面的例子中,我想删除卷组VolGroup05。
步骤1: 查看卷组(VG)相关信息,如下所示[root@getlnx01uat ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup00-LogVol0097G 36G 57G 39% //dev/mapper/VolGroup01-LogVol0079G 33G 43G 44% /u01/dev/mapper/VolGroup02-LogVol00197G 182G 5.4G 98% /u02/dev/mapper/VolGroup03-LogVol00197G 57G 130G 31% /u03/dev/mapper/VolGroup04-LogVol00138G 118G 14G 90% /u04/dev/mapper/VolGroup05-LogVol00178G 48G 121G 29% /u05/dev/sda1 99M 23M 71M 25% /boottmpfs 2.0G 0 2.0G 0% /dev/shm[root@getlnx01uat ~]# vgscanReading all physical volumes. This may take a while...Found volume group "VolGroup05" using metadata type lvm2Found volume group "VolGroup04" using metadata type lvm2Found volume group "VolGroup03" using metadata type lvm2Found volume group "VolGroup02" using metadata type lvm2Found volume group "VolGroup01" using metadata type lvm2Found volume group "VolGroup00" using metadata type lvm2[root@getlnx01uat ~]#
查看卷组VolGroup05包含的PV、LV信息。如下所示[root@getlnx01uat ~]# vgdisplay -v VolGroup05Using volume group(s) on command lineFinding volume group "VolGroup05"--- Volume group ---VG Name VolGroup05System IDFormat lvm2Metadata Areas 1Metadata Sequence No 2VG Access read/writeVG Status resizableMAX LV 0Cur LV 1Open LV 1Max PV 0Cur PV 1Act PV 1VG Size 179.97 GBPE Size 32.00 MBTotal PE 5759Alloc PE / Size 5759 / 179.97 GBFree PE / Size 0 / 0VG UUID UNFxZH-lAGM-vqF3-jtNK-yuKT-enUX-WwL7FQ--- Logical volume ---LV Name /dev/VolGroup05/LogVol00VG Name VolGroup05LV UUID kCTJnc-D3zQ-QiJp-TfPh-ivWs-WKyW-VvGTodLV Write Access read/writeLV Status available# open 1LV Size 179.97 GBCurrent LE 5759Segments 1Allocation inheritRead ahead sectors auto- currently set to 256Block device 253:2--- Physical volumes ---PV Name /dev/sdg5PV UUID VbSwjS-9ckQ-ZfWf-bl8g-oPWQ-TMBi-H6oMWvPV Status allocatableTotal PE / Free PE 5759 / 0
2:卸载卷组的逻辑卷LV
要卸载对应卷组VG的所有逻辑卷LV。从上面的信息可以看出对应的卷组VolGroup05只有/dev/VolGroup05/LogVol00这个逻辑卷LV[root@getlnx01uat ~]# umount /dev/VolGroup05/LogVol00
使用下面命令亦可[root@getlnx01uat ~]# umount /u05
如果还用进程在使用对应逻辑卷的文件,就必须强制卸载挂接点。
3:删除逻辑卷LV[root@getlnx01uat ~]# lvremove /dev/VolGroup05/LogVol00Do you really want to remove active logical volume LogVol00? [y/n]: yLogical volume "LogVol00" successfully removed[root@getlnx01uat ~]#
验证LV是否删除
[root@getlnx01uat ~]# lvdisplay | grep "dev/VolGroup05/LogVol00"
4:删除卷组VG[root@getlnx01uat ~]# vgremove VolGroup05Volume group "VolGroup05" successfully removed[root@getlnx01uat ~]#
如果采用安全的方式删除卷组VG,则必须使用vgchange -a n VolGroup05关闭了vg_name,然后才可以删除它。[root@getlnx01uat ~]# vgchange -a n VolGroup050 logical volume(s) in volume group "VolGroup05" now active[root@getlnx01uat ~]# vgremove VolGroup05Volume group "VolGroup05" successfully removed
验证卷组(VG)是否删除[root@getlnx01uat ~]# vgscanReading all physical volumes. This may take a while...Found volume group "VolGroup04" using metadata type lvm2Found volume group "VolGroup03" using metadata type lvm2Found volume group "VolGroup02" using metadata type lvm2Found volume group "VolGroup01" using metadata type lvm2Found volume group "VolGroup00" using metadata type lvm2[root@getlnx01uat ~]#
5:删除物理卷PV[root@getlnx01uat ~]# pvremove /dev/sdg5Labels on physical volume "/dev/sdg5" successfully wiped[root@getlnx01uat ~]# pvscanPV /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 /
参考资料:
http://wenku.baidu.com/view/459150d85022aaea998f0f20.html
http://www.dengb.com/Linuxjc/1021249.htmlwww.dengb.comtruehttp://www.dengb.com/Linuxjc/1021249.htmlTechArticleCentOS下删除一个卷组(VG) 在Linux系统中,如何删除一个卷组(VG)呢? 下面我总结了一下如何删除卷组(VG)的具体步骤,仅供参考,如有...