RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 952974 - qemu-img resize of a qcow2 image file does not work for reducing the size
Summary: qemu-img resize of a qcow2 image file does not work for reducing the size
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm
Version: 6.4
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Virtualization Maintenance
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-04-17 05:32 UTC by nigil
Modified: 2013-04-17 20:01 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-04-17 20:01:53 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description nigil 2013-04-17 05:32:10 UTC
Description of problem:
Reducing the size of a qcow2 image does not work with qemu-img resize command.

Version-Release number of selected component (if applicable):
# rpm -qa | grep qemu
qemu-img-0.12.1.2-2.355.el6.x86_64
gpxe-roms-qemu-0.9.7-6.9.el6.noarch
qemu-kvm-tools-0.12.1.2-2.355.el6.x86_64
qemu-guest-agent-0.12.1.2-2.355.el6.x86_64
qemu-kvm-0.12.1.2-2.355.el6.x86_64

# lsb_release -r
Release:        6.4

How reproducible:
100%

Steps to Reproduce:
1. Create a qcow2 image in an NFS mounted volume.
2. Increase the size using qemu-img resize. See the size changed.
3. Reduce the size of the image using qemu-img resize. This operation Failed with error message "qemu-img: This image format does not support resize". 


  
Actual results:
Could not Reduce the size of the image using qemu-img resize

Expected results:
Should reduce the size of the image using qemu-img resize.

Additional info:
# qemu-img create -f qcow2 qcow2file1.img 10G
Formatting 'qcow2file1.img', fmt=qcow2 size=10737418240 encryption=off cluster_size=65536

# qemu-img info qcow2file1.img
image: qcow2file1.img
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 140K
cluster_size: 65536

# ls -l qcow2file1.img
-rw-r--r--. 1 root root 262144 Apr 17 10:31 qcow2file1.img

# qemu-img resize qcow2file1.img +10G
Image resized.

# qemu-img info qcow2file1.img
image: qcow2file1.img
file format: qcow2
virtual size: 20G (21474836480 bytes)
disk size: 144K
cluster_size: 65536

# qemu-img resize qcow2file1.img -10G
resize: invalid option -- '1'
qemu-img version 0.12.1, Copyright (c) 2004-2008 Fabrice Bellard
......
Supported formats: raw cow qcow vdi vmdk cloop dmg bochs vpc vvfat qcow2 qed parallels nbd blkdebug host_cdrom host_floppy host_device file

# qemu-img resize qcow2file1.img 10G
qemu-img: This image format does not support resize

# qemu-img resize qcow2file1.img +-10G
qemu-img: This image format does not support resize

# qemu-img resize qcow2file1.img +10G^C

# qemu-img resize qcow2file1.img +10G
Image resized.

# qemu-img info qcow2file1.img
image: qcow2file1.img
file format: qcow2
virtual size: 30G (32212254720 bytes)
disk size: 144K
cluster_size: 65536

# qemu-img resize qcow2file1.img -5G
resize: invalid option -- '5'
qemu-img version 0.12.1, Copyright (c) 2004-2008 Fabrice Bellard
Supported formats: raw cow qcow vdi vmdk cloop dmg bochs vpc vvfat qcow2 qed parallels nbd blkdebug host_cdrom host_floppy host_device file

Comment 1 juzhang 2013-04-17 05:39:27 UTC
Currently,  Seems qcow2 can not support shrink. Raw format support.

Comment 2 nigil 2013-04-17 05:46:32 UTC
Thanks. The same has been said in 
https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Virtualization_Administration_Guide/sect-Virtualization-Tips_and_tricks-Using_qemu_img.html
But I think we should have this feature for qcow2 format also as mainly qcow2 images are used for thin-provisioning. Please update the inclusion plan for this and close the bug.

Comment 4 Ademar Reis 2013-04-17 20:01:53 UTC
(In reply to comment #2)
> Thanks. The same has been said in 
> https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/
> 6/html/Virtualization_Administration_Guide/sect-Virtualization-
> Tips_and_tricks-Using_qemu_img.html
> But I think we should have this feature for qcow2 format also as mainly
> qcow2 images are used for thin-provisioning. Please update the inclusion
> plan for this and close the bug.

Unfortunately qcow2 doesn't support resize and in this case you should either use raw or convert the image to a new one (the effective way to resize a qcow2 image).

Indeed, it's a nice feature to have. Note taken, but closing the bug as WONTFIX because we don't have any plans to support it yet.


Note You need to log in before you can comment on or make changes to this bug.