I thought it would be good to create an OpenSUSE container on my Ubuntu LXC machine.

I am using the existing OpenSUSE template in /usr/lib/lxc/templates/lxc-opensuse, and some SUSE packages built by Thomas-Karl Pietrowski for Ubuntu from https://launchpad.net/~thopiekar/+archive/zypper, and the build scripts from https://github.com/openSUSE/obs-build

This is how you do it (tested with Ubuntu 12.04):

apt-get install python-software-properties
add-apt-repository ppa:thopiekar/zypper 
apt-get update
apt-get install rpm zypper libsolv-tools
wget -O obs-build.tar.gz https://github.com/openSUSE/obs-build/archive/master.tar.gz
tar xzf obs-build.tar.gz
mkdir -p /usr/lib/build
mv obs-build-master/* /usr/lib/build
 
# small fixes for the template to avoid some errors
sed -i 's/--non-interactive --gpg-auto-import-keys/--gpg-auto-import-keys/g' /usr/lib/lxc/templates/lxc-opensuse
sed -i 's#chpasswd#/usr/sbin/chpasswd#g' /usr/lib/lxc/templates/lxc-opensuse
lxc-create -t opensuse -n demoOpenSuse
lxc-start -n demoOpenSuse
# login with root and password root

Things still to be done:

The creation of the image is interactive, since there seems to be unknown keys:
File ‘content’ from repository ‘repo-oss’ is signed with an unknown key ”. Continue? [yes/no] (no): y
File ‘repomd.xml’ from repository ‘update’ is signed with an unknown key ”. Continue? [yes/no] (no): y

/usr/lib/lxc/templates/lxc-opensuse: line 110: patch: command not found

If there are problems with the root password, try this:
echo “root:root2” | chroot /var/lib/lxc/demoOpenSuse/rootfs /usr/sbin/chpasswd

I think the network is not established yet.

But hopefully this is a start…

Creating an OpenSUSE LXC container on Ubuntu 12.04
Tagged on: