准备环境
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.qcow2
image: uniontechos-server-20-1050a-amd64-gui.qcow2
file format: qcow2 virtual size: 12.5 GiB (13421772800 bytes) #系统安装后的默认大小
disk size: 3.24 GiB
cluster_size: 65536
Format specific information:
compat: 1.1 lazy
refcounts: false
refcount bits: 16
corrupt: false
1.2、查看镜像分区信息
virt-df uniontechos-server-20-1050a-amd64-gui.qcow2
文件系统 1K-blocks 已用空间 可用空间 使用百分比%
uniontechos-server-20-1050a-amd64-gui.qcow2:/dev/sda1
1038336 197216 841120 19%
uniontechos-server-20-1050a-amd64-gui.qcow2:/dev/uniontechos/root
11524096 6933576 4590520 61%
1.3、确认需要扩容的分区名
virt-filesystems --partitions --long -a uniontechos-server-20-1050a-amd64-gui.qcow2
Name Type MBR Size Parent
/dev/sda1 partition 83 1073741824 /dev/sda
/dev/sda2 partition 8e 12339642368 /dev/sda
2、扩容
2.1、备份镜像
cp uniontechos-server-20-1050a-amd64-gui.qcow2
uniontechos-server-20-1050a-amd64-gui.qcow2-bak
2.2、创建新的镜像文件,并指定空间
qemu-img create -f qcow2 1050a-expand.qcow2 100G
2.3、将系统扩容到新的镜像
virt-resize
--expand
/dev/sda2 uniontechos-server-20-1050a-amd64-gui.qcow2 1050a-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 PV
on /dev/sda2 will be expanded using the ??pvresize?? method.
**********
[ 2.4] Setting up initial partition table on 1050a-expand.qcow2
[ 3.4] Copying /dev/sda1
100% ????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????? --:--
[ 5.5] Copying /dev/sda2
100% ????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????? 00:00
[ 110.8] Expanding /dev/sda2 using the ??pvresize?? method
Resize 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 -a
1050a-expand.qcow2 Welcome to guestfish, the guest
filesystem 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 shell
Operating system: UnionTech OS Server 20
/dev/uniontechos/root mounted on /
/dev/sda1 mounted on /boot
><fs> command
'lvs'
><fs> command
'lvextend -l +100%FREE /dev/mapper/uniontechos-root
><fs> command
'xfs_growfs /dev/mapper/uniontechos-root
5、验证
5.1、再次查看镜像空间
5.2、再次查看分区空间
5.3、重新启动镜像
1050a-expand.qcow2
©统信软件技术有限公司。访问者可将本网站提供的内容或服务用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯本网站及相关权利人的合法权利。除此以外,将本网站任何内容或服务进行转载,须备注:该文档出自【faq.uniontech.com】统信软件知识分享平台。否则统信软件将追究相关版权责任。