Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Like the title says: Is it possible to resize a QEMU disk image in Linux? And if so, what happens to the partitions within it? Are they automatically resized as well (doubtful) or is there just a new block of unused space following them?

share|improve this question
up vote 12 down vote accepted

From here:

!!! Back up your disk image before trying the below !!!

If you are using a sparse raw image, then do

dd if=/dev/zero of=hdd.img seek=N obs=1MB count=0"

where hdd.img is the raw format image that you want to resize and N is the new size that you want the image to be, in megabytes. To change the units of N, change obs to something else such as 1GB for units in gigabytes (1000x1000x1000).

If you want to resize a raw image but you do not want it to become sparse (you actually want those zeros in the file) then do "dd if=/dev/zero of=image seek=S count=N-S obs=1" instead, where N is the new size and S is the old size (in bytes).

If you want to resize a qcow2 image, this is not yet supported.

this email shows some experimenting with resizing qcow images with a hex editor.

Resizing or growing images in other formats (VMware, Bochs, cow, or cloop) is not supported to the best of my knowledge.

On a Windows host it is possible to resize a raw format disk image using the 'copy' command. You can use qemu-img to convert your existing image to raw format if need be. We will use a temporary raw format disk image that will be appended on to the end of your existing raw format disk image. The size of this temporary image is the size the existing image will be expanded by:

qemu-img create -f raw temp.img 300M

You should then issue the below command - orig.img is your existing raw format image that you want to make larger, temp.img is the temporary image file created earlier, and new.img is the resized resultant image:

copy /b orig.img+temp.img new.img

You will then need to repartition and resize the existing partition(s) and filesystem(s) on the new image. One method of doing this is to boot gparted in QEMU with the gparted livecd iso and the new disk image.

Other links you might want to check out if the above doesn't work:

share|improve this answer
+1 For detailed answer. – BinaryMisfit Aug 18 '09 at 19:29

A qcow2 image can be resized to grow with a new/current version of qemu. For example, i have a arch.qcow2 thats 2G and I want it to become 50G, in that case i type:

qemu-img resize arch.qcow2 50G

then qemu tells me:

image resized

thats it, I just did this today. redhat actually has some nice docs on qemu:

share|improve this answer
However, the space increased will be unnallocated. You will need to resize your virtual disk using some partition tool. – Yamaneko Feb 28 '13 at 20:28
Excelent, solution! – RckLN Aug 8 '13 at 15:28
qemu-img version 1.0 tells me qemu-img: This image format does not support resize – HDave Feb 11 '14 at 17:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .