symbiosⵀS

Symbiosis Operational System

Share x11, camera and pulseaudio over LXC/LXD containers.

main features

reason

demo video

symbiosOS

Table of contents

Host configuration

Install dependencies

https://linuxcontainers.org/lxd/getting-started-cli/#installation

Configure pulseaudio server

Append following line at /etc/pulse/default.pa and enable tcp module for pulseaudio

load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1

Stop pulseaudio server

pulseaudio -k

Mapping driver using unix:// is flickering

Profile

Create blank profile

lxc profile create x11

Edit x11 profile

lxc profile edit x11

Paste the following yaml

Nvidia GPU

config:
  environment.DISPLAY: :0
  environment.PULSE_SERVER: tcp:127.0.0.1:4713
  nvidia.driver.capabilities: all
  nvidia.runtime: "true"
  user.user-data: |
    #cloud-config
    runcmd:
      - 'sed -i "s/; enable-shm = yes/enable-shm = no/g" /etc/pulse/client.conf'
      - 'echo export PULSE_SERVER=tcp:127.0.0.1:4713 | tee --append /home/ubuntu/.profile'
    packages:
      - x11-apps
      - mesa-utils
      - pulseaudio
      - v4l-utils
description: GUI LXD profile
devices:
  PASocket:
    bind: container
    connect: tcp:127.0.0.1:4713
    listen: tcp:127.0.0.1:4713
    type: proxy
  X0:
    bind: container
    connect: unix:@/tmp/.X11-unix/X1
    listen: unix:@/tmp/.X11-unix/X0
    security.gid: "1000"
    security.uid: "1000"
    type: proxy
  mygpu:
    type: gpu
  video0:
    gid: "1000"
    path: /dev/video0
    type: unix-char
name: x11
used_by: []

Intel iGPU

config:
  environment.DISPLAY: :1
  environment.PULSE_SERVER: tcp:127.0.0.1:4713
  raw.idmap: both 1000 1000
  user.user-data: |
    #cloud-config
    runcmd:
      - 'sed -i "s/; enable-shm = yes/enable-shm = no/g" /etc/pulse/client.conf'
      - 'echo export PULSE_SERVER=tcp:127.0.0.1:4713 | tee --append /home/ubuntu/.profile'
    packages:
      - x11-apps
      - mesa-utils
      - pulseaudio
      - v4l-utils
description: GUI LXD profile
devices:
  PASocket:
    bind: container
    connect: tcp:127.0.0.1:4713
    listen: tcp:127.0.0.1:4713
    type: proxy
  X1:
    bind: container
    connect: unix:@/tmp/.X11-unix/X1
    listen: unix:@/tmp/.X11-unix/X1
    security.gid: "1000"
    security.uid: "1000"
    type: proxy
  mygpu:
    gid: "1000"
    type: gpu
  video0:
    gid: "1000"
    path: /dev/video1
    type: unix-char
name: x11
used_by: []

Profile advices

Guest configuration

Deploy a new guest

lxc launch --profile default --profile x11 ubuntu:20.04 guest01

Guest login

lxc exec guest01 -- sudo --user ubuntu --login
To run a command as administrator (user "root"), use "sudo ".
See "man sudo_root" for details.

ubuntu@guest01:~$

If you want distinguished colors for different guests gnome-terminal.

https://mayccoll.github.io/Gogh/

gnome-terminal --profile="Jackie Brown" -- bash -c "lxc exec guest01 -- sudo --user ubuntu --login"

OR use Symbiosis OS Launcher

Checking guest

Video GLX

glxinfo -B
direct rendering: Yes
Memory info (GL_NVX_gpu_memory_info):
    Dedicated video memory: 6144 MB
    Total available memory: 6144 MB
    Currently available dedicated video memory: 5228 MB
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce GTX 1060 6GB/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 450.119.03
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.6.0 NVIDIA 450.119.03
OpenGL shading language version string: 4.60 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)

OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 450.119.03
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20

Pulseaudio

pactl info
Server String: tcp:127.0.0.1:4713
Library Protocol Version: 33
Server Protocol Version: 33
Is Local: no
Client Index: 14
Tile Size: 65472
User Name: rosiney
Host Name: desk
Server Name: pulseaudio
Server Version: 13.99.1
Default Sample Specification: s16le 2ch 44100Hz
Default Channel Map: front-left,front-right
Default Sink: alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo
Default Source: alsa_input.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.mono-fallback
Cookie: 9537:bf95

Camera

v4l2-ctl --list-devices
Iriun Webcam (platform:v4l2loopback-000):
        /dev/video0

Sometimes the commands above not working because the cloud-config steps not finished, if commands not working try to install manually x11-apps mesa-utils pulseaudio v4l-utils

Symbiosis OS Launcher

Install

Open LXC ubuntu guests instances using gnome-terminal

mkdir -p ~/.local/bin/

cat << 'EOF' > ~/.local/bin/sos
#!/bin/bash

CONTAINER="$1"
PROFILE="$2"

if [[ "$CONTAINER" == "" ]]; then
    lxc list
    exit 0
fi

read -ra status <<< "$(lxc info "$CONTAINER" | grep 'Status:')"

if [[ "${status[0]}" == "" ]]; then
    exit 1
elif [[ "${status[1]}" != "Running" ]]; then
    lxc start "$CONTAINER"
fi

if [[ "$PROFILE" != "" ]]; then
    gnome-terminal --profile="$PROFILE" -- bash -c "lxc exec $CONTAINER -- sudo --user ubuntu --login"
else
    gnome-terminal -- bash -c "lxc exec $CONTAINER -- sudo --user ubuntu --login"
fi

EOF

chmod +x ~/.local/bin/sos

Usage

sos                  # list all containers (lxc list)
sos <name>           # start and login at ubuntu container
sos <name> <profile> # start and login at ubuntu container using gnome-terminal profile

Terminal Launcher

Just a small script to call GUI apps without lock terminal or print output

Install

mkdir -p ~/.local/bin/

cat << 'EOF' > ~/.local/bin/tl
#!/bin/bash
nohup "$@" &>/dev/null & disown %%
EOF

chmod +x ~/.local/bin/tl

Configure autocomplete for tl

cat << 'EOF' >> ~/.bashrc

_tl_completions() {
  COMPREPLY=($(compgen -c "${COMP_WORDS[1]}"))
}

complete -F _tl_completions tl

EOF

Usage

tl google-chrome

needs to logout/login to reload profile