My test laptop dead, so all I can done is using VM, but vmware only pass ps2 mouse to VM, but ps2 mouse is not hotplugable, so I have to disable hotplug in x11 config to use the mouse, but only one container succeeded to let mouse click, but it drifted, and I forgot how to reproduce it, but it’s possible. And I can’t test audio. And I can’t start wayland compositor this way.
requirement:
- a pc with mouse and keyboard and monitor and gpu
- no X11 or wayland installed
- have access to switch to a tty and login
- incus or lxd
You need another device to ssh to the pc, because after X start in tty, keyboard won’t let you use Ctrl+Alt+F* to switch tty.
Containerlized X11 has 2 part, output and input. Let’s start output part.
To display containerlized X11 in host is very easy. All we need is a gpu and a tty.
let’s say we use tty3. You switch to tty3 with Ctrl+Alt+F3, and login. Now you can use ls -alh /dev | grep tty3
to verify you own tty3, will dispaly soming like: crw------- 1 username tty 4, 1 tty3
, username will be your username.
you can find your gpu with lspci | grep VGA
, we only need pci address like: 00:02.0.
Create a container. Let’s call it gui, and enter it. incus exec gui bash
We need group id in container: cat /etc/group
. Find tty, video and input. My is 5, 44 and 102.
Exit container, and create a profile call display.
devices:
mygpu:
type: gpu
gputype: physical
pci: '0000:00:02.0'
mode: '0770'
gid: '44'
uid: '1000'
tty3:
path: /dev/tty3
required: "false"
source: /dev/tty3
type: unix-char
uid: "1000"
gid: '5'
And add profile to container. incus profile add gui display
Enter container create a user with group video,input,tty: useradd -m -G video,sudo,input,tty -s /bin/bash lxc
And install xorg, I’m using debian so apt: apt install xorg --install-recommends
And and desktop environment: apt install mate-desktop-environment-core --no-install-recommends
Switch to user: su -l lxc
You can try mate-session or whatever your desktop environment start cmd is, it won’t success, you will get /usr/lib/xorg/Xorg.wrap: Only console users are allowed to run the X server
. Just change allowed_users=console
to allowed_users=anybody
in /etc/X11/Xwrapper.config in container. Then you will get Cannot open display
. Xorg
will succeed, but only black screen, not useful this time. Only startx
will work. You can move mouse but cannot click, at least that’s what I can experience. If you can click, please let me know how.
Let’s talk about input part which I can’t solve.
I add everything in /dev/input in profile, like this:
devices:
event0:
gid: "102"
path: /dev/input/event0
source: /dev/input/event0
type: unix-char
uid: "1000"
event1:
gid: "102"
path: /dev/input/event1
source: /dev/input/event1
type: unix-char
uid: "1000"
mice:
gid: "102"
path: /dev/input/mice
source: /dev/input/mice
type: unix-char
uid: "1000"
Enter container and startx, still cannot click. But can use keyboard, although it will directly input in tty instead of container.
Kill X, you will see black screen, Ctrl+Alt+F2 Ctrl+Alt+F3, you will see what you keyboard input before.
To stop hotplug so X11 won’t disable ps2: X -configure
, you will get xorg.conf.new
. Edit it, add 2 Options in Section “ServerLayout”:
Section "ServerLayout"
Option "AutoAddDevices" "Off"
Option "AutoEnableDevices" "False"
Start X: startx -- -config xorg.conf.new
. I have 2 containers for test, only first one can click but drifting, but I forgot what I have done, second one cannot. I installed xserver-xorg-input-mouse in both container.
I guess by pass usb mouse to container can avoid disable hotplug.
So, 2 problems with input, how to let mouse click and how to let keyboard input in container.