virtualization - How to set up nested Wayland Desktop Environment with systemd-nspawn container, like VirtualBox -


this q&a share hack title based on stackoverflow rule/encouragement

https://stackoverflow.blog/2011/07/01/its-ok-to-ask-and-answer-your-own-questions/

https://stackoverflow.com/help/self-answer

can answer own question?

yes! stack exchange has explicitly encouraged users answer own questions. if have question know answer to, , document knowledge in public others (including yourself) can find later, it's okay ask , answer own question on stack exchange site.

the original repo is

https://github.com/kenokabe/wayland-desktop-container

how set nested wayland desktop environment systemd-nspawn container, virtualbox

this tutorial walks through setting wayland desktop environment linux systemd-nspawn container on computer. similar vmware workstation or virtualbox, linux minimal overhead performance.

a quick @ final result

features , benefits

✓ hardware independent containeros hardware abstraction extremely efficient, minimal performance overhead method systemd-nspawn container technology
✓ 100% portable among systemd enabled linux hosts, easy backup , recovery
✓ direct rendering works such 3d desktop effects
✓ video , sound works
✓ network works out of box
✓ less mess hostos , infrequent reboot operations hostos , hardware, instead, enjoy instant virtual boot, poweroff , reboot of containeros.

summary of how to

  1. launch kwin_wayland window,
    nested on current desktop environment.

  2. boot container os systemd-nspawn

  3. from containeros console:
    (a) launch desktop environment such xfce or lxqt targeted kwin_wayland window.
    (b) prepare favorite launcher app synapse or xfce4-panel alone minimal setup.

walk through

hostos minimal applications

the hostos can linuxos systemd , desktop environment can either wayland or legacy x11.

alghough, wayland hostos preferable, situation still immature. of march 2017, fedora 25 sports wayland-based gnome session default on x11-based one, other distros not. latest version of kde-plasma stable x11/xorg, unstable wayland.

probably, if use gnome host environment, go wayland, if plasma or other de, conservative use x11/xorg stability.

this method works on both conditions, , personally, use arch linux kde-plasma(x11/xorg).

install systemd-nspawn , kwin_wayland

some distro such arch has systemd-nspawn, others such ubuntu not.

systemd-nspawn

binary package “systemd-container” in ubuntu xenial

kwin-wayland

binary package “kwin-wayland” in ubuntu xenial

arch has kwin_wayland in xorg-server-xwayland package.

launch kwin_wayland window

kwin known 1 of feature complete , stable window managers. direct rendering enabled wayland window space managed kwin, , nested on current desktop environment.

starting nested kwin @kwin/wayland - kde community wiki
since 5.3 possible start nested kwin instance under either x11 or wayland:

export $(dbus-launch); \ kwin_wayland --xwayland &; 

for fish shell

export (dbus-launch); 

boot containeros

sudo systemd-nspawn \ -bd /your_machine_root_directory \ --volatile=no \ --bind-ro=/home/your_username/.xauthority \ --bind=/run/user/1000 \ --bind=/tmp/.x11-unix \ --bind=/dev/shm \ --bind=/dev/dri \ --bind=/run/dbus/system_bus_socket \ --bind=/your_data_directory 

bind /your_data_directory of hostos containeros, can share data directory between both, @ same time, containeros can stay small , clean possible , portability , backup/restore.

login containeros console.

typically, build container distro os minimal/server os images.

remember, you not need instal x11/xorg display server, or wayland containeros since kwin_wayland window plays role.

launch desktopenvironment (xfce) targeted kwin_wayland window.

remember, kwin running, , it's feature complete , powerful windowmanager. can launch , switch tasks kwin via shortcut-keys, or prepare favorite launcher app synapse or xfce4-panel minimal setup.

however, if need more user friendly desktop environments, install , launch xfce or lxqt can run along kwin.

from containeros console:

export xauthority=/home/your_username/.xauthority; \ export xdg_runtime_dir=/run/user/1000; \ export clutter_backend=x11; \ export qt_x11_no_mitshm=1; \ xfce4-session --display :1; 

maximize , remove frame of kwin_wayland window default

probably, want remove frame of containeros, how on plasma (de of hostos).

final result

confirm xfce environment recognizes running on xwayland display.

xwayland implements compatibility layer seamlessly run legacy x11 applications on wayland.

so far, more exceptionally, if install gui libraries of wayland, flag, can see gui applications run natively on wayland.

the left kate window xorg/x11 compatiblity mode.
right window wayland native mode.

as can see native wayland app not reflect current window theme , xfce panel not show app task, , cannot tell difference of performance long use normal applications of pc.

so, there's not reason pursuit wayland native mode app. situation can different 3d games, , different on small devices such raspberry pi.

(optional) legacy x11/xorg

althogh tutorial focuses on wayland nested window, xephyr (a nested x server runs x application) has been around long time.

unlike kwin_wayland, xepher not optimized direct rendering , kwin window manager not bundled, if run kwin or other direct rendering composer on top of xepher, things going slow , inefficient, therefore, not recommended, here's how:

xephyr -ac -screen 1200x700 -resizeable -reset :1 &; 

hostos , containeros interaction

you cannot copy&paste between hostos , containeros.
may consider use googlekeep share contents between hostos , containeros, , of course, shold have shared directories via systemd-nspawn bind.

portability

you may "backup/recover" or "copy" or "move" contineros anywhere regardless of

  • kernel updates
  • hardware drivers
  • disk partitions (/etc/fstab etc.)
  • grub/uefi configurations

or other typical integration glitches!

just aware of host kernel versions.

backup

your machines directory ./machines
machines backup directory ./machines-bak
machine image directory arch1

cd ~/machines/ sudo tar -cpf ~/machines-bak/arch1.tar arch1 --totals 

recovery

cd ~/machines/ sudo tar -xpf ~/machines-bak/arch1.tar --totals 

backup tools

the tar commands above may not smartest method, however, it's proven robust method without tool installations. often, simple best.

however, may select various backup tools more efficiency.

synchronization , backup programs @archwiki

git base bup looks , new.

what may consider remove container os

any hardeware dependent factors such as:

  • linux kernels various drivers
  • /etc/fstab
  • networkmanager.service of systemd

mit license


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -