[How-to series 2/N] run X11 graphic Apps. on any Nas (arm or Intel)

Hi,

=== can be ignored by Linux expert even confirmed … but …

Topic 2 : basic tools to build environment … don’t hesitate to return errors …

To create a complete (not full) environment base on Ubuntu 24.04 L.T.S (I start same with new 26.04) …
We used 2 families tools (provide by A.D.M. 5.0, or by Entware (full GNU) : chroot, namespaces unshare and nsenter

Chroot : (if it’s new for you … read for ex. Wikipedia article)
… basically chroot is used to isolate some program in a Linux system by changing the root folder “/” by a private one.
… … if you extend this to a new root folder with its own bin, lib, proc, sys … etc. you create an image of another distribution
… IN THIS CASE we create a complete Ubuntu 24.04 L.T.S. structure BUT without the kernel (A.D.M.)
… creating this structure is done in a real Ubuntu (or any Virtual Machine) using debootstrap tool
… … debootstrap can create ready to use env. if architecture is same (ex. Intel x86_64) OR create preload env. for another architecture (ex. arm64) needing only a second stage when installed on the real system ( in chroot /debootstrap/debootstrap --second-stage to finish the creation.

example of code in V.M. of x86_64 Ubuntu system (noble is name for 24.04) :

debootstrap --variant=minbase --include=whiptail,locales,vim noble chroot_2404_x86_64
debootstrap --variant=minbase --include=whiptail,locales,vim --arch=arm64 --foreign noble chroot_2404_arm64

… this create folder … save it using tar … or what else and transfer to the target NAS

==== I will provide tar file for people can’t create the chroot by itself

BEFORE starting configuration … some explain on how-to used it :

CASE : you just use the chroot and install your applications
… in this case you need an external X server (mobaxterm, linux desktop, VcXsrv, etc.
CASE : you add an internal Xserver (not hardware dependent) and a Vnc server in chroot
… it’s my option to execute X11 applications even without graphic card on NAS
… multiple solution exist (and work) ex. Xvfb with x11vnc OR my prefered (I explain later) tigervncserver (combine Xserver and Vnc server)
… … ALL require to use a vnc client (PC, Mac, Linux? Android, etc.)
CASE : x86_64 NAS with graphic card and HDMI port
… in this case, you can add xserver-xorg-video-intel and video acceleration to be able to used directly applications on NAS
… … ATTENTION … this require to disable Asportal and Xorg delivered in ADM. (this is the basic for myHD APKG)

NAMESPACES :
… putting chroot (Ubuntu) in a namespace is a ligth solution to isolate completely your Ubuntu
… it’s like Docker or LXC but without constraints and ZERO software added or libraries not know.
… I use it for :
isolate mount (isolate even mounted share), IPC (inter process Comm.), PID (so process ID in namespaces are private and a command to list process (ps) show only tasks running in namespace
BUT I keep network (share between ADM and namespace) … so no configuration to do (even expert can configure easily veth, macvlan or ipvlan)= for private network) … also hostname and VPN (like tailscale) as kept so usable as is … and kernel is ADM kernel (so with some attention to the not standard version finishing by .x on x86_64 NAS … so if you need extra kernel modules … you must create it for ADM kernel version.

FOR EXPERT : namespace permit also to use systemd as init, so no need to start manually any services … this is done as a “standard” Ubuntu (the documentation can be follow as is) … to use systemd and flatpak … a tricks (is require) :question: :laughing:

The tools to manage namespace are : unshare and nsenter
… the how-to is like :
use unshare to create a namespace with selected parts and some basic mount (/proc for ex.)
use nsenter or command accepting to target a namespace (ex. mount with -N)
… start the chroot with systemd (/sbin/init) task
… to mount mandatory and data folder
then use nsenter to run what you want

to simplify this complex method … I provide a tool to combine in one command all the actions required
… jchroot write by Vincent Bernat (thanks and all credit to him) … version with a modification to replace pivot_root by chroot … due to NAS architecture. (I will post, soon in github the fork)

===== NEXT topic … how load and manage chroot even out of namespace then start it in namespace.

Philippe.