Thursday, September 30, 2010

AutoYaST and Image Creation/Installation

In openSUSE 11.3 I enhanced the AutoYaST image installation feature a bit and I added a nice useable UI to configure it.
It's still quite beta because I was not able to test it the way I should have but I think that if you are interested in that topic, it's worth a look already.
Let's start immediately and create an AutoYaST image with the UI.

Step 1 - make the openSUSE Installation Source available


taylor:~ # mount /dev/dvd /mnt

I simply mount the openSUSE 11.3 DVD here to the /mnt directory.

Step 2 - start the AutoYaST UI


taylor:~ # yast2 autoyast

When the UI is started, go to the software selection configuration. You'll be asked where the installation source is you want to use.
As you can see in the screenshot, I set the installation source to the mounted DVD by "file:///mnt/".

Hint: You can't create 64bit images on a 32bit system but 32bit images on a 64bit system

Step 3 - select your software for the image


I selected the base pattern and the kernel I want (don't forget the kernel. Linux is no fun without a kernel).




Select okay to return to the main UI when you have selected all the software you want to have in the image.
You probably want to configure anything non image related now, like root password, partitioning, ...

Step 4 - Create the Image





Choose "Image Deployment" in the AutoYaST UI and configure the location of the image. That's where AutoYaST can find it during the installation process.
I want to do a network installation and I'll put the image on my webserver and so I type the http address here.
As you can see in the screenshot, you can also create an ISO. Then you don't have to specify a name and the location, because a DVD ISO will be created that contains the image and the autoyast XML file plus everything you need to do an installation from the ISO by booting it.
Creating an ISO is probably easier in the beginning if you want to play with this feature.

Step 5 - Choose the location to store the image


I'll store it to /srv/www/htdocs/ because that's the document root of my webserver. Like mentioned in step 4, I'll fetch the image from my webserver.



If you create an ISO, you have to choose where to save the ISO now.

Step 6 (optional) - make changes to the image





AutoYaST will now create the image and you can do changes to it when all patterns and packages are installed. You can see that in the screenshot.
So if you want to put any files into the image, you can copy them now to the place shown in the popup, which is a directory that contains the system that will later be dumped to you harddisk. You can even chroot into that directory and let scripts run if you want.
This step is optional, so if you don't want to add files or anything, you can simply press "ok" here to compress the image.

Now you are done with the image creation. Let's take a look at what we have in the XML file now:

...
<software>
<image>
<image_location>http://taylor.suse.de/</image_location>
<image_name>my_image</image_name>
<run_kickoff config:type="boolean">true</run_kickoff>
<script_location>file:///usr/lib/YaST2/bin//fetch_image.sh</script_location>
<script_params config:type="list">
<listentry>http://taylor.suse.de//my_image.tar.gz</listentry>
</script_params>
</image>
<instsource>file:///mnt/</instsource>
<packages config:type="list">
<package>kernel-desktop</package>
</packages>
<patterns config:type="list">
<pattern>apparmor_opt</pattern>
<pattern>base</pattern>
<pattern>yast2_install_wf</pattern>
<pattern>sw_management</pattern>
<pattern>apparmor</pattern>
</patterns>
...


The XML file is prepared for an installation of the image. The fetch_image.sh is part of AutoYaST since openSUSE 11.3 and will fetch and unpack the image after the partitioning is done. That's why we can use "file:///" here, because autoyast will find it as it's part of the autoyast2-installation RPM.
You can replace that script by anything you want that can fetch and unpack the image. So if you have a complete different image type, you can write your own script to fetch and unpack the image. Of course if you have a different kind of image, you can't use the AutoYaST UI anymore to create it. AutoYaST will always create a tar.gz file that contains the installed system.

Installing images via AutoYaST has three major benefits compared to the RPM installation step:

  • multiple times faster

  • post-configuration can be done in the image instead of after the installation

  • very easy switching between image installation and RPM installation (with rules, even dynamically when starting the installation)


You can install images without losing any of the AutoYaST functionality. Ask-dialogs, all kind of scripts (even pre-scripts), complex partitioning and so on is still possible because only the slow RPM installation step is skipped and replaced by putting an image to the harddisk while you have all kinds of flexibility of how that image is created.

As mentioned in the beginning of this article, I had not enough time to test this through but if you are interested in it feel free to play with it and report feedback to me if anything fails or can be enhanced :)

Have fun!

ciao, Uwe

8 comments:

Anonymous said...

Nice Feature, but why not lzma instead of gz?

Uwe Gansert said...

Yes, good point, I'll look into that when I find the time.
The type of the image is very flexible, because you can configure the script that fetches/uncompresses the image.
So a switch to another compression should be no big deal.
But lzma as default is a good idea I think.
Thanks.

Jos Poortvliet said...

Nice tutorial! I see you co-wrote the guide on AutoYaST (http://www.suse.com/~ug/autoyast_doc/index.html), will you update it with this blog's stuff?

BTW no idea how to do it but it might be good to set the language of this blog to English - I can find my way reasonably well but some might not...

Uwe Gansert said...

yes, actually I update toe documentation immediately when I have a new feature but in this case it was too experimental for me in the current state.
I'll document it officially when it's stable.

Thanks for the feedback. I changed my blod settings to english :)

Anonymous said...

Is this only for openSUSE ? SLES 11 SP1 ?

Uwe Gansert said...

the feature like described here in the blog is only on openSUSE 11.3 (the GUI).
I started to experiment a bit with imaging on SLES11 SP1 already. Read this article I wrote back then if you are interessted:

click

but that's experimental.

Anonymous said...

I tried this on OpenSuse11.3-i586. The Image built OK but after that the XML file was not updated as to the location of the image and the the shell script to deliver it. Is this something that has to be changed by hand?

John D said...

For some reason, autoyast2-installation does not get included on the image, so my autoyast scripts never run.