Virtual-Machines

可用空間不足:需要 X 個擴展區,但只有 Y 個可用

  • August 19, 2021

我正在嘗試在 Vmware Workstation 12 Pro CentOS VM 中擴展 LVM。以下是我正在遵循的步驟以及我停止的地方,因為不知道如何從那裡開始:

  1. fdisk使用命令創建主分區
  2. 使用以下方法獲取分區表資訊fdisk -l
# fdisk -l

Disk /dev/sda: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001d929

  Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        5222    41430016   8e  Linux LVM
/dev/sda3            5222       10443    41940357+  8e  Linux LVM

Disk /dev/mapper/vg_webserver-lv_root: 38.3 GB, 38277218304 bytes
255 heads, 63 sectors/track, 4653 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_webserver-lv_swap: 4143 MB, 4143972352 bytes
255 heads, 63 sectors/track, 503 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
  1. 將分區轉換為物理卷:
# pvcreate /dev/sda3
 Physical volume "/dev/sda3" successfully created  
  1. 獲取要擴展的捲的名稱:
# vgdisplay
 --- Volume group ---
 VG Name               vg_webserver
 System ID
 Format                lvm2
 Metadata Areas        1
 Metadata Sequence No  3
 VG Access             read/write
 VG Status             resizable
 MAX LV                0
 Cur LV                2
 Open LV               2
 Max PV                0
 Cur PV                1
 Act PV                1
 VG Size               39.51 GiB
 PE Size               4.00 MiB
 Total PE              10114
 Alloc PE / Size       10114 / 39.51 GiB
 Free  PE / Size       0 / 0
 VG UUID               qo4qm0-yTZc-TVzt-Ys0t-Ap2j-sH4X-rtMqPS
  1. 擴展物理卷:
# vgextend vg_webserver /dev/sda3
 Volume group "vg_webserver" successfully extended
  1. 獲得可用的“免費”空間:
# vgextend vg_webserver /dev/sda3
 Volume group "vg_webserver" successfully extended
  1. 獲取邏輯卷的資訊:
# lvdisplay
 --- Logical volume ---
 LV Path                /dev/vg_webserver/lv_root
 LV Name                lv_root
 VG Name                vg_webserver
 LV UUID                ayl9Ae-Y7nk-CVXG-c0G1-P4vx-wdlD-hEmXSO
 LV Write Access        read/write
 LV Creation host, time webserver.localhost, 2015-10-27 12:48:48 -0400
 LV Status              available
 # open                 1
 LV Size                35.65 GiB
 Current LE             9126
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto
 - currently set to     256
 Block device           253:0

 --- Logical volume ---
 LV Path                /dev/vg_webserver/lv_swap
 LV Name                lv_swap
 VG Name                vg_webserver
 LV UUID                vwXfta-tGr0-kQFI-B2vF-L4gT-skE5-yb5qXA
 LV Write Access        read/write
 LV Creation host, time webserver.localhost, 2015-10-27 12:48:52 -0400
 LV Status              available
 # open                 1
 LV Size                3.86 GiB
 Current LE             988
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto
 - currently set to     256
 Block device           253:1
  1. 擴展邏輯卷:
# lvextend -L+40G /dev/vg_webserver/lv_root
 Insufficient free space: 10240 extents needed, but only 10239 available

我得到了上面的錯誤,我不知道從那裡去哪里以及如何解決這個問題,有什麼可以幫助我的嗎?我做錯了什麼,我正在執行的問題背後的邏輯解釋是什麼?

注意:我已閱讀內容,但我不確定如何撤消我已經做出的所有更改,以及此資訊是否是要遵循的路徑

更新

這裡要求的是以下命令的輸出:

# pvdisplay
 --- Physical volume ---
 PV Name               /dev/sda2
 VG Name               vg_webserver
 PV Size               39.51 GiB / not usable 3.00 MiB
 Allocatable           yes (but full)
 PE Size               4.00 MiB
 Total PE              10114
 Free PE               0
 Allocated PE          10114
 PV UUID               mwFIHY-mwwJ-b3uk-PkbP-7JXp-Vp2t-foCZtt

 --- Physical volume ---
 PV Name               /dev/sda3
 VG Name               vg_webserver
 PV Size               40.00 GiB / not usable 1.38 MiB
 Allocatable           yes (but full)
 PE Size               4.00 MiB
 Total PE              10239
 Free PE               0
 Allocated PE          10239
 PV UUID               tWg4Oj-ZknB-mefb-Ggy9-V8Cu-C7S2-OvO5aU

# vgdisplay
 --- Volume group ---
 VG Name               vg_webserver
 System ID
 Format                lvm2
 Metadata Areas        2
 Metadata Sequence No  5
 VG Access             read/write
 VG Status             resizable
 MAX LV                0
 Cur LV                2
 Open LV               2
 Max PV                0
 Cur PV                2
 Act PV                2
 VG Size               79.50 GiB
 PE Size               4.00 MiB
 Total PE              20353
 Alloc PE / Size       20353 / 79.50 GiB
 Free  PE / Size       0 / 0
 VG UUID               qo4qm0-yTZc-TVzt-Ys0t-Ap2j-sH4X-rtMqPS

# lvdisplay
 --- Logical volume ---
 LV Path                /dev/vg_webserver/lv_root
 LV Name                lv_root
 VG Name                vg_webserver
 LV UUID                ayl9Ae-Y7nk-CVXG-c0G1-P4vx-wdlD-hEmXSO
 LV Write Access        read/write
 LV Creation host, time webserver.localhost, 2015-10-27 12:48:48 -0400
 LV Status              available
 # open                 1
 LV Size                75.64 GiB
 Current LE             19365
 Segments               2
 Allocation             inherit
 Read ahead sectors     auto
 - currently set to     256
 Block device           253:0

 --- Logical volume ---
 LV Path                /dev/vg_webserver/lv_swap
 LV Name                lv_swap
 VG Name                vg_webserver
 LV UUID                vwXfta-tGr0-kQFI-B2vF-L4gT-skE5-yb5qXA
 LV Write Access        read/write
 LV Creation host, time webserver.localhost, 2015-10-27 12:48:52 -0400
 LV Status              available
 # open                 1
 LV Size                3.86 GiB
 Current LE             988
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto
 - currently set to     256
 Block device           253:1

我認為工作中的一些四捨五入會導致你lvextend失敗。

試試這個:lvextend /dev/vg_webserver/lv_root -l+100%FREE

上述命令將要求系統將所有可用空間分配給選定的邏輯卷,而不要求特定大小。

您可以執行獲取所有可用空間:lvextend /dev/vg_webserver/lv_root -l+100%FREE

之後您需要執行: 如果是 xfs:xfs_growfs <partition> 對於 ext4:resize2fs <partition>

引用自:https://serverfault.com/questions/733407