Kiwi Imaging System - Forge your own operating system images in a matter of hours

Updated: May 22, 2009

Would you like to be able to create custom, ready-to-use operating system images that can be used as VMware images, Xen virtual machines or live DVDs or booted from USB sticks? Would you like to be able to convert your physical installation into a deployable image? Would you like to be able to do all of the above in a matter of hours, without dabbling with the command line, just following a simple visual wizard? If the answers are one big yes, then you're reading the right article.

Teaser

Introduction

There are many ways to achieve this, none as complete and powerful as Kiwi.

Kiwi is one of the tools used by the openSUSE Build Service, a complete distribution development platform that allows you to create and release software for openSUSE and other Linux distributions. Kiwi focuses on openSUSE itself, allowing you to do the following:

We've already seen most of these cool tricks done:

Still, some of these phenomenal solutions did not provide us with everything we need. For instance, Remastersys does not create virtual machines, only images that you can use to install as guest operating systems. But this requires extra work and user interaction. Amazon conversion was neat, but this was mainly a command-line work, with quite a few preparatory steps and lots of user interaction. VMware Converter provided us with an almost the entire solution that we need here. Kiwi can do all these - and then some. I hope I've whetted your appetite. Let's see what this power beauty can do.

Prerequisites

One thing that you will have to do before using Kiwi is to have openSUSE installed, version 10 and above. I've covered the installation and configuration of openSUSE on two separate occasions, in extensive, step-by-step tutorials: Installing SUSE Linux is an older article; it covers openSUSE 10.1, focusing on the basic concepts, the functionality of the KDE desktop, security features, and other configurations. openSUSE 11 - Review & Tutorial is a much more thorough, complete article, covering stuff like live CD experience, Wireless, Compiz, multimedia codecs, installation of additional repositories, installation of graphic card drivers, including ATI, installation of games, and more.

SUSE install 1

SUSE install 2

You're welcome to take a look at these two tutorials. They should help you get started with openSUSE. Once you get openSUSE installed, you can move on to Kiwi.

Install Kiwi

First thing, you'll need to install Kiwi through YaST. There's a huge list of Kiwi packages available. We want them all.

Install

But this is only a part of the puzzle. We will also need another utility installed. It's called Product Creator (product-creator). This utility contains two modules, one called the Image Creator and the other Product Creator.

Image Creator, with the lovely kiwi fruit logo, is exactly as its name implies - a GUI wizard for using Kiwi and creating images. Just what we need. Product Creator allows you to convert existing installations into new, installable distributions. Again, what we need.

Kiwi image creator

However, in this article/tutorial, we will only work with Image Creator. We'll see how to use Product Creator in a separate article. We will also mention another powerful build utility, called SUSE Studio. But that's for later. For now, we need Image Creator. It can be found under YaST > Miscellaneous.

Using Kiwi

The first time you start Image Creator, you'll get to a blank configuration menu.

Main

To create a new configuration, click Add.

Image preparation

Now, you need to decide what you want to do. You can use an existing configuration, but we don't have that, so we will use the first option: Create from beginning.

Preparation

The next thing is to choose the Image Type. This is very important, as it determines the final output.

Image type

Live ISO Image is probably the most flexible option, as it allows you install the disk anywhere.

Xen Image is meant to be used with the Xen virtualization software, which, by the way, is officially supported by Novell and comes included with the distribution. You can access the virtualization module via YaST > Virtualization.

USB Stick Image is intended for use with USB devices.

Virtual Disk Image includes a range of formats, including both the .raw and .vmdk file for QEMU and VMware, respectively. You should pay attention to this, because the output will contain several images, not just one, so the size demand will be significant.

On a side note, please note that the background color in the image above is identical to the one I use on my site. A pure stroke of luck/genius coincided that both SUSE and myself would be using the same color. Go figure.

The space demand brings us to Output directory. Make sure you have sufficient free space on the disk to accommodate the images. If you're planning on a 2GB virtual disk image, for instance, the final result will be at least 250% more. Make sure you don't run out of free space, especially if the destination directory is on the same partition as your root, as you might chose the machine.

The default destination is /tmp.

The Package Repository section includes the list of all repositories you want to use to download packages from in the building of your image. The more repositories you have, the more choices for software you'll have. Make sure the repositories are not broken and that they are properly signed, so you don't encounter problems later on.

Virtual Disk Image

The next step is to configure the image itself - what it should contain and do. This is a five-step process. The first sub-stage is to choose the version and size of the image. Once again, plan accordingly to your space restrictions, if any.

Then, choose the packages you want to include.

Image config 1

Description is as the name implies. It's useful for revision control. 

Description

Next comes the list of valid users. By default, you'll have root (with no password) and a generic linux user. You can edit them as you see fit, add more users or delete existing ones.

Users

The fourth stage are the image building scripts. Power users can add anything they like here, including custom network or service configuration scripts, cleanup scripts, etc. If you're not sure what to do, leave this section be, as is.

Scripts

The last step is to choose the directories containing system configurations. Again, if you're not sure, leave the default options. In general, this section allows you to include additional image-building scripts, based on your needs, but they are not required to get the image built and working.

Directories

Once you complete this stage, click Finish. You will be asked to confirm your choices:

Create

Create directory

And the process will begin. Depending on the size of your image and your connection speed, this can take a bit. In my case, the image was ready after approx. 3 hours.

Working

Success

Image created

Test image

Now comes the big moment, testing the whole thing. After a job like this runs for a few hours, you begin wondering whether the end result will actually work. Let's find out.

First, the contents ...

Please note that in the screenshot below, the path to the image files is not /tmp. This is because I moved the images to another partition (/mnt), to gain performance when testing, one of the tips I usually recommend when working with virtualization products.

Contents

There are quite a few files in the directory, including .raw and .vmdk images, both 2+ GB in size, and some additional files, like VMX boot vmlinuz and initrd files. Like I said, the end result is much bigger than the intended allocation.

We're interested in the .vmdk file. But we could also use the .raw file with QEMU and even convert it to AMI format, if we wanted to use it with Amazon EC2.

Create virtual machine

The first step is to create a virtual machine, for example, in VMware Server.

Choose disk

Start virtual machine

And here we go, the virtual machine is ready:

VM ready

And it's booting:

Booting 1

Booting 2

And it's running:

Running

Superb! Our task was a great success.

Other stuff

Kiwi is highly flexible and depends on XML configuration files to work. This means that you can script your image creation procedures, without having to rely on the wizard every time. Necessarily, the use of the command-line tools is mainly intended for more advanced users, who require a more granular control and better automation of their image building.

The official documentation also explains how to create a range of other images, including PXE thin installs and OEM preload systems, in addition to the usual set of images we have already covered. Best of all, examples are included.

We will talk about this some more in a separate tutorial.

Conclusion

In this article, we've only touched the power of Kiwi - and that of the Build Service. Nevertheless, there is no denying the simplicity, beauty, power, and flexibility of the Kiwi package.

It allows you to create a wide range of custom images, test and deploy them in a wide range of scenarios, without bothering with grueling command-line work normally entailed in such endeavors, although Kiwi does support automated use through XML configuration files.

Kiwi does all this using friendly, easy to understand menus. You don't have to be a system expert to get Image Creator working and baking all manner of images for you, whether you want to use them in Xen, VMware Server or deploy them remotely in the Amazon Cloud. The incredible potential is simply dazzling.

If you didn't feel like using openSUSE as your primary desktop distro, I recommend you think again. Should you needs ever cross into the real of virtualization, Kiwi is probably the most complete business-like platform for quick, massive deployments and testing of images. In the sequel tutorials, we will talk about Product Creator and SUSE Studio. Stay tuned.

Cheers.