Jump to content

Archlinux container in Termux with graphical environment


Recommended Posts

Hello,

In case of someone would be interested, I try archlinux container in termux with Xfce and it works perfectly for the pro1 with Xserver-XSDL apk. It also works with VNC but without sound.
I can now listen music, use Libreoffice and firefox and play with my programming tools.

Pro1's keyboard works prefectly (qwerty version here)

Very nice discovering a new linux distro.
It's not so hard and the documentation is very complete.
 
Source installing archlinux :
https://github.com/SDRausty/termux-archlinux

When you have done this, $ startarch (in Termux) and you will go in a root session.
Then if you want to create a User, (using sudo for root) :
$ startarch c 'addauser user'
$ startarch l user

Dont forget this in order to make LibreOffice working (in Termux):
$ bash setupTermuxArch.sh re

Make this working with XSDL server :
https://github.com/sdrausty/TermuxArch/issues/73
 

Screenshot_20211006-081456_XServer_XSDL.png

  • Like 8
  • Thanks 2
Link to post
Share on other sites

Nice job! Always good to see I am not the only one using the Pro1 as an actual computer ... 😎

4 hours ago, raymo said:

It also works with VNC but without sound

By using XRDP as a wrapper around VNC, you can forward sound from the VNC session to an RDP client (I recommend MS Remote Desktop 8 as it seems to work best with the Pro1's keyboard). This way you do not need a separate XServer on Android, and the Linux session can run in the background when disconnected. I gave an overview about such a setup in another thread. I do not use termux, but I guess it cannot install XRDP and the required PulseAudio drivers for you. You'll have to do that yourself from within your Arch system.

As I explained in this post, it is even possible to get rid of VNC altogether by using the (better performing) native X.org-backend of XRDP. However, that is even more complicated as it requires traditional shared-memory access from the Linux system.

Happy hacking.

  • Like 1
  • Thanks 1
Link to post
Share on other sites

@claude0001 Thanks for your answer. I must say, for me it's awesome what you've done, as I'm not a power-user like you. A Debian CLI with full access in Android, whaow ! So Geil !
It's very interesting, however I'm not sure I have the level to do that (not yet, but you really help opening my mind).

I play a little whith termux, scripting inside Arch in order to automatize display and launching Xfce.
However I don't find solution launching XSDL apk from bash script yet, and java and object-oriented programming languages is not my cup of tea (not yet ?).

As Archlinux run in a container inside Termux, I have full access inside the data/data/com.termux directory. So I'm planning doing something at this level for external files managment.

The really fun is ability controlling hardware parts and toast in lineage via termux-api inside my Linux desktop. I will be happy playing with this for a little time I guess 😄

Edited by raymo
typo
  • Like 2
Link to post
Share on other sites
4 hours ago, raymo said:

I play a little whith termux, scripting inside Arch in order to automatize display and launching Xfce.
However I don't find solution launching XSDL apk from bash script yet,

Termux is a nice project and has some interesting features. But as an in-app solution, I guess it will always be somewhat limited. That is why I decided to install everything from scratch by myself. Note that, in the beginning, I also knew nothing about chrooting Linux distros on phones: the Pro1 is my first Android device. Do not give up!

The reward for all the work and learning is that I have now a GNU/Linux distro running really in parallel to LineageOS, which allows me to use the Pro1 like an actual PC, while neither disturbing the Android environment nor depending on it in any way (except for the kernel, of course). I can SSH into my Pro1 for CLI access or file transfer. I can remote-desktop into it, which will spawn a fresh KDE desktop or reconnect to an existing session. I can start arbitrary GNU/Linux background processes via cron. All without relying on any supporting Android apps -- though it is of course possible and useful (thanks to the keyboard!) to have Android SSH or RDP clients ready for accessing the GNU/Linux environment on-device.  

Yes, it was some work to get there. But it seemed like this was the only way the Pro1 could at last replace my beloved N900 ... 😉 

Edited by claude0001
  • Like 3
Link to post
Share on other sites

Do you mean a Linux distro running really in parallel with Android like @claude001 ?

I'm digging into this, but it will take me lot of time with learning so for this I can't help you at this moment.

For setting the archlinux container in Termux I can maybe help you.

Link to post
Share on other sites
4 hours ago, PokeParadox said:

I've not got around to trying again, do you have a more recent set of steps I could follow? I don't seem to have much luck getting this set up.

I am ready to help, but I would first need to know what you are failing at ...

Please have a look at this post, and try to understand it, following the links I provided.

The first step is to prepare an SD-card with a partition containing the GNU/Linux distribution. This is best done from an existing (x86) Linux-PC using qemu as described in the first link of my post. As most modern Linux distros are based on systemd (which cannot run in an Android chroot), I suggest Devuan which uses traditional System-V init. It is possible to change the init system also in vanilla Debian, but that adds one more layer of complexity to the project you may want to avoid. 😉

Upon startup of LineageOS, that "Linux" partition of the SD-card is mounted via the Chroot script attached to said post of mine. Then, the script starts a few services within the Chroot environment, the most important ones being SSH and XRDP. On LineageOS, running the script can be automated by placing it into /data/local/userinit.d and installing the Run Userinit App from F-Droid. Note that the App -- as the Chroot script itself -- requires a rooted LineageOS.

With the SSH and XRDP servers running in the background, they can then be used for accessing the GNU/Linux environment, either remotely or by using suitable Android client-apps on the Pro1 itself.

Of course, you cannot just copy my Chroot script blindly. You should install your own system step-by-step, adjusting the script as required. Obviously, it is also good to first test the individual commands from an interactive (root) shell of LineageOS before trying to automate things using the script.

If we continue this discussion, it should probably be moved to another/a new thread, as this is explicitly about not using Termux now ...

Edited by claude0001
  • Like 3
Link to post
Share on other sites
  • 3 months later...

Some time ago, I recommended Devuan as my GNU/Linux distribution of choice for installation in a chroot of LineageOS.

Today, I wanted to upgrade my xrdp-pulseaudio modules (providing seamless sound forwarding to Android when using my X11 desktop) and found out that installing them on Devuan is not possible in a straightforward way using the tools provided on neutrinolabs' GitHub repo.

The reason is that the drivers need to be compiled against the pulseaudio sources matching the version of each respective distribution. On Devuan, the command:

# sudo apt build-dep pulseaudio

fails, probably because of some unresolvable (and likely unnecessary) dependencies on systemd.

So how to proceed? Disregarding the (non-)dependence of some packages on systemd, Devuan 3 (which I use) is binary-compatible with upstream Debian 10. So, if I had an ARM64 version of the latter, I could build the drivers and just copy them over to my Devuan 3 system.

Luckily, there is schroot. It allows to seamlessly install and use a a foreign Linux distribution within one’s main OS. We install a minimal Debian 10 ('buster') system in an directory /var/chroot/buster. Note that all this will (temporarily) require at least ~1 GB of SD card space, make sure you have enough.

# sudo apt install debootstrap schroot
# sudo mkdir /var/chroot/buster
# sudo debootstrap buster /var/chroot/buster http://deb.debian.org/debian

After that, create the config file for the new distribution in /etc/schroot/chroot.d/buster.conf:

[buster]
description=Vanilla Debian 10 'buster' for package compilation
directory=/var/chroot/buster
root-users=<YOURUSER>
users=<YOURUSER>
type=directory 

Enter your new Debian 10 system as root:
 

# schroot -c buster -u root

install sudo in Debian 10:
 

> apt install sudo 

Then, edit the the sudoers file in the chroot
 

> visudo

adding a line like
 

<YOURUSER>    ALL=(ALL:ALL) ALL

Save the sudoers file, exit the schroot and re-enter as regular user
 

> exit
# schroot -c buster

For clarity, we use "#" to symbolize the Devuan 3 CLI prompt, and ">" for that of the Debian 10 'guest OS'.

And, yes, we are in fact running a Debian 10 inside a chroot of a Devuan 3 which is, itself, running in a chroot of LineageOS. If you are not confused at this point, consider yourself hardcore. If you are, do not worry, we hold you. Either way, take a minute to meditate on the fact that the concepts taking us this far in 2022 were developed ~42 years ago in UNIX v7.

Install the minimally necessary dev tools in the schroot:

> sudo apt install build-essential dpkg-dev libpulse-dev git autoconf libtool

Get the pulseaudio sources for Debian 10:
 

> sudo echo "deb-src http://deb.debian.org/debian buster main" >> /etc/apt/sources.list
> sudo apt update
> cd ~
> apt source pulseaudio

Get the build dependencies for pulseaudio (as we are in vanilla Debian 10, this should work now):
 

> sudo apt build-dep pulseaudio

Configure the pulseaudio sources:
 

> cd pulseaudio-XX.Y 
> ./configure

Clone the GIT repo with the xrdp driver sources:
 

> cd ~
> git clone https://github.com/neutrinolabs/pulseaudio-module-xrdp.git

Compile the driver modules:
 

> cd pulseaudio-module-xrdp
> ./bootstrap && ./configure PULSE_DIR=~/pulseaudio-XX.Y
> make

Of course, running the provided “make install”-script from within the Debian 10 chroot does not make sense, as that would install the drivers only in the Debian 10 'guest', but not in the Devuan 3 'host', which is what we want. Either leave the schroot and run the installer script in Devuan 3, or just copy the drivers to /usr/lib/pulse-XX.Y/modules/ and configure pulseaudio manually, which is what I do. The compiled .so’s are in ~/pulseaudio-modules-xrdp/src/.libs/ .

After successful compilation and driver installation, you may delete the Debian 10 schroot in /var/chroot/buster to free up some SD card space. You might also choose to keep it around as a dedicated building environment, allowing you to (re-)compile more stuff without polluting your 'main' distribution with hundreds of dev packages.

Have fun!

Edited by claude0001
Fixed awkward formatting of body text. Further clarified a few things.
  • Like 2
  • Thanks 2
Link to post
Share on other sites
  • 2 months later...

Hi @claude0001

Just wanted to leave a big thank you for your guide on Chroot installation. Been looking to reuse an "old" android to run a media server at home with radarr/sonarr either by pulling containers from linuxserver.io using docker or just setting up everything without docker.

Not sure if you ever tried but have you successfully run docker inside your Chroot distro ? I ask this because apparently android kernel has features disabled that docker requires to be enabled.

..

Link to post
Share on other sites
47 minutes ago, savvy said:

Not sure if you ever tried but have you successfully run docker inside your Chroot distro ?

I am not sure if "recycling" an old Android device to run any Linux home servers is worth the trouble, considering how cheap and powerful RaspberryPis (or similar single board computers) have become. They provide a full-featured and well-supported GNU/Linux environment, with Docker just an "apt install" away. With Android chroots, you'll always be on your own to solve any issues emerging (trust me on that 😉 ).

I do not know about Docker on Android. Yes, it seems like a lot depends on what your kernel provides. I would guess that installing everything manually in a chroot should always be possible somehow. But I have no experience with those servers you want to set up. 

 

Link to post
Share on other sites

It's not so old a phone, to be fair it is running android 11 and had 12 before that. It's just the unknown of its performance under such environment (snapdragon 625). I just wanted to give it a go before I go down another route. I know I could do a not so good home media server variant by using android apps only, but it'd be great to have plex (directplay), radarr & sonarr. Hell, I even have a thin client which I could easily set up to be honest, but I would like to keep it down to phone size.

Trying to compile an android kernel as I type (for the very first time) with those docker features enabled. If I fail in the end, oh well.. I'll resort to android only or the thin client as I don't really wish to spend £80 on a RPI, although I've been wanting to have one to tinker with for ages lol

 

Link to post
Share on other sites
On 10/6/2021 at 6:21 PM, claude0001 said:

Nice job! Always good to see I am not the only one using the Pro1 as an actual computer ... 😎

 

You're not the only one, I've been using my Pro1 as a laptop more than a phone since February 2020 (but using a different setup, my host is Sailfish)! And I am not ready to stop anytime soon, the Pro1 really is great at that use case. :]

Very happy to see that there are more and more solutions to achieve similar results.

Edited by matf
Link to post
Share on other sites

@matf
Nice, I've planned trying sailfish OS but I'm not aware with android apk compatibility and the use of gps (I often use openstreetmap). Is this possible in SFOS ?
However the (unofficial) port looks awesome, what a good work !!
 

Link to post
Share on other sites

We have a great GPS application with offline support and it supports OSM, but indeed it is difficult to get a GPS fix in SailfishOS since the Mozilla location thingie has been discontinued (very long and how long it'll take is hard to predict). Android apps can be run with compatiblity layers: either the official one (proprietary and not available for community ports normally, but tinkerers found ways to use it if they had a paid licence aside from the port) or Waydroid (free and open source). They have some limitations which usually are related to hardware access (camera, BT) or apps that have stringent requirements (some bank apps), but this varies.

There is a thread in this forum about running Debian and a desktop WM within SFOS using LXC, where I posted a demo video. But what you showed with Arch is really great, and will surely be of interest for a higher number of users as an Android-based solution!

Edited by matf
  • Thanks 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms