I know some of you geeks have already done something like that, running a GNU/Linux distribution on top of an Android device. It’s an interesting time, with projects like
proot we don’t need
root privilege on our Android devices to run a containerized Linux environment. Here in this post, I’ve written down the steps that I’ve taken to have a usable desktop environment up running on my Galaxy Tab S5e (this blog post has been written up purely within such environment).
First of all, you must have a device running Android 7.0+, which is a requirement of Termux. If you plan to use graphical environment, I highly recommend you having a big-screen device such as a tablet, or having a USB-C hub that connects to a monitor and other peripherals.
You need to first install Termux from FDroid. Don’t install it from Google Play. The version in Google Play store is outdated and will not receive any updates until the author has figured a way to target newer Android APIs. Once you’ve done that, open Termux and install
proot-distro and use it to install Fedora 33 (check other distributions it supports by
pkg install proot-distro proot-distro install fedora-33
Now we can log into the proot environment and it is Fedora!
proot-distro login fedora-33 # the commands below are executed in fedora proot dnf update dnf install mate-session-manager mate-desktop mate-themes mate-terminal pluma caja marco glibc-langpack-en firefox
Now you’ve installed some packages for MATE desktop environment and should be ready to have a basic graphical desktop up running. Not so fast yet… Android doesn’t have an X11 server nor a wayland compositor. We then have two choices here:
- VNC/RDP remote desktop
- “Remote” X11
I’m going for the second option here. Mainly because all the VNC clients on Android I’ve tried so far don’t have perfect experience (albeit perfectly usable). To do that, install “XServer XSDL” from Google Play store on the same Android device. Launch it and configure the screen resolution if you need, then we can head back to Termux task and tell Fedora to start a MATE session with a “remote” X server.
export DISPLAY=localhost:0 PULSE_SERVER=tcp:localhost:4713 mate-session
Remember to acquire wakelock for Termux in the notification area, otherwise Android might kill Termux process to save battery. Now you can head to the XServer XSDL task again, wait for a couple of seconds and you should be greeted by a MATE session (as shown in the screenshot below).
Logging as a Non-root User
You might be struck down by a number of applications that refuse to run in privileged mode (by default, proot logins as
root). To solve that and login as a non-root user, you need the good old friends
usermod commands to create a new user in the proot environment:
useradd -m user1 # create a new user with login ID user1 groups root # check what groups we might need to add usermod -aG aid_inet user1 # add aid_inet group to user1
Now in the future when you want to login as this user, you can do:
proot-distro login fedora-33 --user user1
However it seems that some configuration files are not correctly sorted so you might not be able to use
sudo to gain root privilege. The workaround would be to execute those commands in another Termux tab as
Locale and Timezone
The system is up running now but it’s been really configured as a bare minimal OS. You might find quite a few things out of the place. Here we’re going to correct the locale and the timezone.
The locale would’ve been configured to the fallback “C”. To make it worse, there is no language pack installed for
glibc by default (in the Setup section, we installed English language pack ourselves). Once you’ve installed the language pack you need (and potentially the fonts required), you should be able to see a good candidate in the output of
locale -a, pick one and set the
LANG environment variable in
.bashrc, for example, setting it to British English:
Now let’s look at the timezone which is UTC by default, that’s fine on the CLI but might be confusing in a graphical desktop environment. To fix that, run
tzselect and edit
.bashrc file to add the environment variable for
For example, this sets the timezone to London, UK.
It’s not a one-click solution, but GNU/Linux desktop is never going to be used by people who require one-click solutions (not anytime soon).
On the compatibility, the
proot solution is almost as good as a regular
chroot on a privileged environment (regular Linux PC, or rooted Android). There are a few applications that might freeze, or crash outright, but you should be able to find replacements easily. For example, I couldn’t get Xfce running without major usability issues and that’s why I changed to use MATE.
On the performance side, the
proot solution will be a bit slower than
chroot. If your Android device has been rooted already, look at
chroot solutions such as LinuxDeploy. Either way, you won’t get hardware acceleration on the graphics but
chroot should be generally a bit faster as it is a “native” solution.