Cloud

Disk image creation with Oz

The Oz tool allows an automatic disk image creation working on Linux OS. Virtual machines or physical hosts can be used for the process.

Description

  • create JEOS (just enough operating system) guests with minimal input.
  • need KVM + Libvirt.
  • use a predefined set of kickstart/preseed file.
  • working on VM.

Working

  1. Download the installation media.
  2. Generate an automated installation file (e.g. kickstart, preseed, etc).
  3. Generate a modified installation media that includes the installation file.
  4. Run the native installer in a KVM (or Qemu) guest.
  5. At the end of installation, shutdown the guest.

Installation

  • Linux packages:
$ yum install oz libguestfs-tools virt-manager virt-viewer eog

Configuration files

Configuration files for CentOS 6.

  • Oz configuration:
[paths]
output_dir = /var/lib/libvirt/images
data_dir = /var/lib/oz
screenshot_dir = /var/lib/oz/screenshots
# sshprivkey = /etc/oz/id_rsa-icicle-gen

[libvirt]
uri = qemu:///system
image_type = raw
#type = kvm
bridge_name = virbr0
cpus = 1
memory = 1024

[cache]
original_media = yes
modified_media = no
jeos = no

[icicle]
safe_generation = no
  • Oz TDL (template definition language):

A simple XML type file.

<template>
 <name>CentOS-6-Server-x86_64</name>
 <description>CentOS 6 Server x86_64</description>
 <os>
  <name>CentOS-6</name>
  <version>6</version>
  <arch>x86_64</arch>
  <install type='iso'>
        <iso>file:///root/Oz/CentOS-6.6-x86_64-minimal.iso</iso>
  </install>
 </os>
 <disk>
  <size>5</size>
 </disk>
</template>

Kickstart/Preseed files

  • Kickstart:

Automatic installation file for Red Hat family.

install

# Use network installation
url --url "http://mirror.centos.org/centos/6/os/x86_64/"

# Additional repositories
# Install epel-release package from
repo --name="extras" --baseurl=http://mirror.centos.org/centos/6/extras/x86_64/

# Install stratuslab-contextualization package from
repo --name="StratusLab" --baseurl=http://yum.stratuslab.eu/releases/centos-6/ --cost=5000

...

# Packages
%packages --nobase --ignoremissing
-selinux-policy-targeted
%end
  • Preseed:

Automatic installation file for Debian family.

#### Contents of the preconfiguration file

### Localization
d-i debian-installer/locale string en_US

# Keyboard selection.
d-i console-setup/ask_detect boolean false
d-i console-setup/layoutcode string us

...

### Finishing up the installation
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note

Oz commands

  • Disk image creation:
$ oz-install -d 3 -t 10000 -p -c ~/Oz/oz.cfg -x centos6.xml -a centos.ks -u oz.tdl 
  • Check the disk image state:
$ eog /var/lib/oz/screenshots/CentOS-6-Server-x86_64-*.ppm