Re: Can i shrink the image file size?

Matthew Palmer
2009-03-22T04:30:00Z

On Sun, Mar 22, 2009 at 12:12:13PM +1100, Ross McKay wrote:
> John Wong wrote:
>
> >I create the 30G qcow2 image file, installed winxp, winxp show me the
> >harddisk used 5G, but the image file size is 12G now.
> >can i shrink the image file size? how?
> >my kvm version is: "kvm-84", qemu version is: "0.9.1".
> >please help, thank you.
>
> In addition to what the others said, you might be able to reclaim some
> space by running qemu-img convert. If you tell it to compress, it will
> certainly reduce the image file size, perhaps with a little loss in
> performance.

The problem there is that qemu-img convert will only save space where the
blocks are zeroes, and most filesystems don't zero blocks when they're
freed, so not much space is actually saved.

I'm working on a tool at the moment that understands various filesystem
formats and doesn't copy the non-zero freed blocks either. It's only
working for swap partitions at the moment, but once I get up to speed on how
ext2/3 works I'll have that sorted. I guess I should announce it here once
I get ext2 support working now that there are people here who care...

- Matt

--
MacOS X ... [is] enough of a bother to luse it if you've progressed past the
"ooh, click on the shiny little picture!" stage, if you try to treat it as a
serious OS, then it really gets out the little tricycle wheels and the toy
horn that goes "onk! onk!" -- Dave Brown, ASR