In the first part of this series about using base images to be more productive, I discussed how you can use base images to build template disk images from which you can create copy on write clones. As a natural follow up to creating your clones, at some point you’ll want to update your base images with patches or applications that is a better starting point for a clone. Regardless of how well you planned your base images, you may find that you need to update your base images to minimize additional installation on your clones. You can achieve this by “rebasing” your disk images.
Simply put, rebasing is the process of merging your current clone with your base image to create a new base image file that is completely different and independent from your original base image. You new base image will not have any dependency on your original base image and can be used for creating new clones. I think it’s good idea to always keep a base image with a pure install and additional rebased images for different purposes. For example, in a desktop environment one rebased image can be used for marketing department, another for customer service etc all built by merging different clones with an original single install base image. Rebasing can save you loads of time.
Now that you understand what a rebased image is, let’s create one. I’ll use the same image names from the first part of the series for continuity. In order to rebase your image you only need to issue one single command. The command follows.
qemu-img convert windows-clone.qcow2 –O qcow2 windows-marketing.qcow2
That’s it. Your windows-marketing.qcow2 will be a new base image completely independent from the original base image (windows-master.qcow2) used to create windows-clone.qcow2. It will be a merge of the windows-clone.qcow2 and the original windows-master.qcow2 images from the original post. This means that even if you destroy your windows-master.qcow2, your new rebased image will not be affected since there’s no dependency.
You now know what a rebased image is and how to create one. It only involves running a single command. Rebasing images can save you time by allowing you to create repurposed base images that you can use to deploy quickly and easily. In the next and last part of the series , I’ll explore another option recently added to qemu-img and how it might be used.