Qemu qcow2 disk enlarge

Source: Internet
Author: User
>

1.

[[email protected] kvm]# qemu-img info new.qcow2 image: new.qcow2file format: qcow2virtual size: 60G (64424509440 bytes)disk size: 7.0Gcluster_size: 65536qemu-img resize  filename +20GImage resized.[[email protected] kvm]# qemu-img  info new.qcow2 image: new.qcow2file format: qcow2virtual size: 80G (85899345920 bytes)disk size: 7.0Gcluster_size: 65536

The first step is to expand the disk. We recommend that you create only one partition. After adding a disk, you can identify the mount. We are a/and A/export partition. After expanding the disk, we enter the system. fdisk-L is followed by the process of deleting the disk and creating the disk. You should be more proficient than me. I will not go into detail.


2. Disk Expansion

Extended qcow2 disk format

Use commands

virt-filesystems --long -h --all -a olddisktruncate -r olddisk newdisktruncate -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 [[email protected] KVM] # virt-DF-H net. qcow2 filesystem size used available use % net. qcow2:/dev/sda1 194 m 28 m 155 m 15% net. qcow2:/dev/sda2 19G 6.3g 12g 33% net. qcow2:/dev/sda5 36g 176 m 34g 1% [[email protected] KVM] # virt-filesystems -- long-h -- all-a net. qcow2name type VFS label MBR size parent/dev/sda1 filesystem ext4---200 m-/dev/sda2 filesystem ext4--20g-/dev/sda3 fil Esystem swap--4.0g-/dev/sda4 filesystem unknown--1.0 K-/dev/sda5 filesystem ext4--36g-/dev/sda1 partition--83 200 m/ dev/SDA/dev/sda2 partition--83 20g/dev/SDA/dev/sda3 partition--82 4.0g/dev/SDA/dev/sda4 partition--05 1.0 k/dev/SDA/dev/sda5 partition--83 36g/dev/SDA device---80g-select the disk to be extended/ dev/sda2 need to execute the following command truncate-r net. qcow2 nett. qcow2truncate-S + 5G nett. qcow2 [[email protected] KVM] # virt-resize -- Expand/dev/sda2 net. qcow2 nett. qcow2 has been released since July 74%. there are already too many operating procedures available when there are too many other than resize operation completed with no errors. before deleting the old disk, carefully check that the resized disk boots and works correctly are successfully converted to [[email protected] KVM] # virt-filesystems -- long-h -- all-A nett. qcow2 name type VFS label MBR size parent/de V/sda1 filesystem ext4--200 m-/dev/sda2 filesystem ext4--40g-/dev/sda3 filesystem swap--4.0g-/dev/sda4 filesystem unknown -- 1.0 K-/dev/sda5 filesystem ext4--36g-/dev/sda1 partition--83 200 m/dev/SDA/dev/sda2 partition-83 40g/dev /SDA # has increased a lot. /Dev/sda3 partition-82 4.0g/dev/SDA/dev/sda4 partition--05 1.0 K/dev/SDA/dev/sda5 partition--83 36g/dev /SDA/dev/SDA device---80g-[[email protected] KVM] # qemu-IMG info nett. qcow2 image: nett. qcow2file format: qcow2virtual size: 80g (85899345920 bytes) disk size: 60gcluster_size: 65536316-resize can only expand the primary partition. /Dev/sda5 has changed to an extended partition and cannot be expanded directly. You can expand/dev/sda4, format the disk again, and partition again.


If any of you have any better or other methods, please do not hesitate to give me your advice.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.