LXC Linux containers on JiffyBox running CentOS on Ubuntu   January 18th, 2014

This post covers several topics at once:

I have got some experience with OpenVZ, and was looking how LXC could satisfy the requirements that I am used to. Especially how to install several Linux distributions on one LXC host. I will show how to install CentOS, Ubuntu, and Debian Wheezy on a Ubuntu LXC container.

The other issue is that I wanted to play with a virtual machine called JiffyBox provided by DomainFactory.

Let’s look first at how to configure the JiffyBox, before we configure the LXC containers:

This post on the web Linux Containers (lxc) in Linode (xen)  helped me to understand how LXC works fine on a JiffyBox.
With the default kernel from JiffyBox, lxc-checkconfig shows that some requirements for LXC are missing.
JiffyBox allows you to start from a custom kernel. Now I was looking for a fitting kernel to install.
I have no idea how to do that on CentOS, but on the mentioned blog I found that Ubuntu can easily install a kernel that works fine for virtualization.

So you install a 64 bit Ubuntu JiffyBox, and then run these commands to setup LXC:

apt-get install lxc linux-virtual

After that, in the admin website of JiffyBox, select the custom kernel Bootmanager 64 Bit (pvgrub64); see also the german JiffyBox FAQ. Then restart your JiffyBox.

After the restart, uname -a should show something like:

Linux j80074.servers.jiffybox.net 3.2.0-58-virtual #88-Ubuntu SMP Tue Dec 3 17:58:13 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Now we will install some virtual machines:

First an Ubuntu 12.04 (precise) machine, which should work without any problems:

lxc-create -t ubuntu -n demo1
lxc-start -n demo1

You can login with username ubuntu, and password ubuntu. To get out of the machine, you type shutdown -h now.

To make the machine start at boot time, and to visit the console once the machine is running, type this:

ln -s /var/lib/lxc/demo1/config /etc/lxc/auto/demo1.conf
lxc-console -n demo1

By the way: you find the templates in /var/cache/lxc/, and the containers in /var/lib/lxc/.

For Debian, there is a template in directory /usr/lib/lxc/templates, but that is for Debian 6 (Squeeze). You need to slightly modify the template, so that Debian 7 (Wheezy) is installed. See my gist for that: Debian Wheezy template file

wget https://gist.github.com/tpokorra/8488744/raw/f1d050704e8cc8c70dd956eb18e6374d70f8ecf6/lxc-debian-wheezy
mv lxc-debian-wheezy /usr/lib/lxc/templates/lxc-debian-wheezy
chmod a+x /usr/lib/lxc/templates/lxc-debian-wheezy
lxc-create -t debian-wheezy -n demo2

You can login with username root and password root.

For CentOS, I have modified an existing Gist, so that it works for the latest CentOS 6.5. You might to check the latest differences in the revision, to adjust the script to future releases of CentOS. Have a look at my gist for lxc-centos.

wget https://gist.github.com/tpokorra/8488836/raw/dbcd0920c1b9047da707c318190959cf64d72f7c/lxc-centos
mv lxc-centos /usr/lib/lxc/templates/lxc-centos
chmod a+x /usr/lib/lxc/templates/lxc-centos
apt-get install yum
lxc-create -t centos -n demo3

You can login with username root and password password.

Tags: , ,
This entry was posted on Saturday, January 18th, 2014 at 12:23 pm and is filed under Software Development. You can follow any responses to this entry through the RSS 2.0 feed.Both comments and pings are currently closed.

5 Responses

March 14th, 2014 at 3:24 pm
peace Says:

Please I having the following issue creating the centos template on elementary os 32 bit : –

error: /var/cache/lxc/centos/i686/6/partial/centos-release-6-5.centos.i386.rpm: not an rpm package (or package manifest):

March 15th, 2014 at 9:27 am
Timotheus Says:

I have learnt now that there are prepared templates available at
https://jenkins.linuxcontainers.org/view/LXC/view/LXC%20Templates/

For example, you can create a machine for CentOS 6, 32 bit, like this:

lxc-create -t download -n myCentosTest -- -d centos -r 6 -a i386
March 15th, 2014 at 5:07 pm
peace Says:

Thanks a lot for your reply.. will try and let you know how it goes..

Regards

Peace

March 19th, 2014 at 6:39 pm
peace Says:

Hello Timotheus,

Could you please give me the rigth comand to download the prepared template from lxc-create directly. the command did not work for me>>>

May be I am wrong…

March 20th, 2014 at 8:41 am
Timotheus Says:

I have fixed the command in my previous comment. WordPress did format the double hyphen as a single hyphen, it seems.
Sorry about that!