编译服务/KIWI/XEN镜像

Jump to: navigation, search

Susemini.png 本文处于需要翻译的文章的状态,欢迎您积极参与翻译与修订。 翻译人员:无,修订人员:无。

This page will hold information on how to create XEN images with the kiwi system.

It's not correctly formatted, and there are some issues with this setup at the moment, so please do not publish!

It would seem that these instructions don't work any more for the current versions of wiki (1.64.22) Simoncrute 15:14, 6 November 2007 (UTC)


kiwi for XEN

These instructions will guide you show you how to create XEN images with kiwi. For this, two machines are being used, both of which have SUSE Linux Enterprise Server 10, SP1 (RC1) installed. One of the machine have XEN enabled (xen-sles), the other one will be used for kiwi (kiwi-sles).

The machines are standard installs.

Step 1

First thing is to install the kiwi tools onto kiwi-sles

  • Add the following installation source;
 http://ftp-1.gwdg.de/pub/opensuse/repositories/smart/SLE_10/
  • Then install the following packages;
    • perl-XML-LibXML
    • perl-libwww-perl
    • smart
    • gcc
  • In a terminal, run the following command;
 rpmbuild --rebuild kiwi-1.21-25.1.src.rpm  (This will take a while to complete)
  • Go to /usr/src/packages/RPMS/i586 then run;
 rm kiwi-desc-livesystem-1.21-25.1.i586.rpm
 rm kiwi-desc-vmxboot-1.21-25.1.i586.rpm
 rpm -Uhv *.rpm

The reason for deleteting the above rpm's is that they require squashfs and qemu, which currently is not available on SLE10.

Congratulations! This completes step 1.

Step 2

Now it's time to actually create an image. We will create an xen image of SLES10-SP1

  • Go to /usr/share/kiwi/image and run;
 cp -a buildhost-suse-10.1 sle10
 cd sle10
 mkdir root/image
 cp -a repo root/image
  • Edit config.xml and change;
 <type>ext3</type> to <type>xen:ext3:xenboot/sle10</type>
to reflect your repository
 <packages type="xen"> to <packages type="xen" disk=”/dev/hda” memory=”512”>
  • Save the file, then go to /usr/share/kiwi/image/xenboot and run;
 cp -a suse-10.2 sle10
 cd sle10
  • Edit config.xml and change;
to reflect your repository
  • Add the following section;
 <repository type="rpm-dir">
 </repository>
  • If you are using SLES10SP1 (RC1) and kiwi 1.21-25, please go to Known Issues and resolve them before proceeding.
  • Now run the following commands;
 cd /usr/share/kiwi/image
 kiwi --prepare sle10 --root /tmp/sle10
 kiwi --create /tmp/sle10 -d /tmp

Customizing

The image created in the above example will not be of much use. It uses a simple example that comes with kiwi. There are several way to customize it so that it installs the packages you want. Perhaps the easiest way is to actually do a proper install of a virtual machine, then copy the config from there.

Having built a virtual SLES10SP1 (RC1) server in XEN, the following is an easy way to extract the packages;

 rpm -qa --queryformat "\<package name=\"%{NAME}\"/\>\n" >rpms.txt

That will produce a list of all rpm's installed in the following format;

 <package name="kernel-xen"/>

You can then simply open up the /usr/share/kiwi/image/sle10/config.xml file and paste the content of rpms.txt in between the following two tags;

 <packages type="image">
 </packages>

More ways of customzing the install is to copy files you want to have in the install to /usr/share/kiwi/image/sle10/root. Everything in that directory will be copied to the image AFTER all the rpm's have been install. You can see that it is possible to use a directory structure and it will be copied exactly as it is seen there.

Known issues

With the version of kiwi listed here, there is a known issue getting the xen image to actually run on SLES10SP1RC1. To work around this issue, 3 files needs to be modified;

  • /usr/share/kiwi/modules/KIWIImage.pm
  • /usr/share/kiwi/image/xenboot/suse-linuxrc
  • /usr/share/kiwi/image/sle10/config.xml

Changes to KIWIImage.pm

Open the file up in an editor and do a search for buildXenConfig

Find the following two lines;

 my $device = $xenconfig{disk}."1";
 my $part   = $device;

Change it to;

 my $device = $xenconfig{disk};
 my $part   = $device."1";

Then find the following line;

 print FD 'root="'.$device.' ro"'."\n";

Insert the following line just after that one with the following content;

 print FD 'extra=" xencons=tty "'."\n";

Changes to suse-linuxrc

Find the following line;

 for rdevice in /dev/hda1 /dev/sda1; do

Modify it so that it becomes;

 for rdevice in /dev/hda1 /dev/sda1 /dev/hda /dev/sda; do

Changes to config.xml

Find the following line;

 <compressed>yes</compressed>

Modify it so that it becomes;

 <compressed>no</compressed>