Creating a customized Ubuntu Live CD for OpenNMS trainings

ulf1 For the OpenNMS training at Unix User Group Frankfurt, we have the idea to create a custom Ubuntu Live-CD with OpenNMS preinstalled.

Such a CD would allow a quick start of the training and can be used from a CD, an USB stick and in a virtual machine.

The Ubuntu Customization Kit allows easy creation of remastered Ubuntu Live-CDs and is available from the Ubuntu Repository.

At first we have to install uck:

sudo apt-get install uck

As the remastering process requires a existing Ubuntu Live-CD, the current Live-CD must be downloaded from the ubuntu homepage.

We have chosen the classical x86 version, because we cannot guarantee, that all used notebooks are amd64 ones.

After downloading the base Live-CD image, we can start the remastering process.

The process will run in the ~/tmp directory. Ensure that there are no files in this directory, you will miss afterwards.

The following commands will unpack the base and create a chroot environmant, which can be modified. All changes done in this environment are available on our custom Live-CD afterwards:

sudo uck-remaster-clean
sudo uck-remaster-unpack-iso Downloads/ubuntu-12.10-desktop-i386.iso
sudo uck-remaster-unpack-rootfs
sudo uck-remaster-chroot-rootfs

At first, some required tools can should be installed:

apt-get install vim

To install OpenNMS on our Live-CD, The source list must be edited: /etc/apt/sources.list:

deb quantal main universe multiverse restricted
deb quantal-security main universe multiverse restricted
deb quantal-updates main universe multiverse restricted

The OpenNMS repository must be added to the source list: /etc/apt/sources.list.d/opennms.list:

deb stable main
deb-src stable main

To use the OpenNMS repository, the repositories PGP key must be downloaded and installed:

wget -O - | sudo apt-key add -

The system should be upgraded completely:

apt-get update
apt-get upgrade

The last requirement for OpenNMS is a running PostgreSQL server. It can be installed from the repository:

apt-get install postgresql

As the OpenNMS installation requires full access to the database. The most security concerns can be ignored, as this CD should be used for trainings only.

The file /etc/postgresql/9.1/main/pg_hba.conf must be edited to make PostgreSQL to trust all access:

 local   all             all                                     trust
 host    all             all               trust
 host    all             all             ::1/128                 trust

Now, the PostgreSQL server must be restarted for the OpenNMS installation:

service postgresql restart

As PostgreSQL in the default installation comes with the wrong encoding for the OpenNMS database, the encoding must be changed by recreating the template database:

su postgres -c psql
    UPDATE "pg_database" SET "datistemplate" = 'false' WHERE "datname" = 'template1';
    DROP DATABASE "template1";
    CREATE DATABASE "template1" TEMPLATE "template0" ENCODING 'UTF8';
    UPDATE "pg_database" SET "datistemplate" = 'true' WHERE "datname" = 'template1';

Now OpenNMS can be installed:

apt-get install opennms

Some additional installation steps must be done to make OpenNMS running:

/usr/share/opennms/bin/runjava -S /usr/bin/java
/usr/share/opennms/bin/install -dis

To make the Live-CD somewhat more comfortable for the training, some defaults should be changed. At first, a custom wallpaper can be downloaded:

wget -O /usr/share/backgrounds/free-software-ulf.jpg

To make the wallpaper available as default wallpaper, the file /usr/share/gnome-background-properties/ubuntu-wallpapers.xml must be edited:


And the wallpaper must be specified as default by editing the file /usr/share/glib-2.0/schemas/30_gnome-desktop.gschema.override:


To make the OpenNMS web interface, the welcome page of firefox, the file /etc/xul-ext/ must be created:


To make the changes effective, the file /etc/xul-ext/ubufox.js must be edited:

pref("browser.startup.homepage", "file:/etc/xul-ext/

And the example folder should be used for the user:

rm /etc/skel/examples.desktop

To clean up the list of applications in the quick start bar, the file /usr/share/glib-2.0/schemas/10_gnome-shell.gschema.override mus be edited:

 favorite-apps=[ 'firefox.desktop', 'evolution.desktop', 'gnome-terminal.desktop', 'nautilus.desktop', 'yelp.desktop' ]

After a schema override has changed, the changes must be compiled using the following command:

glib-compile-schemas /usr/share/glib-2.0/schemas/
As the Live-CD should not be used to install <em>Ubuntu</em>, the installer should be removed:
<pre lang="bash">
apt-get remove ubiquity

Most users prefer the gnome desktop. This should be installed and the unity desktop should be removed:

apt-get install ubuntu-gnome-desktop
apt-get remove ubuntu-desktop ubuntu-settings
/usr/lib/lightdm/lightdm-set-defaults -s gnome

The timezone used on the Live-CD should be configured for the target audience:

dpkg-reconfigure tzdata

To change the default keyboard layout, the file /etc/default/keyboard can be edited:


As last step, some cleanup must be down to shrink the size of the resulting image:

apt-get autoremove
apt-get autoclean
rm /etc/hosts
rm /etc/resolv.conf
rm /var/lib/dbus/machine-id
rm /sbin/initctl
dpkg-divert --rename --remove /sbin/initctl
rm -rf /tmp/* ~/.bash_history

Now we can exit the chroot environment:


To make a Live-CD from our changed chroot environment, the image must be packed using the following commands:

sudo uck-remaster-pack-rootfs
sudo uck-remaster-pack-iso opennms-training.iso

Now, the Live-CD is finished and ready to boot. The image can be found under ~/tmp/remaster-new-files/opennms-training.isoOne easy way to test the image is qemu:

qemu --cdrom ~/tmp/remaster-new-files/opennms-training.iso

To make additional changes to the chroot environment, the following command must be called again:

sudo uck-remaster-chroot-rootfs

After changing the chroot environment, the image must be recreated using the following commands:

sudo uck-remaster-pack-rootfs
sudo uck-remaster-pack-iso opennms-training.iso

Have a lot of fun!

Leave a Reply