预备:下载 gparted-live-0.30.0-1-amd64.iso
官网地址:https://nchc.dl.sourceforge.net/project/gparted/gparted-live-stable/0.30.0-1/gparted-live-0.30.0-1-amd64.iso
网盘共享:链接:https://pan.baidu.com/s/1qZbbvE8 密码:i7uq
- 在cmd命令行下进入VirtualBox的安装目录,使用“VBoxManage list hdds”命令,找到需要修改磁盘容量的虚拟机的img路径或UUID:
D:\Program Files\Oracle\VirtualBox>VBoxManage list hdds
UUID: c820a29d-f74f-4a5a-81e8-c6156babd3ae
Parent UUID: base
State: created
Type: normal (base)
Location: D:\VirtualBox_VMs\node02\node02.vdi
Storage format: VDI
Capacity: 8192 MBytes
Encryption: disabled
D:\Program Files\Oracle\VirtualBox>
由以上内容可知,D:\VirtualBox_VMs\node02\node02.vdi ,此虚拟磁盘大小为8192M=8G 大小,现在将其扩容到20G。
- 修改虚拟机的磁盘空间
D:\Program Files\Oracle\VirtualBox>VBoxManage modifyhd "D:\VirtualBox_VMs\node02\node02.vdi" --resize 20480
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
设置完成
- 让虚拟机上CentOS知道磁盘容量已经增加
在VirtualBox光驱中加载下载的gparted-live-0.16.1-1-amd64.iso镜像,设置为第一顺序启动










如上图所示,得到一个新的拓展分区 /dev/sda3,磁盘添加完成!
- 关闭GParted,在VirtualBox设置中将gparted-live-0.30.0-1-amd64.iso 镜像卸载,再启动CentOS,进入CentOS系统



- 在CentOS终端中扩展逻辑分区
a. 确保当前为root 用户

b.在前面 [3]步骤中,通过gparted 工具得到一个新的分区 /dev/sda3
执行 lvm pvcreate /dev/sda3

c. 执行lvm vgextend "vg_node" /dev/sda3, 添加/dev/sda3到卷组vg_node

d. 执行lvresize -l+100%FREE /dev/mapper/vg_node-lv_root,扩展卷组vg_node下的lv_root卷组

e. 执行 resize2fs /dev/mapper/vg_node-lv_root 重新设置文件系统

f. 执行df -h -T验证扩展磁盘容量

- 磁盘容量扩展成功,重启CentOS 使用!
网友评论