LXC(Linux Containers:http://en.wikipedia.org/wiki/LXC) is a virtualization technique which provides os and network stack level isolation. It allows to run multiple OS distros on a host machine with isolated process listings, user groups, ip addressing. The only constraint is all these containers and host machines should use same kernel(http://en.wikipedia.org/wiki/Linux_kernel). It make use of cgroups, a new feature addition to latest linux kernels.
What is cgroup
Cgroup associates each task to a subsystem and the subsystem allocates resources shared fro host machine. One can even control amount of resources by passing them as parameter. There can be heirarchy of cgroups i.e cgroups within cgroups(in precise vm within vm)
Have a look at http://www.kernel.org/doc/Documentation/cgroups/cgroups.txt to get a taste of cgroup
Create our VM
This works without any issue in Ubuntu host.
1)install lxc
2)create a mount point for vms
mkdir -p /cgroup
mount none -t cgroup /cgroup
3)create network bridges
Refer http://blogs.eskratch.com/2012/10/bridging-interfaces.html
4)Create your vm
lxc-create -n <name for vm> -t ubuntu -f /usr/share/doc/lxc/examples/lxc-veth.conf
where -t specifies os templates
os templates are available at /usr/lib/lxc/templates/. Have a look at them and try to understand how devices are shared between host system and containers.
-f specifies the config file (here for network ip assignment ). To understand different network options available, have a look at http://blog.flameeyes.eu/2010/09/linux-containers-and-networking
5)The previous command should have created a vm. Check using
lxc-ls
6)Start the VM using
lxc-start -n <name of the vm>
This will take some time to boot. Then once the console appears, it prompts for username, password. For each OS, the template will have username password as variables(For eg ubuntu template assigns username and password to be ubuntu).
LXC and Ubuntu Connection:
Ubuntu's 12.04 release has fixed most of the common bugs of lxc and have created security policies to avoid collision between containers and host while sharing resources.
For CentOs geeks:
CentOS 6.x supports lxc and cgroup. Lesser than 6.x, its impossible to have isolations.
1) Download lxc-0.7.5 source from http://lxc.sourceforge.net/download/lxc/
2)Do a manual install
Ref http://wiki.centos.org/PackageManagement/SourceInstalls
3)Centos has lot of issues with lxc. I tried fixing some of them with patches available
Download centos container template from https://github.com/kalyanceg/lxc-centos
4)Keep the tar file in /var/cache/lxc and the lxc-centos file in /usr/local/lib/lxc/templates/
5)Create the vm using
/usr/local/bin/lxc-create -n <name of vm> -t centos -f {lxc_source_path}/doc/examples/veth.conf
6)Start vm
/usr/local/bin/lxc-start -n <name of vm>
What is cgroup
Cgroup associates each task to a subsystem and the subsystem allocates resources shared fro host machine. One can even control amount of resources by passing them as parameter. There can be heirarchy of cgroups i.e cgroups within cgroups(in precise vm within vm)
Have a look at http://www.kernel.org/doc/Documentation/cgroups/cgroups.txt to get a taste of cgroup
Create our VM
This works without any issue in Ubuntu host.
1)install lxc
2)create a mount point for vms
mkdir -p /cgroup
mount none -t cgroup /cgroup
3)create network bridges
Refer http://blogs.eskratch.com/2012/10/bridging-interfaces.html
4)Create your vm
lxc-create -n <name for vm> -t ubuntu -f /usr/share/doc/lxc/examples/lxc-veth.conf
where -t specifies os templates
os templates are available at /usr/lib/lxc/templates/. Have a look at them and try to understand how devices are shared between host system and containers.
-f specifies the config file (here for network ip assignment ). To understand different network options available, have a look at http://blog.flameeyes.eu/2010/09/linux-containers-and-networking
5)The previous command should have created a vm. Check using
lxc-ls
6)Start the VM using
lxc-start -n <name of the vm>
This will take some time to boot. Then once the console appears, it prompts for username, password. For each OS, the template will have username password as variables(For eg ubuntu template assigns username and password to be ubuntu).
LXC and Ubuntu Connection:
Ubuntu's 12.04 release has fixed most of the common bugs of lxc and have created security policies to avoid collision between containers and host while sharing resources.
For CentOs geeks:
CentOS 6.x supports lxc and cgroup. Lesser than 6.x, its impossible to have isolations.
1) Download lxc-0.7.5 source from http://lxc.sourceforge.net/download/lxc/
2)Do a manual install
Ref http://wiki.centos.org/PackageManagement/SourceInstalls
3)Centos has lot of issues with lxc. I tried fixing some of them with patches available
Download centos container template from https://github.com/kalyanceg/lxc-centos
4)Keep the tar file in /var/cache/lxc and the lxc-centos file in /usr/local/lib/lxc/templates/
5)Create the vm using
/usr/local/bin/lxc-create -n <name of vm> -t centos -f {lxc_source_path}/doc/examples/veth.conf
6)Start vm
/usr/local/bin/lxc-start -n <name of vm>
Comments
Post a Comment