LXD & CLC (desktop)

Published 01-01-0001 00:00:00

Installing CLC (Calculate Linux Container) in LXD and create a desktop environment

**The article is not complete and in the editing process**  

The LXD container hypervisor is based on LXC, but has its own configuration and deployment utilities. Below is an example of how to install CLC (Calculate Linux Container) using LXD.

**The installation process must be compatible with the gentoo-based distributors**

Installing LXD

emerge -av app-emulation/lxd

Configuring LXD

Unlike the installation in LXC, the network bridge is raised by the LXD daemon, saving you from having to make the settings yourself. To do this, first run the daemon /etc/init.d/lxd:

/etc/init.d/lxd start

Then perform the initial setup:

lxd init

The program will ask a number of questions. You can leave everything by default, after which the virtual bridge lxdbr0 will be created.

Adding a remote container image repository

Now you can add a remote container image repository:

lxc remote add calculate https://mirror.calculate-linux.org --protocol simplestreams

To confuse us a little, LXD is configured with LXC utility.

Creating a container

You can see the list of available images by running the following command:

lxc image list calculate:

Pay attention to the trailing colon. To install the system, run:

lxc init calculate:CLC/17.6 desktop-clc


  • calculate:CLC/17.6 - repository and image alias
  • desktop-clc - an arbitrary container name

All the data lxd stores in the directory /var/lib/lxd.

Starting the container

To start the LXD container, run:

lxc start desktop-clc

To add a container to startup, run:

rc-update add lxd default
lxc config set desktop-clc boot.autostart 1

You can access the console of the container by:

lxc exec desktop-clc /bin/bash

Stopping the container:

lxc stop desktop-clc

Deleting the container:

lxc delete desktop-clc

The second part consists of creating a desktop environment in a container

Setting the option to run the container in privileged mode:

lxc config set desktop-clc security.privileged true

Preparing the host for pass-through devices into a container

Allocation one of tty terminals for container:

lxc config device add desktop-clc /dev/tty2 unix-char path=/dev/tty2

Setting up GPU pass-through into container:

lxc config device add desktop-clc gpu gpu

Setting up input devices pass-through into container:

for i in /dev/input/*; do lxc config device add desktop-clc $i unix-char path=$i; done

Setting up sound devices pass-through into container:

for i in /dev/snd/*; do lxc config device add desktop-clc $i unix-char path=$i; done

Preparing the container for the received devices

Setting up Xorg server and video drivers in container:

**Assuming that the video drivers are already installed on the host**
echo 'USE="X"' >> /etc/portage/make.conf/custom
echo 'VIDEO_CARDS="nvidia"' >> /etc/portage/make.conf/custom
echo "x11-drivers/nvidia-drivers -driver -kms" >> /etc/portage/package.use/custom
echo "sys-kernel/calculate-sources -grub -firmware -minimal -symlink -vmlinuz" >> /etc/portage/package.use/custom
emerge -av x11-base/xorg-server

Update the environment variables:

env-update && source /etc/profile

Use a script to generate the configuration file for inputs:

cat > /etc/X11/xorg.conf.d/10-lxc-input.conf << _EOF_
Section "ServerFlags"
     Option "AutoAddDevices" "False"

cd /dev/input
for input in event*
cat >> /etc/X11/xorg.conf.d/10-lxc-input.conf << _EOF_
Section "InputDevice"
    Identifier "$input"
    Option "Device" "/dev/input/$input"
    Option "AutoServerLayout" "true"
    Option "XkbLayout" "us,ru"
    Option "XkbOptions" "grp:alt_shift_toggle,grp_led:scroll,compose:ralt,terminate:ctrl_alt_bksp"
    Driver "evdev"

Setting up alsa in container:

emerge -av media-sound/alsa-utils
/etc/init.d/alsasound start
rc-update add alsasound boot

Preparing the user environment in container

Creating a groups in container:

for groups in games plugdev scanner kronoz; do groupadd $groups; done

Creating a user in container:

useradd -m -g kronoz -G lp,wheel,uucp,audio,cdrom,video,cdrw,usb,users,games,plugdev,scanner,kronoz -s /bin/bash kronoz

Assign a password for new user in container:

passwd kronoz

Installing the desktop environment in container