Can i shrink the image file size?
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.
You can create another smaller disk image and with help of losetup,kpartx and ntfsclone
clone the ntfs data to the new image.
Quoted 10 lines · John Wong
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.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
2009/3/21 John Wong <[email protected]>:
Quoted 3 lines
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?
It's not possible to directly reclaim the unused space (qemu is not aware of what is used and what is not); a workaround is first filling the unused space with zeros (using sdelete -c) and then compressing the image with qemu-img convert -c; the side effect of sdelete is that the image will grow to the limit of 30G, but then the empty space will be highly compressible.
The alternative is dumping the FS and restoring it on a new image as suggested by Piavlo.
Luca
Quoted 5 lines · John Wong
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.
qemu-img convert -c -O qcow2 source.img target.img
Signature · 2 lines
Ross McKay, Toronto, NSW Australia "There is more to life than simply increasing its speed." - Gandhi
Quoted 8 lines · Ross McKay
Quoted 5 lines · John Wong
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.
Quoted 4 lines
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
Signature · 4 lines
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
Quoted 3 lines · John Wong
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?
I wrote a simple utility in .Net 2.0 that creates a file in Windows with all 0's until the drive is full, then deletes it. This allows qemu-img to recreate the image and reclaim any sectors that are all 0's. This is what I do:
1. Defragment the Windows drive(s). Run the defragmenter at least 3 times to make sure you get good results.
2. Run my tool (http://mel.byu.edu/zerofill.exe). It will automatically detect all drive letters, create a file filled with zero's and delete it whn it's done. Make sure the VM is not under a lot of use or the continually decreasing amount of disk space may interfere with whatever may be running.
3. Run qemu-img and recreate the virtual drive with the same format parameters. For example, if your image is in qcow2 format you run:
qemu-img convert -O qcow2 win_xp.img win_xp.img.new
4. Rename win_xp.img to win_xp.img.old and win_xp.img.new to win_xp.img. Run your VM and make sure everything works. If it does, remove win_xp.img.old and go on with life.
I would recommend you back up your drive image before your start the first couple of times, just to be sure. It's not fun when you screw up and can't get back into your VM. I've done that a few times while developing this technique. :-)
Quoted 2 lines · Alberto Treviño
I wrote a simple utility in .Net 2.0 that creates a file in Windows with all 0's until the drive is full, then deletes it.
Like this?
SDelete:
http://technet.microsoft.com/en-us/sysinternals/bb897443.aspx
Quoted 4 lines
This allows qemu-img to recreate the image and reclaim any sectors that are all 0's. [...]
qemu-img convert -O qcow2 win_xp.img win_xp.img.new
Thanks, and to Matthew Palmer; this is a big help in reclaiming qcow2 file size.
Signature · 2 lines
Ross McKay, Toronto, NSW Australia "Nobody ever rioted for austerity" - George Monbiot