**环境 文件系统
CentOS 7 XFS
1.1查看虚拟机(以下操作在宿主机上)**
[root@office-prd-kvm-01 ~]# virsh list
4 office-com-ldap-01 running
1.2查看虚拟机系统盘
[root@office-prd-kvm-01 ~]# virsh domblklist office-com-ldap-01
目标 源
------------------------------------------------
vda /home/office-com-ldap-01/office-com-ldap-01.system.qcow2
hda
1.3原始系统盘大小
[root@office-prd-kvm-01 ~]# qemu-img info /home/office-com-ldap-01/office-com-ldap-01.system.qcow2
virtual size: 15G (16106127360 bytes)
#很重要要先关闭虚拟机
[root@office-prd-kvm-01 ~]# virsh shutdown office-com-ldap-01
1.4扩容磁盘
[root@office-prd-kvm-01 ~]# qemu-img resize /home/office-com-ldap-01/office-com-ldap-01.system.qcow2 +5G
[root@office-prd-kvm-01 ~]# qemu-img info /home/office-com-ldap-01/office-com-ldap-01.system.qcow2
virtual size: 20G (21474836480 bytes)
[root@office-prd-kvm-01 ~]# virsh start office-com-ldap-01
2.1查看是否增加
[root@office-prd-kvm-01 ~]# lsblk
2.2给未分配的空间分区
[root@office-prd-kvm-01 ~]# fdisk /dev/vda
命令(输入 m 获取帮助):n
Select (default p):p
命令(输入 m 获取帮助):t
Hex 代码(输入 L列出所有代码):l
Hex代码 (输入 L 列出所有代码):8e
命令(输入 m 获取帮助):p
命令(输入 m 获取帮助):w
2.3刷新分区表
[root@office-com-ldap-01 ~]# partprobe
2.4添加到卷组(dev/centos/root)
[root@office-com-ldap-01 ~]# pvcreate /dev/vda3
Physical volume "/dev/vda3" successfully created.
[root@office-com-ldap-01 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/vda2 centos lvm2 a-- <9.00g 0
/dev/vda3 lvm2 --- 5.00g 5.00g
[root@office-com-ldap-01 ~]# vgextend centos /dev/vda3
Volume group "centos" successfully extended
[root@office-com-ldap-01 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 2 2 0 wz--n- 13.99g <5.00g
[root@office-com-ldap-01 ~]# lvextend -l +100%FREE /dev/mapper/centos-root
New size given (1279 extents) not larger than existing size (2047 extents)
[root@office-com-ldap-01 ~]# xfs_growfs /dev/mapper/centos-root
[root@office-com-ldap-01 ~]# df -Th
[post cid="32" /]