如何扩大这个分区呢?

如何扩大这个分区呢?

在 vmware ESXI 内部,我有一个 CentOS 虚拟机,我使用 vmware“编辑”vm 菜单将虚拟磁盘大小从大约 30 GB 调整到 120 GB。

然后我使用 gparted 可启动 ISO 进行启动,并将分区大小从 30GB 调整为最大 (120 GB)

但现在当我启动时,我仍然看到主分区 ( /root) 约为 25 GB。据我所知(下面的代码)磁盘被视为 ~120GB 但不是分区?

为了安全地扩展分区,需要运行哪些命令?我认为这是/root需要扩展的。

[root@localhost ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   26G  1.6G   25G   6% /
devtmpfs                 3.9G     0  3.9G   0% /dev
tmpfs                    3.9G     0  3.9G   0% /dev/shm
tmpfs                    3.9G  8.9M  3.9G   1% /run
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1               1014M  145M  870M  15% /boot
tmpfs                    783M     0  783M   0% /run/user/0


[root@localhost ~]# fdisk -l

Disk /dev/sda: 128.8 GB, 128849018880 bytes, 251658240 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 label type: dos
Disk identifier: 0x000d5212

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   251658239   124779520   8e  Linux LVM

Disk /dev/mapper/centos-root: 27.9 GB, 27913093120 bytes, 54517760 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/centos-swap: 3221 MB, 3221225472 bytes, 6291456 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

编辑:

[root@localhost ~]# lsblk -f
NAME            FSTYPE      LABEL UUID                                   MOUNTPOINT
sda
├─sda1          xfs               2499226d-4c93-4ef1-b4ab-1055f8bab7cd   /boot
└─sda2          LVM2_member       49Sk0d-ClAm-FGza-9HrJ-hYGP-V1Zn-UlrgaO
  ├─centos-root xfs               f78ccb25-5dcc-49fc-81b8-5c33e6b5e9ef   /
  └─centos-swap swap              100d2a33-ab8d-4dd8-8e6c-19d51ad53a40   [SWAP]
sr0

[root@localhost ~]# pvs
  PV         VG     Fmt  Attr PSize    PFree
  /dev/sda2  centos lvm2 a--  <119.00g 90.00g

编辑2:

[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name               centos
  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               <119.00 GiB
  PE Size               4.00 MiB
  Total PE              30463
  Alloc PE / Size       7423 / <29.00 GiB
  Free  PE / Size       23040 / 90.00 GiB
  VG UUID               dpAjcO-xazq-6sJZ-PA23-N0a0-Zcz3-iRVloi



[root@localhost ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                ZuJyt6-YDaV-1kw7-Zjzl-4gPX-vkzH-dfmV7y
  LV Write Access        read/write
  LV Creation host, time localhost, 2019-04-01 19:44:02 -0400
  LV Status              available
  # open                 2
  LV Size                3.00 GiB
  Current LE             768
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                KkcOnV-OQvj-lpmc-5Eiz-2hfd-6mcV-30zWvW
  LV Write Access        read/write
  LV Creation host, time localhost, 2019-04-01 19:44:03 -0400
  LV Status              available
  # open                 1
  LV Size                <26.00 GiB
  Current LE             6655
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

答案1

编辑:

看起来您已经创建了分区和物理卷,并将空间添加到卷组中,因此我删除了有关向磁盘添加新分区和创建新physical volume.

要扩展根逻辑卷:

lvextend -l +100%FREE /dev/centos/root

要同步新空间:

xfs_growfs /dev/centos/root

运行df -h以查看带有额外空间的新大小,并lvdisplay | sed -n '/root/,$p查看根逻辑卷本身增加的大小。

相关内容