Sunday, 26 January 2014

LXC – Fast virtualization with Linux containers – X86 and ARM

Stéphane Graber explains how to get started with linux containers on Ubuntu 12.04 here:-

Creating a basic container and starting it on Ubuntu 12.04 LTS is now down to:
  sudo apt-get install lxc  
sudo lxc-create -t ubuntu -n my-container  
sudo lxc-start -n my-container
I needed this, because the container name was wrong.
sudo cp -rf my-container/ my-cloud-container/
This will default to using the same version and architecture as your machine, additional option are obviously available (–help will list them). Login/Password are ubuntu/ubuntu.
Container shuts down when the running system is shut down with the "halt" command.
Shut down a crashed container with:-
sudo lxc-stop -n my-container-name
It's now possible to use qemu-user-static with LXC to run containers of non-native architectures, ARM for example:
 sudo apt-get install lxc qemu-user-static 
sudo lxc-create -t ubuntu -n p3 -- -a armhf
 sudo lxc-start -n p3 -d

sudo lxc-attach -n p3
Use the code below to test your ARM gcc compiler.
void main(void){
/* NOP */
asm ("mov r0, r0");
puts ("hello");
Save the code as test.c, compile with gcc test.c, and run with ./a.out.
It will put hello on the screen.

No comments:

Post a Comment