In this short guide I will explain how to run Ubuntu with Xfce4 desktop environment on your Android smartphone by using Termux-X11 in an isolated environment without root privileges. With minor adjustments this guide should work for Debian too (just replace ubuntu
by debian
).
Note: Neither of options won't support systemd. Moreover, Firefox on Ubuntu is distributed as a snap package, which in turn does not work without systemd.
I am a user of an arm64 based Android smartphone. First of all let's install Termux application from Play Market.
Once Termux is installed we have to install some packages.
$ pkg update
$ pkg upgrade
$ pkg install x11-repo
$ pkg install termux-x11-nightly proot proot-distro pulseaudio
Additionally, we have to install Termux-X11 companion application for Android. We will use it to connect to Ubuntu desktop environment.
You should get it from the Termux-X11 repo at https://github.com/termux/termux-x11/releases
Now install the bare Ubuntu operating system
$ proot-distro install ubuntu
Configure pulseaudio to accept anonymous connections over the localhost by default
$ mkdir -p $PREFIX/etc/pulse/default.pa.d
$ cat <<'EOF' > $PREFIX/etc/pulse/default.pa.d/remote-local.pa
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1
EOF
Run pulseaudio as runit
$ mkdir -p $SVDIR/pulseaudio/log
$ cat <<'EOF' > $SVDIR/pulseaudio/run
#!/data/data/com.termux/files/usr/bin/sh
exec pulseaudio --daemonize=no --system=no --exit-idle-time=-1 --fail --disallow-exit 2>&1
EOF
$ cat <<'EOF' > $SVDIR/pulseaudio/log/run
#!/data/data/com.termux/files/usr/bin/sh
svlogger="/data/data/com.termux/files/usr/share/termux-services/svlogger"
exec "${svlogger}" "$@"
EOF
$ chmod u+x $SVDIR/pulseaudio/run
$ chmod u+x $SVDIR/pulseaudio/log/run
$ sv-enable pulseaudio
Run termux-x11 as runit
$ mkdir -p $SVDIR/termux-x11/log
$ cat <<'EOF' > $SVDIR/termux-x11/run
#!/data/data/com.termux/files/usr/bin/sh
exec termux-x11 2>&1
EOF
$ cat <<'EOF' > $SVDIR/termux-x11/log/run
#!/data/data/com.termux/files/usr/bin/sh
svlogger="/data/data/com.termux/files/usr/share/termux-services/svlogger"
exec "${svlogger}" "$@"
EOF
$ chmod u+x $SVDIR/termux-x11/run
$ chmod u+x $SVDIR/termux-x11/log/run
$ sv-enable termux-x11
Run it first
$ proot-distro login --isolated --bind /dev/null:/proc/sys/kernel/cap_last_cap --shared-tmp ubuntu
Install required packages
$ apt update
$ apt install dialog pulseaudio apt-utils
$ echo 'default-server = localhost' > /etc/pulse/client.conf.d/remote-local.conf
$ pactl list sinks short
$ apt install --no-install-recommends xorg xfce4 dbus-x11 pavucontrol
Launch Ubuntu with XFCE4
$ DISPLAY=:0 dbus-launch --exit-with-session xfce4-session
To run it directly
$ proot-distro login --isolated --bind /dev/null:/proc/sys/kernel/cap_last_cap --shared-tmp ubuntu -- env DISPLAY=:0 dbus-launch --exit-with-session xfce4-session
Launch Termux-X11 companion app to connect to XFCE4 desktop environment
It's possible to use VNC instead of the Termux-X11 companion app.
Map VNC port over the SSH tunnel
Connect to VNC at
localhost::5900