歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

Linux LVM學習總結——刪除物理卷

本篇介紹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 BootStartEndBlocksId  System
/dev/sda1*  1 1310439183  Linux
/dev/sda2  14 10443 837789758e  Linux LVM
/dev/sda3  10444 15665 4194571583  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/sda2VG VolGroup00lvm2 [79.88 GB / 0 free]
  PV /dev/sda3VG VolGroup00lvm2 [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 NameVolGroup00
  PV Size79.90 GB / not usable 23.41 MB
  Allocatable  yes (but full)
  PE Size (KByte) 32768
  Total PE  2556
  Free PE0
  Allocated PE 2556
  PV UUIDYGtB2J-ZKJr-mV62-NluQ-2DGy-vuUT-cCc1lo

  --- Physical volume ---
  PV Name/dev/sda3
  VG NameVolGroup00
  PV Size40.00 GB / not usable 2.61 MB
  Allocatable  yes 
  PE Size (KByte) 32768
  Total PE  1280
  Free PE1280
  Allocated PE 0
  PV UUIDwsnv13-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 VGAttrLSize  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 ~]# 
clip_image001

 
[root@localhost ~]# pvscan
  PV /dev/sda2VG VolGroup00lvm2 [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
  PVVGFmt  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/sda2VG VolGroup00lvm2 [79.88 GB / 0 free]
  Total: 1 [79.88 GB] / in use: 1 [79.88 GB] / in no VG: 0 [0]

 


Copyright © Linux教程網 All Rights Reserved