Welcome a new distro for containers - Calculate Linux Container!

Calculate Linux family has recently received one more distro - Calculate Linux Container (CLC). It is created specially to be installed in a LXC/LXD container.

Before installing it, please, update the system:

cl-update

Below you can find an example of creating LXC container with setting up OpenRC using DHCP server in a local network.

Install required packages

To work with LXC containers you need the package app-emulation/lxc:

emerge app-emulation/lxc

Install the system in the container

To install Calculate Linux Container you should run following command:

lxc-create -n calculate -t download -- --server mirror.calculate-linux.org --no-validate

Where:

  • n name you assign to the container
  • t initialisation scenario
  • -server mirror (list of available mirrors)
  • -no-validate don’t check gpg signature

The download scenario will show a list of available images and ask to select distro “CLC” (in capital letters), its release and architecture.

Then the program will download an image and install it. All installed containers are located in the directory /var/calculate/lxc.

Network setup

To setup a network in LXC container you need to setup a network bridge. An example of settings for OpenRC in the file /etc/conf.d/net:

config_eth0="null"
bridge_br0="eth0"
config_br0="dhcp"
bridge_worward_delay_br0=0
bridge_hello_time_br0=1000
bridge_stp_state_br0=0

You should also delete a symbolic link /etc/init.d/net.eth0 and create a new one /etc/init.d/net.br0:

/etc/init.d/net.eth0 stop
rm -f /etc/init.d/net.eth0
ln -s /etc/init.d/net.lo /etc/init.d/net.br0
/etc/init.d/net.br0 start

Then you need to make network settings of the container in the file /var/calculate/lxc/calculate/config:

 # network type, veth if you use a bridge
lxc.network.type = veth
 # startup network interface during the boot
lxc.network.flags = up
 # interface name inside the container
lxc.network.name = eth0
 # bridge name for a virtual interface
lxc.network.link = br0
 # name of the network adaptor for this container on a host machine
lxc.network.veth.pair = veth-calculate
 # random MAC address for the network interface of the container (first digit must be even)
lxc.network.hwaddr = 02:03:04:05:06:07

Start the container

You can start the container with the following command:

lxc-start -n calculate

Open the container console:

lxc-attach -n calculate

After that you can enable a network:

/etc/init.d/net.eth0 start
rc-update add net.eth0 default

To leave you can either enter ‘exit’ or press Ctrl+d.

To add the container to the autostart:

ln -sf /etc/init.d/lxc /etc/init.d/lxc.calculate
rc-update add lxc.calculate default

Mount resources

Please, notice that the path must already exist in the system.

To mount /home you should edit the container settings file /var/calculate/lxc/calculate/config by adding a following string:

lxc.mount.entry = /home home none rw,bind 0.0

This guide addresses installing Calculate in LXC v1 containers but is there any guide for installing in LXD (re LXC v2) containers ?

LXC v1 is quite different from LXC v2 in CLI syntax as well as functionality & features.

thanks

Brian