统信服务器操作系统【qcow2 镜像空间扩容】方案

发布时间:2026/8/30 5:22:48
统信服务器操作系统【qcow2 镜像空间扩容】方案 准备环境1、统信服务器操作系统 V20 e 版本或V20 a 版本安装完成2、安装libguestfs-tools-c扩容工具#yum install libguestfs-tools-c扩容步骤1、检查环境信息1.1、查看镜像信息qemu-img info uniontechos-server-20-1050a-amd64-gui.qcow2image: uniontechos-server-20-1050a-amd64-gui.qcow2file format: qcow2 virtual size: 12.5 GiB (13421772800 bytes) #系统安装后的默认大小disk size: 3.24 GiBcluster_size: 65536Format specific information:compat: 1.1 lazyrefcounts: falserefcount bits: 16corrupt: false1.2、查看镜像分区信息virt-df uniontechos-server-20-1050a-amd64-gui.qcow2文件系统 1K-blocks 已用空间 可用空间 使用百分比%uniontechos-server-20-1050a-amd64-gui.qcow2:/dev/sda11038336 197216 841120 19%uniontechos-server-20-1050a-amd64-gui.qcow2:/dev/uniontechos/root11524096 6933576 4590520 61%1.3、确认需要扩容的分区名virt-filesystems --partitions --long -a uniontechos-server-20-1050a-amd64-gui.qcow2Name Type MBR Size Parent/dev/sda1 partition 83 1073741824 /dev/sda/dev/sda2 partition 8e 12339642368 /dev/sda2、扩容2.1、备份镜像cp uniontechos-server-20-1050a-amd64-gui.qcow2uniontechos-server-20-1050a-amd64-gui.qcow2-bak2.2、创建新的镜像文件并指定空间qemu-img create -f qcow2 1050a-expand.qcow2 100G2.3、将系统扩容到新的镜像virt-resize--expand/dev/sda2 uniontechos-server-20-1050a-amd64-gui.qcow21050a-expand.qcow2[ 0.0] Examining uniontechos-server-20-1050a-amd64-gui.qcow2**********Summary of changes:/dev/sda1: This partition will be left alone./dev/sda2: This partition will be resized from 11.5G to 99.0G. The LVM PVon /dev/sda2 will be expanded using the ??pvresize?? method.**********[ 2.4] Setting up initial partition table on 1050a-expand.qcow2[ 3.4] Copying /dev/sda1100% ????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????? --:--[ 5.5] Copying /dev/sda2100% ????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????? 00:00[ 110.8] Expanding /dev/sda2 using the ??pvresize?? methodResize operation completed with no errors. Before deleting the old disk,carefully check that the resized disk boots and works correctly.3、扩容 lvm 分区guestfish-i --network -a1050a-expand.qcow2Welcome to guestfish, the guestfilesystem shell for editing virtual machine filesystems and disk images.4、扩容 lvm 分区Type: ‘help’ for help on commands‘man’ to read the manual‘quit’ to quit the shellOperating system: UnionTech OS Server 20/dev/uniontechos/root mounted on //dev/sda1 mounted on /bootfs commandlvsfs commandlvextend -l 100%FREE /dev/mapper/uniontechos-rootfs commandxfs_growfs /dev/mapper/uniontechos-root5、验证5.1、再次查看镜像空间查看镜像空间5.2、再次查看分区空间再次查看分区空间5.3、重新启动镜像1050a-expand.qcow2