[root@GGD ~]# base-vm xxx #创建虚拟机
[ vm xxx create
[root@GGD ~]# virsh start xxx #启动虚拟机
域 xxx 已开始
[root@GGD ~]# virsh domblklist xxx #查看虚拟机磁盘路径
vda /var/lib/libvirt/images/xxx.img
[root@GGD ~]# qemu-img info /var/lib/libvirt/images/xxx.img #查看虚拟机磁盘大小
image: /var/lib/libvirt/images/xxx.img
file format: qcow2
virtual size: 30G
(32212254720 bytes)
disk size: 17M
cluster_size: 65536
backing file: /var/lib/libvirt/images/.node_base.qcow2
Format specific information:
compat: 1.1
lazy refcounts: false
[root@GGD ~]# virsh blockresize --path /var/lib/libvirt/images/xxx.img --size 50G xxx #扩容磁盘到50G
重新定义 ‘/var/lib/libvirt/images/xxx.img’ 块设备大小
[root@GGD ~]# virsh console xxx #进入虚拟机
连接到域 xxx
换码符为 ^]
CentOS Linux 7 (Core)
Kernel 3.10.0-862.el7.x86_64 on an x86_64
localhost login: root #管理员
Password: #密码
Last login: Sat Jan 26 13:22:25 from 192.168.1.254
[root@localhost ~]# eip 10 #自动获取IP
[root@localhost ~]# LANG=C #设置语言为英文坏境
[root@localhost ~]# growpart /dev/vda 1 #扩容分区
CHANGED: partition=1 start=2048 old: size=62912479 end=62914527 new: size=104855519,end=104857567
[root@localhost ~]# xfs_growfs / #扩容文件系统
meta-data=/dev/vda1 isize=512 agcount=61, agsize=131008 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=7864059, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 7864059 to 13106939
[root@localhost ~]#
[root@localhost ~]# df -h #查看扩容成功
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 50G 914M 50G 2% /
devtmpfs 697M 0 697M 0% /dev
tmpfs 707M 0 707M 0% /dev/shm
tmpfs 707M 8.4M 699M 2% /run
tmpfs 707M 0 707M 0% /sys/fs/cgroup
tmpfs 142M 0 142M 0% /run/user/0