This is an old revision of the document!


Virtualization

Virtualization gives customers the possiblity to execute their own applications. Usage of containers allows to isolate the applications and the entire OS images from the other processes which are running on a host system.

This tutorial shows how to get started with it using LXC container.

Prerequisites

NetModule Router NB2800

Configuration

  1. Download the container jessie.tgz
  2. Transfer it (you can use WinSCP) to the router and put in /mnt/storage/<name> (for example /mnt/storage/OS)
  3. Unpack it using
     tar -xvzf <jessie.tgz> 
  4. Open GUI and go to System → Virtualization.
  5. Click ‘+’ (add) to add container.
  6. Set type, description, root filesystem ( /mnt/storage/OS/lxc/jessie/rootfs in this case) and press Apply.
  7. Click on Edit button (the one to the left of Delete button), go to “Networking”, select routed (if your network contains one router, if more - bridged) by the Network Interface VIRT1 and press Apply. You should see a following screen:
  8. Create a new session using SSH client (for example Putty)
  9. Log in as root
  10. Attach to the specified container
     lxc-attach -n <name> 

    in this example:

     lxc-attach -n guest0 

Installing nano/vim editor

By default, no text editor is installed. I recommend installing two most popular editors, namely vim and nano.

Being attached to the container (root@jessie:~# displayed in the left corner of the CLI), type

 apt-get install <name> 

,where <name> is either 'vim' or 'nano'.

When a line similar to the following appears: After this operation, 27.9 MB of additional disk space will be used. Do you want to continue? [Y/n], type 'y' and confirm by pressing enter.

Hello World in C

  1. First of all we need to install gcc: GNU Compiler Collection
  2. At the beginning, update the packages by typing
     apt-get update 
  3. Subsequently install the compiler by typing
     apt-get install gcc 
  4. Now create and open a .c file using nano editor
     nano hello.c 
  5. Type following code:
    hello.c
    #include <stdio.h> 
    int main() 
    {
    	printf("Hello World");
    	return 0; 
    }
  6. Save it using Ctrl + O (German keyboard: Strg + O)
  7. Exit using Ctrl + X (German keyboard: Strg + X)
  8. Compile the program using gcc
     gcc hello.c -o hello 
  9. Type
     ls -l 
  10. The created file has rights 644. Change it to 755
     chmod 755 hello 
  11. Type
     ./hello 

    to run the program

Hello World shell script

  1. Create and open file using nano editor
     nano helloBash 
  2. Type following code:
    helloBash
    #!/bin/bash
    echo "Hello World"
  3. Save it using Ctrl + O (German keyboard: Strg + O)
  4. Exit using Ctrl + X (German keyboard: Strg + X)
  5. Type
     ls -l 
  6. The created file has rights 644. Change it to 755
     chmod 755 helloBash 
  7. Type
     ./helloBash 

    to run the program

Hello World in Python

  1. First of all we need to install Python
  2. At the beginning, update the packages by typing
     apt-get update 
  3. Subsequently install Python by typing
     apt-get install python 
  4. Create and open a .py file using nano editor
     nano helloPt.py 
  5. Type following code:
    helloPt.py
     print "Hello World" 
  6. Save it using Ctrl + O (German keyboard: Strg + O)
  7. Exit using Ctrl + X (German keyboard: Strg + X)
  8. Run the program using
     python helloPt.py