I've been working on a special project.. one that requires the building of multiple virtual machines on the fly. My VM of choice (as seen in previous entries) is Xen.
Part of my requirements is the ability to have a base image of a root drive, then have each of the dynamic VMs have their own dynamic image based on the original. One, if they wanted to, and had the space - could just copy the drive image multiple times. And this would work.
Fortunately, there is a better way. Copy-on-write disks are disks that write changes from a base image to a separate file. Thus, reducing the overall usage. This is what I want.
Xen wiki has multiple solutions to doing this, however, I wanted something simple, and supported at the xen level. This left me with qcow files.
In order to save some people some time. I wanted to describe how I went about getting the images to work -- pain for me, means less pain for you in the long run.
To make a long story short:
Created a image with dd (see previous posts)
Made my changes to the image
used "qemu-img convert -O qcow2 (base-img) (qcow-img)" to convert the image to a base qcow format
built the actual qcow files with "create-qcow (image-size) (container-qcow) (qcow-img)"
Some notes:
When building your base image with dd - it CAN NOT be a spare file (meaning using the seek) it must be a full img
img2qcow does not work! (or at least it didn't for me)
Some errors you might see
Failed to write new L1 tableĀ (Usually after: Converting image to big endian L1 table)
Your using qcow files, not qcow2 - probably because you used img2qcow or -O qcow with qemu-img
QCOW Open failed
You may have used qcow-create, but referenced a raw image - not a qcow image.
XENBUS: Waiting for devices to initialise
One of your devices didn't init in dom0 - look at /var/log/syslog to find the error in your ways