- VMWARE设置
关闭虚拟机,删除快照,编辑虚拟机设置-硬件-硬盘-扩展磁盘容量(填写扩容后的最终大小)。 - 进入虚拟机
- 查看当前分区情况
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 49G 0 part ├─openeuler-root 253:0 0 45.1G 0 lvm /└─openeuler-swap 253:1 0 3.9G 0 lvm [SWAP]
sr0 11:0 1 1.5G 0 rom
磁盘sda大小已经是100G,sda2分区还是49G.
- 扩展分区表
[root@localhost ~]# sudo yum install cloud-utils-growpart
[root@localhost ~]# sudo growpart /dev/sda 2
CHANGED: partition=2 start=2099200 old: size=102758400 end=104857600 new: size=207615967 end=209715167
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 99G 0 part ├─openeuler-root 253:0 0 45.1G 0 lvm /└─openeuler-swap 253:1 0 3.9G 0 lvm [SWAP]
sr0 11:0 1 1.5G 0 rom
这将使 /dev/sda2 占用所有新增的空间,现在sda2大小为99G了。
- 扩展物理卷
[root@localhost ~]# sudo pvresize /dev/sda2Physical volume "/dev/sda2" changed1 physical volume(s) resized or updated / 0 physical volume(s) not resized
- 扩展卷组
[root@localhost ~]# sudo vgextend openeuler /dev/sda2Physical volume '/dev/sda2' is already in volume group 'openeuler'Unable to add physical volume '/dev/sda2' to volume group 'openeuler'/dev/sda2: physical volume not initialized.
- 扩展逻辑卷
[root@localhost ~]# sudo lvextend -l +100%FREE /dev/mapper/openeuler-rootSize of logical volume openeuler/root changed from <45.07 GiB (11537 extents) to <95.07 GiB (24337 extents).Logical volume openeuler/root successfully resized.
- 调整文件系统大小
我的是ext4 文件系统:
[root@localhost ~]# sudo resize2fs /dev/mapper/openeuler-root
resize2fs 1.46.4 (18-Aug-2021)
/dev/mapper/openeuler-root 上的文件系统已被挂载于 /;需要进行在线调整大小old_desc_blocks = 6, new_desc_blocks = 12
/dev/mapper/openeuler-root 上的文件系统现在为 24921088 个块(每块 4k)。
对于 xfs 文件系统:
sudo xfs_growfs /
- 查看最终结果
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 99G 0 part ├─openeuler-root 253:0 0 95.1G 0 lvm /└─openeuler-swap 253:1 0 3.9G 0 lvm [SWAP]
sr0 11:0 1 1.5G 0 rom