LXC Desktop

markc

Active Member
Sep 12, 2020
59
13
28
70
Gold Coast, Australia
spiderweb.com.au
I've got a LXC container running Kodi on Ubuntu via lightdm, but without a window manager. I've also tried a container with accelerated GPU for JellyFin and that also seems to work (vaapi to Intel iGPU) but that may only be using GL or part of Xorg. The Kodi CT is indeed using most or all of Xorg to present the app on a monitor via HDMI connected to the Proxmox host. I've spent years of frustration trying to get GPU passthrough working with an iGPU inside VMs, but with no luck. This Kodi container is the first time I've seen Xorg anything presented on a monitor with good performance. This is promising, but another couple of days and I can't for the life of me get a window manager to work (i.e. kwin_x11) and therefor bootstrap a full desktop.

I know it's common to suggest using VNC/RDP/Spice, but as a potential daily driver those remote connect options are not acceptable. Most other suggestions say to use GPU passthrough from a VM, but I've already lost most of my hair going down that rabbit hole and, besides, a full desktop inside a LXC container would be extremely lightweight and efficient. Seeing Kodi on my monitor via X is very encouraging, so...

a) is anyone aware of any LXC tutorials or example LXC templates that provide a full desktop ?

b) (long shot) any hints how to bootstrap kwin_x11 from sddm (or lightdm that the Kodi CT uses) ?

c) is this of any interest to anyone else (for me, it's the holy grail of Proxmox usefulness) ?
 
Last edited:
Well, nearly two weeks later, I now have a Plasma desktop working with AUDIO as of an hour ago. I added the plasma-desktop packages to the Ubuntu Focal based Kodi container and after a week of fiddling finally got the desktop to start up using lightdm, not sddm. I tried so many tweaks that I am not exactly sure what the procedure was to get xinit -> lightdm -> startplasma-x11 to work, but now that I know it does indeed work I'll set up another container (perhaps using my beloved Manjaro/Plasma) and take notes. For now, I'll add some details about getting audio to work (with limitations) seeing that it's fresh in my mind.

The most realistic suggestions for getting audio to work in a container involves using Pulseaudio in network mode, talking to Pulseaudio on the host node, so I ended up installing the plasma-desktop package on my Proxmox host node, so I could make sure that sound was working through the HDMI output to my screen. Having confirmed sound was working in Firefox with YouTube on the host node, I made a last ditch effort to test audio via ALSA without needing Pulseaudio in the container because a) it would not run by default anyway and b) I want to use Pipewire instead and there are zero docs for Pipewire in LXC containers. The trick ended up being to determine the exact working audio device and set up /etc/asound.conf to use that one device as the default for ALSA. Example with my Minisforum HM90 amd/ryzen hardware.

First, find the audio devices available in the container...

Code:
~ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: Device [USB Audio Device], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: Generic_1 [HD-Audio Generic], device 3: HDMI 0 [LG TV]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: Generic_1 [HD-Audio Generic], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: Generic_1 [HD-Audio Generic], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: Generic_1 [HD-Audio Generic], device 9: HDMI 3 [HDMI 3]
Subdevices: 1/1
Subdevice #0: subdevice #0

and after a bunch of testing with aplay I finally heard something with this particular invocation...

Code:
aplay -c1 -D plughw:CARD=Generic_1,DEV=3 /usr/share/sounds/alsa/Front_Center.wav
and/or
aplay -D plughw:2,3 /usr/share/sounds/alsa/Front_Center.wav

Some more googling and that translated to this asound.conf config...

Code:
~ cat /etc/asound.conf
defaults.pcm.card 2
defaults.pcm.device 3
defaults.ctl.card 1

and smplayer used it by default. YAY!

The gotchas are that because there is no Pipe/Pulse/Jack audio server, Firefox will not play audio. Chromium and VLC are expected to be installed via snap, but the snap package will not install, so I was left with smplayer and the Falkon webkit based browser.

The main takeaway is that even though there is a slight lag between video and sound from YouTube (my main A/V usage case) it is nowhere near as bad as when testing Spice/VNC to a similar configured VM. IOW, it's closer to being a daily desktop contender, as I had hoped, compared to any remote access protocol that is just not acceptable for all day usage. And for reference this is the container config...

Code:
~ pct config 117
arch: amd64
cores: 4
description: First snapshot of working kodi CT with Plasma
features: nesting=1,keyctl=1
hostname: kodi
memory: 8192
net0: name=eth0,bridge=vmbr0,hwaddr=6A:33:14:62:B3:49,ip=dhcp,type=veth
onboot: 1
ostype: ubuntu
rootfs: ceph-vm:vm-117-disk-0,size=8G
swap: 512
unprivileged: 1
lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.mount.entry: /dev/fb0 dev/fb0 none bind,optional,create=file
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir
lxc.cgroup2.devices.allow: c 29:0 rwm
lxc.mount.entry: /dev/dri/renderD128 dev/renderD128 none bind,optional,create=file
lxc.cgroup2.devices.allow: c 4:7 rwm
lxc.mount.entry: /dev/tty7 dev/tty7 none bind,optional,create=file
lxc.cgroup2.devices.allow: c 13:* rwm
lxc.mount.entry: /dev/input dev/input none bind,optional,create=dir
lxc.cgroup2.devices.allow: c 116:* rwm
lxc.mount.entry: /dev/snd dev/snd none bind,optional,create=dir
lxc.idmap: u 0 100000 65536
lxc.idmap: g 0 100000 5
lxc.idmap: g 5 5 1
lxc.idmap: g 6 100006 23
lxc.idmap: g 29 29 1
lxc.idmap: g 30 100030 14
lxc.idmap: g 44 44 1
lxc.idmap: g 45 100045 60
lxc.idmap: g 105 101 1
lxc.idmap: g 106 100106 2
lxc.idmap: g 108 103 1
lxc.idmap: g 109 100109 65427
 
Great findings! I am also trying to set up a Kodi container to display through the HDMI port of my MiniPC.

May I know if you had to make any additional configuration on the Proxmox host to allow LXC to display a desktop?

I found this mentioned in another thread. I suppose you have mostly figured it out, but reference for others perhaps.
https://github.com/mrrudy/proxmoxHelper

The LXC conf created with the script
Code:
## kodi LXC
arch: amd64
cores: 2
features: nesting=1,keyctl=1
hostname: kodi
memory: 2048
net0: name=eth0,bridge=vmbr0,hwaddr=86:BE:C7:76:55:AB,ip=dhcp,type=veth
onboot: 1
ostype: ubuntu
rootfs: local-lvm:vm-102-disk-0,size=8G
swap: 512
unprivileged: 1
lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir
lxc.cgroup2.devices.allow: c 29:0 rwm
lxc.mount.entry: /dev/fb0 dev/fb0 none bind,optional,create=file
lxc.cgroup2.devices.allow: c 4:7 rwm
lxc.mount.entry: /dev/tty7 dev/tty7 none bind,optional,create=file
lxc.cgroup2.devices.allow: c 13:* rwm
lxc.mount.entry: /dev/input dev/input none bind,optional,create=dir
lxc.cgroup2.devices.allow: c 116:* rwm
lxc.mount.entry: /dev/snd dev/snd none bind,optional,create=dir
lxc.idmap: u 0 100000 65536
lxc.idmap: g 0 100000 5
lxc.idmap: g 5 5 1
lxc.idmap: g 6 100006 23
lxc.idmap: g 29 29 1
lxc.idmap: g 30 100030 14
lxc.idmap: g 44 44 1
lxc.idmap: g 45 100045 60
lxc.idmap: g 105 101 1
lxc.idmap: g 106 100106 2
lxc.idmap: g 108 103 1
lxc.idmap: g 109 100109 65427

However, I'm not having much success on my side as the HDMI port is showing a blank screen on a monitor. Any advice will be appreciated!
Correction: it turns out my TV was having some issues with the HDMI ports and wasn't even working when I connected my laptop. Kodi in CT was displaying properly after rebooting my TV. However, I am still facing issues with audio output through HDMI as it doesn't seem to work even on the Proxmox host. Hence, I am unable to confirm if sound is working properly with the setup.
 
Last edited:
Thanks for the reminder about the mrrudy/proxmoxHelper script as that is what I originally started from. It's been many months since I did all my testing and I eventually gave up until I buy a dedicated minipc that I have confirmation that iGPU passthrough will actually work... if such a beast exists, and someone else smarter than me has done all the hard work, and documented it :-)

I don't recall doing anything special on the host other than being careful to match up the device nodes and perms on the host with what is available inside LXC. I think the main problem is the lack of dbus/ubus support within LXC that makes running a normal desktop difficult to impossible so that sound managers (and no doubt many other things) will never "simply" work.

The other (main) reason I stopped working on a LXC Desktop container is that, for me, being able to back up the virtual desktop and reinstall it is the primary reason I want to go down this path in the first place. If a 100 GB VM with storage on say local-zfs versus a CT using a ZFS dataset then the difference of backing the VM compare to the CT is considerable. Small containers are not a problem with Proxmox Backup Server, but a 100+ GB CT can take 10 minutes or more, whereas a 100+ GB VM with a valid dirty-bitmap can take 10 seconds. Between that point and be able to run a "normal" desktop without any problems (aside from making sure the host is configured to cooperate) I'm sitting on the fence waiting for the right time and hardware to jump back into a KVM Desktop.

FWIW I'm also on the lookout for a forum or group of folks that also see merit in running a virtual desktop as their daily driver... and also considering using the LXD microcloud system instead of Proxmox mainly because it doesn't depend on a dated Debian host OS.
 
I have edited my post. It turns out my TV was having some issues with the HDMI port. Kodi in CT was displaying properly after I rebooted my TV. However, I am unable to confirm if sound works with the setup.
 
Never really tried and tested it for myself, but this may be of help to you?

Install MATE desktop environment and xrdp in Mint LXC:

# apt install xrdp
-reboot
# apt install mate-desktop-environment
- reboot
 
Spoonman2002, remote emulation protocols are fine for occasional use, but they are not efficient enough for long term use, neither for something as video intensive as Kodi nor as a daily driver desktop system where good frame rates and responsive mouse movements are essential.

wyextay, welcome to the world of ALSA. You have to determine exactly which single audio stream goes to your HDMI audio outputs, then hard-wire an /etc/asound.conf config to use that audio channel. Trial and error.
 
wyextay, welcome to the world of ALSA. You have to determine exactly which single audio stream goes to your HDMI audio outputs, then hard-wire an /etc/asound.conf config to use that audio channel. Trial and error.
Thanks, I managed to get it working!

For reference, this was what I got from my machine
Code:
root@pve-0:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC897 Analog [ALC897 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
root@pve-0:~# aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
lavrate
    Rate Converter Plugin Using Libav/FFmpeg Library
samplerate
    Rate Converter Plugin Using Samplerate Library
speexrate
    Rate Converter Plugin Using Speex Resampler
jack
    JACK Audio Connection Kit
oss
    Open Sound System
pulse
    PulseAudio Sound Server
upmix
    Plugin for channel upmix (4,6,8)
vdownmix
    Plugin for channel downmix (stereo) with a simple spacialization
hw:CARD=PCH,DEV=0
    HDA Intel PCH, ALC897 Analog
    Direct hardware device without any conversions
hw:CARD=PCH,DEV=3
    HDA Intel PCH, HDMI 0
    Direct hardware device without any conversions
hw:CARD=PCH,DEV=7
    HDA Intel PCH, HDMI 1
    Direct hardware device without any conversions
hw:CARD=PCH,DEV=8
    HDA Intel PCH, HDMI 2
    Direct hardware device without any conversions
hw:CARD=PCH,DEV=9
    HDA Intel PCH, HDMI 3
    Direct hardware device without any conversions
plughw:CARD=PCH,DEV=0
    HDA Intel PCH, ALC897 Analog
    Hardware device with all software conversions
plughw:CARD=PCH,DEV=3
    HDA Intel PCH, HDMI 0
    Hardware device with all software conversions
plughw:CARD=PCH,DEV=7
    HDA Intel PCH, HDMI 1
    Hardware device with all software conversions
plughw:CARD=PCH,DEV=8
    HDA Intel PCH, HDMI 2
    Hardware device with all software conversions
plughw:CARD=PCH,DEV=9
    HDA Intel PCH, HDMI 3
    Hardware device with all software conversions
default:CARD=PCH
    HDA Intel PCH, ALC897 Analog
    Default Audio Device
sysdefault:CARD=PCH
    HDA Intel PCH, ALC897 Analog
    Default Audio Device
front:CARD=PCH,DEV=0
    HDA Intel PCH, ALC897 Analog
    Front output / input
surround21:CARD=PCH,DEV=0
    HDA Intel PCH, ALC897 Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=PCH,DEV=0
    HDA Intel PCH, ALC897 Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0
    HDA Intel PCH, ALC897 Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0
    HDA Intel PCH, ALC897 Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0
    HDA Intel PCH, ALC897 Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0
    HDA Intel PCH, ALC897 Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
hdmi:CARD=PCH,DEV=0
    HDA Intel PCH, HDMI 0
    HDMI Audio Output
hdmi:CARD=PCH,DEV=1
    HDA Intel PCH, HDMI 1
    HDMI Audio Output
hdmi:CARD=PCH,DEV=2
    HDA Intel PCH, HDMI 2
    HDMI Audio Output
hdmi:CARD=PCH,DEV=3
    HDA Intel PCH, HDMI 3
    HDMI Audio Output
dmix:CARD=PCH,DEV=0
    HDA Intel PCH, ALC897 Analog
    Direct sample mixing device
dmix:CARD=PCH,DEV=3
    HDA Intel PCH, HDMI 0
    Direct sample mixing device
dmix:CARD=PCH,DEV=7
    HDA Intel PCH, HDMI 1
    Direct sample mixing device
dmix:CARD=PCH,DEV=8
    HDA Intel PCH, HDMI 2
    Direct sample mixing device
dmix:CARD=PCH,DEV=9
    HDA Intel PCH, HDMI 3
    Direct sample mixing device
usbstream:CARD=PCH
    HDA Intel PCH
    USB Stream Output
default:CARD=Remote
    Default Audio Device
sysdefault:CARD=Remote
    Default Audio Device
usbstream:CARD=Remote
    BLE Remote
    USB Stream Output

I managed to get the sound from my HDMI port with the following commands.
Code:
speaker-test -D plughw:CARD=PCH,DEV=3 -c 2
#or equivalently
speaker-test -D plughw:0,3 -c 2

Hence, the following was my /etc/asound.conf
Code:
root@pve-0:~# cat /etc/asound.conf
defaults.pcm.card 0
defaults.pcm.device 3
defaults.ctl.card 0
 
  • Like
Reactions: markc
How were you able to get the desktop to load? I'm having a hard time with that. Getting an error stating that there is no display. I guess there is some way to link the video card hardware to the container?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!