可用空间不足:需要 X 个扩展区,但只有 Y 个可用

可用空间不足:需要 X 个扩展区,但只有 Y 个可用

我正在尝试在 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
    
  3. 将分区转换为物理卷:

    # pvcreate /dev/sda3
      Physical volume "/dev/sda3" successfully created  
    
  4. 获取要扩展的卷的名称:

    # 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
    
  5. 扩展物理卷:

    # vgextend vg_webserver /dev/sda3
      Volume group "vg_webserver" successfully extended
    
  6. 获取可用的“空闲”空间:

    # vgextend vg_webserver /dev/sda3
      Volume group "vg_webserver" successfully extended
    
  7. 获取逻辑卷的信息:

    # 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
    
  8. 扩展逻辑卷:

    # 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

答案1

我认为工作中的一些失误导致了你的lvextend失败。

尝试这个:lvextend /dev/vg_webserver/lv_root -l+100%FREE

上述命令将要求系统分配所有可用空间到选定的逻辑卷,而不要求具体的大小。

答案2

您可以运行抓取所有可用空间:lvextend /dev/vg_webserver/lv_root -l+100%FREE

接下来你需要运行:对于 xfs:xfs_growfs <partition> 对于 ext4:resize2fs <partition>

答案3

您可以使用-l具有可用范围数量的选项:

sudo lvextend  -l+10239 /dev/vg_webserver/lv_root

引文来自man lvextend

   -l|--extents [+]Number[PERCENT]

指定逻辑盘区中 LV 的新大小。--
size 和 --extents 选项是指定大小的替代方法。当 RAID 级别需要冗余数据时,使用的物理盘区总数将更大。替代语法允许间接确定大小作为相关 VG、LV 或 PV 集大小的百分比。后缀 %VG 表示 VG 的总大小,后缀 %FREE 表示 VG 中剩余的可用空间,后缀 %PVS 表示指定 PV 中的可用空间。对于快照,大小可以表示为带有后缀 %ORIGIN 的源 LV 总大小的百分比(100%ORIGIN 为整个源提供空间)。当以百分比表示时,大小定义了新 LV 中逻辑盘区数量的上限。直到命令完成后才能确定新 LV 中逻辑盘区的准确数量。当使用加号 + 或减号 - 前缀时,该值不是绝对大小,而是相对的,并从当前大小中加上或减去。

答案4

vgdisplay    --- Volume group ---
  VG Name               cl
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <299.00 GiB
  PE Size               4.00 MiB
  Total PE              76543
  Alloc PE / Size       76543 / <299.00 GiB
  Free  PE / Size       0 / 0   
  VG UUID               wakdFZ-f1sR-3cNk-0bMH-VZaS-slgU-3MOOKt

我想扩展 /dev/mapper/cl-root 到 200 GB

我的 df-h /dev/mapper/cl-root 50G 4.0G 47G 8% /

/dev/mapper/cl-home 241G 1.8G 240G 1% /home

/dev/sda1 976M 129M 781M 15% /boot

怎么办谢谢

相关内容