我有一个在 Ubuntu 机器上运行(无头)的 Debian Linux VM。我使用 vboxmanage 将虚拟磁盘的大小从原来的 20G 增加到了 30G。我已经尝试了很多方法,但我仍然卡在LVM分区显示20G的问题上。
我从 ISO 启动并进入修复模式。我通过删除 sda2 和 sda5 分区并使用新的结束扇区创建新分区来更改分区表。我无法从这里扩展分区。
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/dm-0 19G 13G 5.5G 69% /
udev 10M 0 10M 0% /dev
tmpfs 1.6G 8.4M 1.6G 1% /run
tmpfs 4.0G 0 4.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 4.0G 0 4.0G 0% /sys/fs/cgroup
/dev/sda1 236M 33M 191M 15% /boot
192.168.10.177:/ 8.2G 2.4G 5.4G 31% /mnt/nfs
# fdisk -l
Disk /dev/sda: 30 GiB, 32212254720 bytes, 62914560 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf5edb169
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 499711 497664 243M 83 Linux
/dev/sda2 499712 62914559 62414848 29.8G 5 Extended
/dev/sda5 501760 62914559 62412800 29.8G 8e Linux LVM
Disk /dev/mapper/ArkSrvr--vg-root: 18.9 GiB, 20300431360 bytes, 39649280 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/ArkSrvr--vg-swap_1: 872 MiB, 914358272 bytes, 1785856 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
# pvdisplay
--- Physical volume ---
PV Name /dev/sda5
VG Name ArkSrvr-vg
PV Size 19.76 GiB / not usable 2.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 5058
Free PE 0
Allocated PE 5058
PV UUID yWin1N-w3A4-sIAR-O2q9-nqPp-ki4G-yPr7kr
# lvdisplay
--- Logical volume ---
LV Path /dev/ArkSrvr-vg/root
LV Name root
VG Name ArkSrvr-vg
LV UUID 6YHVao-5Pth-2gA7-w42j-wAW7-mc9W-sQcImK
LV Write Access read/write
LV Creation host, time ArkSrvr, 2017-03-06 08:51:00 -0600
LV Status available
# open 1
LV Size 18.91 GiB
Current LE 4840
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:0
--- Logical volume ---
LV Path /dev/ArkSrvr-vg/swap_1
LV Name swap_1
VG Name ArkSrvr-vg
LV UUID eElIsI-bGdy-Cuje-BacF-1zap-wzlS-ftD28h
LV Write Access read/write
LV Creation host, time ArkSrvr, 2017-03-06 08:51:00 -0600
LV Status available
# open 2
LV Size 872.00 MiB
Current LE 218
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:1
# lvextend -L+10G /dev/ArkSrvr-vg/root
Insufficient free space: 2560 extents needed, but only 0 available
# lvextend -l+100%FREE /dev/ArkSrvr-vg/root
New size (4840 extents) matches existing size (4840 extents)
Run `lvextend --help' for more information.
# resize2fs /dev/ArkSrvr-vg/root
resize2fs 1.42.12 (29-Aug-2014)
The filesystem is already 4956160 (4k) blocks long. Nothing to do!
如何将 /dev/ArkSrvr-vg/root 增加到 30G?
答案1
你错过了一步。
您所拥有的是分区内(一组)物理卷内逻辑卷内的文件系统。
您已经扩展了分区。下一步是扩展物理卷:
pvresize /dev/sda5
您不必在此处指定大小:如果没有大小参数,PV 将自动采用封闭容器(在本例中为分区)允许的最大大小。
如果成功,该pvdisplay
命令应显示总 PE 增加,并且可用 PE 不再为 0。因此您将拥有一些可以使用的可用物理扩展。
下一步是扩展逻辑卷,然后是文件系统。看起来您已经知道该怎么做了。