LXC (Linux Containers) For Debian Squeeze
Today i migrated my vservers to LXC. LXC is similar to Linux VServers and OpenVZ but with one big difference. You don’t need to install a custom/patched Kernel for LXC since the support is included within the Kernel Mainline. As for Debian Linux VServers support will be dropped in future releases. This means LXC is the way to go. Okay enough talking. Lets get to work.<a id="more"></a><a id="more-554"></a>
Install Linux Containers
apt-get install lxc
Add cgroup mount point:
mkdir -p /var/local/cgroup echo "cgroup /var/local/cgroup cgroup defaults 0 0" >> /etc/fstab mount -a
Install bridge utils
apt-get install bridge-utils
Convert your eth0 configuration into a br0 bridge configuration:
# The primary network interface #auto eth0 #allow-hotplug eth0 #iface eth0 inet static #address 192.168.10.1 #netmask 255.255.255.0 auto br0 iface br0 inet static bridge_ports eth0 bridge_fd 0 address 192.168.10.1 netmask 255.255.255.0
Please keep in mind that this change might also affect your firewall settings and/or other connections.
Enable IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
Create a new container. I used a modified version of the lxc-debian template script from Daniel Lezcano which is included in the LXC debian package. It can be found here /usr/lib/lxc/templates/lxc-debian. The modfied version can be downloaded <a href="/downloads/lxc/lxc-debian">here</a>.
wget http://www.jotschi.de/downloads/lxc/lxc-debian chmod +x lxc-debian ./lxc-debian ./lxc-debian squeeze test 2
Your container with the name test will be installed at /var/lib/lxc/test.
Adapt container network configuration For my configuration i had to adapt the resolv.conf and the /etc/network/interfaces file. I changed the nameserver to 192.168.10.1 since my nameserver is running of that ip.
I also adapted the container /etc/network/interfaces file.
auto eth0 iface eth0 inet static address 192.168.10.26 netmask 255.255.255.0 gateway 192.168.10.1
You can edit those file outside of your conainer by editing:
Start the container
lxc-start -n test -d
Enter the conainer
lxc-console -n test
The default login is root/root.
Use this manual for migrating linux vservers to lxc: