1。
[root@ kvm]# qemu-img info new.qcow2 image: new.qcow2 file format: qcow2 virtual size: 60G (64424509440 bytes) disk size: 7.0G cluster_size: 65536 qemu-img resize filename +20G Image resized. [root@BJ-W-2101 kvm]# qemu-img info new.qcow2 image: new.qcow2 file format: qcow2 virtual size: 80G (85899345920 bytes) disk size: 7.0G cluster_size: 65536
磁盘扩展的第一步搞定。这里建议只搞一个/分区, 添加完磁盘后,可以识别挂载出来。我们是一个/ 和一个/export 分区, 扩展完磁盘后,进入到系统,fdisk -l 接着就是删除磁盘创建磁盘的过程。这个大家应该比我更熟练。就不多说了。
2. 磁盘扩展
扩展qcow2 磁盘格式
使用命令
virt-filesystems --long -h --all -a olddisk truncate -r olddisk newdisk truncate -s +5G newdisk # Note "/dev/sda2" is a partition inside the "olddisk" file. virt-resize --expand /dev/sda2 olddisk newdisk
cp net.qcow2 nett.qcow2 [root@ kvm]# virt-df -h net.qcow2 Filesystem Size Used Available Use% net.qcow2:/dev/sda1 194M 28M 155M 15% net.qcow2:/dev/sda2 19G 6.3G 12G 33% net.qcow2:/dev/sda5 36G 176M 34G 1% [root@ kvm]# virt-filesystems --long -h --all -a net.qcow2 Name Type VFS Label MBR Size Parent /dev/sda1 filesystem ext4 - - 200M - /dev/sda2 filesystem ext4 - - 20G - /dev/sda3 filesystem swap - - 4.0G - /dev/sda4 filesystem unknown - - 1.0K - /dev/sda5 filesystem ext4 - - 36G - /dev/sda1 partition - - 83 200M /dev/sda /dev/sda2 partition - - 83 20G /dev/sda /dev/sda3 partition - - 82 4.0G /dev/sda /dev/sda4 partition - - 05 1.0K /dev/sda /dev/sda5 partition - - 83 36G /dev/sda /dev/sda device - - - 80G - 选择要扩展的磁盘 我选择的是/dev/sda2 需要执行如下命令 truncate -r net.qcow2 nett.qcow2 truncate -s +5G nett.qcow2 [root@ kvm]# virt-resize --expand /dev/sda2 net.qcow2 nett.qcow2 枓鈻掆枓鈼74% 鉄︹枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓鈻掆枓 Resize operation completed with no errors. Before deleting the old disk, carefully check that the resized disk boots and works correctly 这就转换成功 [root@BJ-W-2101 kvm]# virt-filesystems --long -h --all -a nett.qcow2 Name Type VFS Label MBR Size Parent /dev/sda1 filesystem ext4 - - 200M - /dev/sda2 filesystem ext4 - - 40G - /dev/sda3 filesystem swap - - 4.0G - /dev/sda4 filesystem unknown - - 1.0K - /dev/sda5 filesystem ext4 - - 36G - /dev/sda1 partition - - 83 200M /dev/sda /dev/sda2 partition - - 83 40G /dev/sda # 增长了不少。 /dev/sda3 partition - - 82 4.0G /dev/sda /dev/sda4 partition - - 05 1.0K /dev/sda /dev/sda5 partition - - 83 36G /dev/sda /dev/sda device - - - 80G - [root@ kvm]# qemu-img info nett.qcow2 image: nett.qcow2 file format: qcow2 virtual size: 80G (85899345920 bytes) disk size: 60G cluster_size: 65536 virt-resize 只能扩展主分区。/dev/sda5 已经变为扩展分区,无法直接对其扩展,可以对/dev/sda4进行扩展,再重新格式化磁盘,重新分区。
如过哪位仁兄有更好或其他方式,请不吝赐教。
qemu qcow2 disk enlarge,布布扣,bubuko.com
原文地址:http://my.oschina.net/davisqi/blog/292662