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

Linux刪除LVM中PV物理卷的技巧

  LVM通常用於裝備大量磁盤的系統,具有良好的可伸縮性,可對卷組、邏輯卷的大小進行調整,今天小編要給大家介紹的是Linux如何刪除LVM中的PV物理卷(硬盤或分區),一起來學習下吧。

 Linux刪除LVM中PV物理卷的技巧

  一、由於硬盤或者分區的操作方式其實都一樣,所以我這裡就以分區為例。

  二、/home分區2.6G,由如下pv組成:

  /dev/sda5 100M

  /dev/sda6 200M

  /dev/sda7 300M

  /dev/sda8 400M

  /dev/sda9 500M

  /dev/sda10 600M

  /dev/sda11 500M

  很碎對吧?^_^因為測試。

  三、隨機寫了一堆文件進去,用量達到了2G,空閒500M

  四、准備將sda6這個200M的PV卸掉(卸掉的容量必須小於空閒容量)

  好了開始具體操作了。

  卸載分區(縮小操作必須卸載才能進行):

  umount /home

  縮小分區:

  e2fsck -f /dev/liuhg_disk/home

  resize2fs /dev/liuhg_disk/home 2200M

  首先將分區縮小到2200M這是為了給sda6騰出空間,sda6為200M,而我騰出了400M,因此應該是足夠的。

  縮小邏輯卷:

  lvreduce -L 2200M /dev/liuhg_disk/home

  分區縮小了用到的邏輯卷也要隨著縮小,並查看PV使用的狀態:

  pvdisplay -m

  顯示如下:

  --- Physical volume ---

  PV Name /dev/sda5

  VG Name liuhg_disk

  PV Size 103.26 MiB / not usable 3.26 MiB

  Allocatable yes (but full)

  PE Size 4.00 MiB

  Total PE 25

  Free PE 0

  Allocated PE 25

  PV UUID 5lnx52-b4jc-OOfZ-f2QA-ttdQ-DZeD-Ce3rb3

  --- Physical Segments ---

  Physical extent 0 to 24:

  Logical volume /dev/liuhg_disk/home

  Logical extents 0 to 24

  --- Physical volume ---

  PV Name /dev/sda6

  VG Name liuhg_disk

  PV Size 203.92 MiB / not usable 3.92 MiB

  Allocatable yes (but full)

  PE Size 4.00 MiB

  Total PE 50

  Free PE 0 《-----太悲劇了,sda6裡寫滿了數據一點不剩

  Allocated PE 50 《-----這50PE的數據要挪走才行,否則數據就丟了,並且存放的地方也必須是連續的至少50PE

  PV UUID S2ane6-nlFG-uSNR-35NP-Yxa6-cXRb-r8E8mK

  --- Physical Segments ---

  Physical extent 0 to 49:

  Logical volume /dev/liuhg_disk/home

  Logical extents 25 to 74

  --- Physical volume ---

  PV Name /dev/sda7

  VG Name liuhg_disk

  PV Size 305.89 MiB / not usable 1.89 MiB

  Allocatable yes

  PE Size 4.00 MiB

  Total PE 76

  Free PE 76 《---這個分區有76個空余,因此預計裝那50個是不會有問題的

  Allocated PE 0

  PV UUID 9CFnlx-CAEw-CSul-Rig9-FiCN-zK0a-oGmTEP

  --- Physical Segments ---

  Physical extent 0 to 75:

  FREE

  --- Physical volume ---

  PV Name /dev/sda8

  VG Name liuhg_disk

  PV Size 407.87 MiB / not usable 3.87 MiB

  Allocatable yes

  PE Size 4.00 MiB

  Total PE 101

  Free PE 60

  Allocated PE 41

  PV UUID X0I8p0-x2xr-2xLG-QQD4-jbtS-3C4i-xPn4Bl

  --- Physical Segments ---

  Physical extent 0 to 40:

  Logical volume /dev/liuhg_disk/home

  Logical extents 471 to 511

 12 共2頁

Copyright © Linux教程網 All Rights Reserved