Using qcow for your disk images
For the uninitiated, CoW stands for Copy on Write. Suppose you have to make two copies of something, creating a full copy could be expensive. So, what you do is, when you do a copy, just share the contents. When you modify one of the copies, only then a copy – Copy on Write. So, as you expect, this saves space.
So, what is qcow ? It’s Qemu CoW. Qemu is a open source virtual machine manager. QCoW is a disk image format which consumes disk space only when contents are actually written on it. So, a blank 5G disk image just consumes a few kilobytes of data. Cool you’d say. Wait! there’s more to it. You can create new disk images by basing them on existing ones. When you do this, only the deltas will be written to your new disk file and the base image is treated as read only.
Now, how is this useful ? – when you create many virtual machines. Suppose you have to run 100 virtual machines (that’s not unreasonable), with each disk image occupying 10G disk space. SO you’d need 1TB of storage ? Not with qcow. With a little more than 10G you can create 100 disk images as told above.
You can create disk images using an utility called qemu-img. You can also convert between various formats, and create cow qcow images.
The best part is, today even XEN suports qcow. But there’s a difference between the formats used by qemu and XEN. They are incompatible, and this gave me endless troubles yesterday. I converted a raw disk image to qcow using a utility called img-qcow. Now to create a new qcow image for use with XEN and which is based on the original qcow, i used qcow-create. It usage is simple.
Folks, if you want to use qcow within XEN make sure you
- Dont create qcow images using qemu-img
- Dont convert qcow-images using qemu-img
- Use only qcow-create and img2qcow utilities.
- Dont expect these qcow images to work with QEMU, and even XEN HVM.
Doesn’t XEN simply suck ? They’ve borrowed the qcow disk format and even its driver from QEMU and they’ve made it incompatibe with its source!