在 linux gparted 上扩展分区但在 vm 中没有更多空间

Ask*_*ken 5 ubuntu partition gparted

我有一个运行构建服务器的 linux 的 vm 测试安装。不幸的是,我在添加磁盘时只是按了确定,最终得到了一个 8GB 的​​驱动器。当然,在测试阶段,构建会消耗越来越多的空间。

vm 驱动器被调整为 21gb 并使用 gparted 我扩展了驱动器分区并且一切正常但是当我回到控制台并执行 df 时仍然只有 8gb 可用。

我如何声明我添加的其他 13GB?

fdisk -l

Disk /dev/sda: 21.0 GB, 20971520000 bytes
255 heads, 63 sectors/track, 2549 cylinders, total 40960000 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 identifier: 0x0006d284

Device    Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758    40959999    20229121    5  Extended
/dev/sda5          501760    40959999    20229120   8e  Linux LVM

vgdisplay

--- Volume group ---
VG Name               ct
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  4
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               19.29 GiB
PE Size               4.00 MiB
Total PE              4938
Alloc PE / Size       1977 / 7.72 GiB
Free  PE / Size       2961 / 11.57 GiB
VG UUID               MwiMAz-52e1-iGVf-eL4f-P5lq-FvRA-L73Sl3

lvdisplay

  --- Logical volume ---
LV Name                /dev/ct/root
VG Name                ct
LV UUID                Rfk9fh-kqdM-q7t5-ml6i-EjE8-nMtU-usBF0m
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                5.73 GiB
Current LE             1466
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           252:0

--- Logical volume ---
LV Name                /dev/ct/swap_1
VG Name                ct
LV UUID                BLFaa6-1f5T-4MM0-5goV-1aur-nzl9-sNLXIs
LV Write Access        read/write
LV Status              available
# open                 2
LV Size                2.00 GiB
Current LE             511
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           252:1
Run Code Online (Sandbox Code Playgroud)

B14*_*4D3 10

你调整了分区的大小,现在你必须调整 lvm 和文件系统的大小......你可以用 pvextend 和 resize2fs 来做到这一点阅读手册做备份使用考虑...... :)

您所要做的就是在您的情况下扩展适当的 lvm 卷,我认为 /dev/ct/root 与您新的免费 pe(物理扩展)。您可以使用lvdisplay命令查看所有卷使用并扩展正确的卷

lvextend -l +2961 /dev/ct/root

之后,您必须使用命令扩展文件系统 resize2fs -p /dev/ct/root

就这样!即使已挂载,您也可以在工作文件系统上执行此操作(警告我从未在根分区上执行此操作/因此我无法为您提供有关本教程的任何保证)

  • 伙计,你的答案读起来就像松鼠在速度上写的一样。 (2认同)