Loading... # 一.宿主机扩容虚拟机系统盘 **环境 文件系统 CentOS 7 XFS 1.1查看虚拟机(以下操作在宿主机上)** ```shell [root@office-prd-kvm-01 ~]# virsh list 4 office-com-ldap-01 running ``` **1.2查看虚拟机系统盘** ```shell [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原始系统盘大小** ```shell [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扩容磁盘 ```shell [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 ``` # 二.虚拟机内查看(以下操作在kvm虚拟机中) 2.1查看是否增加 ```shell [root@office-prd-kvm-01 ~]# lsblk ``` ![请输入图片描述](https://www.helloimg.com/images/2022/02/23/GrlIO1.png) **2.2给未分配的空间分区** ```shell [root@office-prd-kvm-01 ~]# fdisk /dev/vda ``` ![请输入图片描述](https://www.helloimg.com/images/2022/02/23/GrlYNQ.png) ```shell 命令(输入 m 获取帮助):n Select (default p):p 命令(输入 m 获取帮助):t Hex 代码(输入 L列出所有代码):l ``` ![请输入图片描述](https://www.helloimg.com/images/2022/02/23/GrljEu.png) ```shell Hex代码 (输入 L 列出所有代码):8e 命令(输入 m 获取帮助):p 命令(输入 m 获取帮助):w ``` ![请输入图片描述](https://www.helloimg.com/images/2022/02/23/GrlyrE.png) **2.3刷新分区表** ```shell [root@office-com-ldap-01 ~]# partprobe ``` **2.4添加到卷组(dev/centos/root)** ```shell [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 ``` `<div class="preview"> <div class="post-inser post box-shadow-wrap-normal"> <a href="https://bk1314.com/32.html" target="_blank" class="post_inser_a no-external-link no-underline-link"> <div class="inner-image bg" style="background-image: url(https://www.helloimg.com/images/2022/02/24/GrTSaK.png);background-size: cover;"></div> <div class="inner-content" > <p class="inser-title">Linux类系统手动操作篇--标准分区硬盘和目录扩容,适合魔方云机器扩容系统盘 BY:宝塔运维-赤井秀一</p> <div class="inster-summary text-muted"> !!!必读!!!!!!数据无价,谨慎操作,操作之前做好服务器快照,方便操作失败回滚!!!!!!数据无价,谨慎操作,... </div> </div> </a> <!-- .inner-content #####--> </div> <!-- .post-inser ####--> </div>` 最后修改:2022 年 05 月 21 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏