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
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.