This is an old revision of the document!
root@hostX:~# apt-get install bridge-utils root@hostX:~# ifdown eth0 root@hostX:~# cat /etc/network/interfaces
auto lo iface lo inet loopback #auto eth0 #iface eth0 inet static # address 172.16.1.X # netmask 255.255.255.0 # gateway 172.16.1.254 auto br0 iface br0 inet static address 172.16.1.X netmask 255.255.255.0 bridge_ports eth0 bridge_stp off bridge_maxwait 5 post-up /usr/sbin/brctl setfd br0 0 gateway 172.16.1.254
root@hostX:~# ifup br0
root@hostX:~# apt-get install debootstrap root@hostX:~# mkdir -p /opt/lxc/serverX root@hostX:~# cd /opt/lxc/serverX/ root@hostX:/opt/lxc/serverX# debootstrap --variant=minbase --arch i386 lucid rootfs.ubuntu
root@hostX:~# cp /etc/hosts /opt/lxc/serverX/rootfs.ubuntu/etc/ root@hostX:~# cp /etc/resolv.conf /opt/lxc/serverX/rootfs.ubuntu/etc/ root@hostX:~# cp /etc/apt/sources.list /opt/lxc/serverX/rootfs.ubuntu/etc/apt/ root@hostX:~# chroot /opt/lxc/serverX/rootfs.ubuntu /bin/bash root@hostX:/# apt-get install --force-yes -y gpgv root@hostX:/# apt-get update root@hostX:/# apt-get -y install language-pack-en root@hostX:/# locale-gen en_US.UTF-8 root@hostX:/# /usr/sbin/update-locale LANG="en_US.UTF-8" LANGUAGE="en_US.UTF-8" LC_ALL="en_US.UTF-8" LC_CTYPE="C" root@hostX:/# apt-get install -y vim telnet ssh rsyslog root@hostX:/# cat /etc/init/rc-sysinit.conf start on startup pre-start script rm -f $(find /var/run -name '*pid') route add default gw 172.16.1.254 # /etc/init.d/postfix start end script root@hostX:/# cat /etc/init/ssh.conf ... start on startup ... root@hostX:/# cat /etc/init/rsyslog.conf ... start on startup ... root@hostX:/# passwd root@hostX:/# cat /etc/hostname serverX.class.un root@hostX:/# cat /etc/hosts ... 172.16.1.100+X serverX.class.un root@hostX:/# cd /etc/init root@hostX:/etc/init# rm -f console* control* hwclock* module* mount* network-interface* plymouth* procps* tty{1,2,3,4,5,6}.conf udev* upstart* root@hostX:/# exit
root@hostX:~# apt-get install lxc root@hostX:~# mkdir /cgroup root@hostX:~# cat /etc/fstab ... none /cgroup cgroup defaults 0 0 root@hostX:~# mount /cgroup root@hostX:~# mkdir /opt/lxc/lib root@hostX:~# rmdir /var/lib/lxc root@hostX:~# ln -s /opt/lxc/lib/ /var/lib/lxc
root@hostX:~# cat /opt/lxc/config.serverX lxc.utsname = serverX lxc.tty = 4 lxc.network.type = veth lxc.network.flags = up lxc.network.link = br0 lxc.network.name = eth0 lxc.network.mtu = 1500 lxc.network.ipv4 = 172.16.1.100+X/24 lxc.rootfs = /opt/lxc/serverX/rootfs.ubuntu lxc.mount = /opt/lxc/fstab.serverX root@hostX:~# cat /opt/lxc/fstab.serverX none /opt/lxc/serverX/rootfs.ubuntu/dev/pts devpts defaults 0 0 none /opt/lxc/serverX/rootfs.ubuntu/proc proc defaults 0 0 none /opt/lxc/serverX/rootfs.ubuntu/sys sysfs defaults 0 0 none /opt/lxc/serverX/rootfs.ubuntu/var/lock tmpfs defaults 0 0 none /opt/lxc/serverX/rootfs.ubuntu/var/run tmpfs defaults 0 0 root@hostX:~# lxc-create -f /opt/lxc/config.serverX -n serverX root@hostX:~# lxc-ls serverX root@hostX:~# ls /var/lib/lxc serverX
root@hostX:~# lxc-start -n serverX /bin/bash root@hostX:~# lxc-start -n serverX -d root@hostX:~# lxc-info -n serverX 'serverX' is RUNNING root@hostX:~# lxc-ps --name serverX root@hostX:~# ssh 172.16.1.100+X root@hostX:~# lxc-stop -n serverX