我正在尝试在 Vmware Workstation 12 Pro CentOS VM 中扩展 LVM。以下是我正在遵循的步骤以及我停止的地方,因为不知道如何从那里开始:
fdisk
使用命令创建主分区使用以下方法获取分区表信息
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
将分区转换为物理卷:
# pvcreate /dev/sda3 Physical volume "/dev/sda3" successfully created
获取要扩展的卷的名称:
# 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
扩展物理卷:
# vgextend vg_webserver /dev/sda3 Volume group "vg_webserver" successfully extended
获得可用的“免费”空间:
# vgextend vg_webserver /dev/sda3 Volume group "vg_webserver" successfully extended
获取逻辑卷的信息:
# 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
扩展逻辑卷:
# 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>
您可以使用
-l
带有可用范围数量的选项:引自
man lvextend
:更好的方法是:
寻找“免费 PE / 尺寸”。在这种情况下为 1020M。这样做: