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
  2. Open GUI and go to System → Virtualization
  3. Click + to add container
  4. By settings, choose type, create a description and select storage. Root file system will be set automatically
  5. If you want to enable networking, go to “Networking”, select routed or bridged by the Network Interface and press Apply
  6. You should see a following screen (if you chose extended storage, the path will have storage1 instead of storage0: /mnt/storage1/lxc/guest0)
  7. Transfer the downloader container (you can use WinSCP) to the router and put in /mnt/storage0/lxc
  8. Unpack the container:
     tar –xvf jessie.tar –C ./guest0 
  9. Check access rights using
     ls –l 
  10. If the created folder has rights 644, change them* to 755:
     chmod 755 -R guest0 
  11. The extracted container contains rootfs directory. You need to copy the content of it to the specified root file system. Using
     cd 

    , go to guest0/lxc/jessie

  12. Type
     lxc-start –n guest0 
  13. Information about container can be accesed by typing
     lxc-info –n guest0 <code> {{ :app-notes:info.png |}}
      - Now you can attach to the container by typing <code> lxc-attach –n guest0 

* Later you should remove executable permission bits from some system files, start container in foreground mode

 lxc-start –F –n guest0 

to get more Information

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