本篇介绍LVM管理中的命令vgreduce, pvremove。其实前面几篇中以及有所涉及。
vgreduce:通过删除LVM卷组中的物理卷来减少卷组容量。注意:不能删除LVM卷组中剩余的最后一个物理卷
pvremove: 用于删除一个存在的物理卷。使用pvremove指令删除物理卷时,它将LVM分区上的物理卷信息删除,使其不再被视为一个物理卷。
在删除物理卷PV之前,必须将服务器的分区信息、卷组信息、物理卷信息、逻辑卷信息都掌握清楚,避免出现失误或误操作。
[root@localhost ~]# fdisk -l
Disk /dev/sda: 128.8 GB, 128849018880 bytes
255 heads, 63 sectors/track, 15665 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 linux
/dev/sda2 14 10443 83778975 8e Linux LVM
/dev/sda3 10444 15665 41945715 83 Linux
[root@localhost ~]# vgscan
Reading all physical volumes. This may take a while...
Found volume group "VolGroup00" using metadata type lvm2
[root@localhost ~]# pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [79.88 GB / 0 free]
PV /dev/sda3 VG VolGroup00 lvm2 [40.00 GB / 40.00 GB free]
Total: 2 [119.88 GB] / in use: 2 [119.88 GB] / in no VG: 0 [0 ]
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 79.90 GB / not usable 23.41 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 2556
Free PE 0
Allocated PE 2556
PV UUID YGtB2J-ZKJr-mV62-NluQ-2DGy-vuUT-cCc1lo
--- Physical volume ---
PV Name /dev/sda3
VG Name VolGroup00
PV Size 40.00 GB / not usable 2.61 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 1280
Free PE 1280
Allocated PE 0
PV UUID wsnv13-7j1H-SH8q-hl6k-HpNc-x4WU-gM7LzW
[root@localhost ~]# lvscan
ACTIVE '/dev/VolGroup00/LogVol00' [77.91 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [1.97 GB] inherit
[root@localhost ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 77.91G
LogVol01 VolGroup00 -wi-ao 1.97G
vgreduce参数:
-a:如果命令行中没有指定要删除的物理卷,则删除所有的空物理卷;
--removemissing:删除卷组中丢失的物理卷,使卷组恢复正常状态。
[root@localhost ~]# vgreduce VolGroup00 /dev/sda3
Removed "/dev/sda3" from volume group "VolGroup00"
[root@localhost ~]#
[root@localhost ~]# pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [79.88 GB / 0 free]
PV /dev/sda3 lvm2 [40.00 GB]
Total: 2 [119.88 GB] / in use: 1 [79.88 GB] / in no VG: 1 [40.00 GB]
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 VolGroup00 lvm2 a- 79.88G 0
/dev/sda3 lvm2 a- 40.00G 40.00G
[root@localhost ~]# pvremove /dev/sda3
Labels on physical volume "/dev/sda3" successfully wiped
[root@localhost ~]# pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [79.88 GB / 0 free]
Total: 1 [79.88 GB] / in use: 1 [79.88 GB] / in no VG: 0 [0 ]
新闻热点
疑难解答