需要帮助扩展 Debian 虚拟服务器的空间

需要帮助扩展 Debian 虚拟服务器的空间

我在 vmware 上运行一个虚拟机,它只分配了 17gig 的空间,我将 vmware 中的硬盘大小从 17gig 更改为 100gig。

这是虚拟机的信息,如何将容量从 17gig 扩展到 100gig?

Last login: Mon Jul 30 18:33:29 2018
root@observium ~# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda1
  VG Name               turnkey
  PV Size               18.57 GiB / not usable 1.41 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              4753
  Free PE               273
  Allocated PE          4480
  PV UUID               AjIer9-K9Ue-vCoB-andJ-Nyjc-M7nq-Grl4dy

root@observium ~# pvdisplay
  --- Volume group ---
  VG Name               turnkey
  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               18.57 GiB
  PE Size               4.00 MiB
  Total PE              4753
  Alloc PE / Size       4480 / 17.50 GiB
  Free  PE / Size       273 / 1.07 GiB
  VG UUID               pMLhIv-btYl-Jel3-VXuu-WnTn-xjzN-W59dUm

root@observium ~# lvs display 
  --- Logical volume ---
  LV Path                /dev/turnkey/root
  LV Name                root
  VG Name                turnkey
  LV UUID                xSASQ7-l8Fe-a0kg-ruZa-DnOX-uefh-Fpm3pG
  LV Write Access        read/write
  LV Creation host, time tkldev, 2017-06-02 09:02:54 +0000
  LV Status              available
  # open                 1
  LV Size                17.00 GiB
  Current LE             4352
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:0

  --- Logical volume ---
  LV Path                /dev/turnkey/swap_1
  LV Name                swap_1
  VG Name                turnkey
  LV UUID                4d1BKJ-OBvj-iewk-h2Wb-wKWf-7I04-isvqjf
  LV Write Access        read/write
  LV Creation host, time tkldev, 2017-06-02 09:02:54 +0000
  LV Status              available
  # open                 2
  LV Size                512.00 MiB
  Current LE             128
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:1

root@observium ~# lvscan 
  ACTIVE            '/dev/turnkey/root' [17.00 GiB] inherit
  ACTIVE            '/dev/turnkey/swap_1' [512.00 MiB] inherit
root@observium ~# fis  disk -l

Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 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: 0x2f250c11

Device     Boot  Start      End  Sectors  Size Id Type
/dev/sda1  *    123046 39062500 38939455 18.6G 8e Linux LVM

Disk /dev/mapper/turnkey-root: 17 GiB, 18253611008 bytes, 35651584 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/turnkey-swap_1: 512 MiB, 536870912 bytes, 1048576 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

答案1

您需要调整分区 sda1 的一侧以获得更大的一端。如果您很小心,您可以只使用 fdisk,然后删除并重新创建它。只需确保您具有完全相同的起始扇区和类型。

完成此操作后,您应该能够运行pvresize /dev/sda1以扩展 LVM 中的可用空间。然后,您可以使用调整逻辑卷的大小lvresize,最后调整所包含的文件系统的大小(如果是 ext2/3/4,则使用)resize2fs

相关内容