I am making a script that uses systemd-nspawn to boot a second linux root filesystem in a container.
The script is currently using this line to boot the container:
systemd-nspawn -b --machine virtualdesktop -D "/mnt/virtualdesktop"
The host and container are based on Debian and use systemd. (Raspbian Buster to be exact)
The guest boots up correctly and after logging in, gives me a shell.
But that is not all I want - the script should also load the graphics of the guest. The host has a Xephyr window open, running a second X display on
Then the guest will run lxsession on display :1.
It is easy to do this manually by typing this command in the guest's shell:
DISPLAY=:1 lxsession -s LXDE-pi -e LXDE, but here's what I need help with: running that command automatically, not requiring the operator to input the guest's password and type in the lxsession command.
I have tried:
- Appending the desired
lxsessioncommand to the end of the
systemd-nspawncommand, like this:
systemd-nspawn -b --machine virtualdesktop -D "/mnt/virtualdesktop" 'DISPLAY=:1 lxsession -s LXDE-pi -e LXDE', but nothing happened.
systemd-run, as suggested here. Ran this command while container is running:
systemd-run --machine virtualdesktop "/usr/binlxsession -s LXDE-pi -e LXDE", but Xephyr doesn't display anything and journalctl reports
Failed to execute command: No such file or directory
Failed at step EXEC spawning /usr/bin/lxsession -s LXDE-pi -e LXDE: No such file or directory