2024年11月Linux删除LVM中PV物理卷的技巧(2)

发布时间:

  ⑴Physical extent to :

  ⑵--- Physical volume ---

  ⑶PV Name /dev/sda

  ⑷VG Name liuhg_disk

  ⑸PV Size . MiB / not usable . MiB

  ⑹Allocatable yes (but full

  ⑺PE Size . MiB

  ⑻Total PE

  ⑼Free PE

  ⑽Allocated PE

  ⑾PV UUID avJQaA-oMKt-NEoJ-ojBK-Csc-dca-mhUe

  ⑿--- Physical Segments ---

  ⒀Physical extent to :

  ⒁Logical volume /dev/liuhg_disk/home

  ⒂Logical extents to

  ⒃--- Physical volume ---

  ⒄PV Name /dev/sda

  ⒅VG Name liuhg_disk

  ⒆PV Size . MiB / not usable . MiB

  ⒇Allocatable yes (but full

  ⒈PE Size . MiB

  ⒉Total PE

  ⒊Free PE

  ⒋Allocated PE

  ⒌PV UUID JlMIAF-An-MHA-ZLXf-dnS-pfZr-YeQsKT

  ⒍--- Physical Segments ---

  ⒎Physical extent to :

  ⒏Logical volume /dev/liuhg_disk/home

  ⒐Logical extents to

  ⒑--- Physical volume ---

  ⒒PV Name /dev/sda

  ⒓VG Name liuhg_disk

  ⒔PV Size . MiB / not usable . MiB

  ⒕Allocatable yes (but full

  ⒖PE Size . MiB

  ⒗Total PE

  ⒘Free PE

  ⒙Allocated PE

  ⒚PV UUID xnHJNA-tDVx-dryX-KMx-gY-sptI-iUOcU

  ⒛--- Physical Segments ---

  ①Physical extent to :

  ②Logical volume /dev/liuhg_disk/home

  ③Logical extents to

  ④将sda设置为离线状态:

  ⑤pvchange -xn /dev/sda

  ⑥使用pvdisplay -m

  ⑦……

  ⑧--- Physical volume ---

  ⑨PV Name /dev/sda

  ⑩VG Name liuhg_disk

  ⅠPV Size . MiB / not usable . MiB

  ⅡAllocatable NO 《-----表示已经关闭了该PV

  ⅢPE Size . MiB

  ⅣTotal PE

  ⅤFree PE

  ⅥAllocated PE

  ⅦPV UUID Sane-nlFG-uSNR-NP-Yxa-cXRb-rEmK

  Ⅷ……

  Ⅸ将sda的数据移走:

  Ⅹpvmove -i /dev/sda

  ㈠-i 是每秒钟报告一次数据迁移的进度。

  ㈡[rootliuhg /]# pvmove -i /dev/sda

  ㈢/dev/sda: Moved: .%

  ㈣/dev/sda: Moved: .%

  ㈤/dev/sda: Moved: .%

  ㈥重新用pvdisplay -m

  ㈦……

  ㈧--- Physical volume ---

  ㈨PV Name /dev/sda

  ㈩VG Name liuhg_disk

  PV Size . MiB / not usable . MiB

  Allocatable NO

  PE Size . MiB

  Total PE

  Free PE 《----显示完全空闲和Total PE数一致

  Allocated PE

  PV UUID Sane-nlFG-uSNR-NP-Yxa-cXRb-rEmK

  ……

  从卷组里把sda删除:

  [rootliuhg /]# vgreduce liuhg_disk /dev/sda

  Removed “/dev/sda” from volume group “liuhg_disk”

  pvdisplay -m再看看吧:

  --- NEW Physical volume --- 《-----还告诉你这是一个新的PV ^_^

  PV Name /dev/sda

  VG Name 《-----空了

  PV Size . MiB

  Allocatable NO

  PE Size

  Total PE

  Free PE

  Allocated PE

  PV UUID Sane-nlFG-uSNR-NP-Yxa-cXRb-rEmK

  到此vgdisplay -v能看到已经没有了/dev/sda了。重新挂载/home

  [rootliuhg /]# mount /dev/liuhg_disk/home /home

  [rootliuhg /]# df -h

  Filesystem Size Used Avail Use% Mounted on

  /dev/sda .G M .G % /

  tmpfs M M % /dev/shm

  /dev/mapper/liuhg_disk-home

  .G .G M % /home

  进去看看数据,一个都没丢。

  上面就是Linux删除LVM中的PV物理卷(硬盘或分区的介绍了,如果你在系统中安装了LCM,而又不知道如何删除其中的PV物理卷的话,可以试试文中介绍的方法。