I would like to set up Canonical hosted Ubuntu Base image for arm on my Android phone.
I need a simple step by step answer on how to get started.
I would like to be able to use Ubuntu to run apps on my phone, without rooting it.
See this question for app installation.
Setting up Ubuntu in Termux involves three parts,
Simplest method - If you don't want to get your hands dirty, install Termux, and simply download either Andronix (Website, GitHub) or AnLinux, and install Ubuntu 20.04 with them. These apps provide the scripts to download and extract the base image, to install desktop environments (e.g. XFCE), and setup the VNC server, which you simply need to copy-paste in Termux.
User interface of Andronix
How to use it?
When done, enter the command
./start-ubuntu20.sh
to open Ubuntu, and the commandexit
to leave Ubuntu. Once you start Ubuntu, enter the commandvncserver-start
to start the VNC server (with the XFCE desktop), and the commandvncserver-stop
to stop it. (unfortunately, it is namedubuntu20
, although it is actually Ubuntu 20.04, not Ubuntu Core 20. Once you get an idea how the script works, you can rename everything toubuntu20.04
, or anything else)Some of the entries (e.g. uptime) are wrong due to fake
/proc
entries, otherwise recent versions of Android would not let Ubuntu work.How to access XFCE desktop with VNC Viewer?
Install a VNC viewer app in Android, e.g. VNC Viewer - Remote Desktop, or androidVNC. And open the address
localhost:5901
to connect to the VNC Server. Tip: Choosequality: high
, or24-bit color (4 bpp)
for better picture quality. Also,VNC Viewer - Remote Desktop
supports the portrait as well as landscape mode very well. Other VNC viewers don't seem to have good support for the portrait mode.Applications running in XFCE desktop. I installed Tango icon theme and Arc GTK theme
However, these apps will download the Ubuntu Base from their GitHub repo (where they have saved a copy), not from Canonical's website. All the scripts in these apps are available in their GitHub repositories under free licenses.
What does this script do?
This script downloads the Ubuntu rootfs image for the architecture of your device, and then sets it up to work with proot. Recent versions of Android (v10, v11) impose some restrictions, and that is why this script creates fake entries in
/proc
to fool Ubuntu and Android into functioning normally.Enabling Sound
Andronix has made a script to enable sound. Run the following command in a termux (Not Ubuntu) shell.
To use sound
Start Ubuntu in a Termux shell, and open another Termux shell (don't open Ubuntu there). Run
pulseaudio --start
in the new Termux shell (not in Ubuntu), and now Ubuntu would be able to play audio. Audio demonstration - Youtube VideoNote that the file
setup-audio.sh
is cryptic (probably so that the competitor's of Andronix cannot use it), and its human readable form can be found here. It is so cryptic that people at Unix & Linux Stack Exchange thought that it could be a malware, but I have verified that it is not.Slightly complex method - combine step 1. and 2. in one go (but download the images from Canonical, not from Andronix's GitHub repo).
Andronix has an automated script for downloading the rootfs, installing the DE, and then setting up the VNC server.
However, the Andronix script downloads the rootfs from their GitHub repo (a renamed version of the Ubuntu 20.04 (not 20.04.2) rootfs), not from Canonical's server.
We will modify the script to use the image from the Canonical's server instead. First install wget and nano in Termux (if already not installed), and then download the script.
Now open the script in Nano.
Change the contents of
line 29
(use either Hacker's keyboard or scrcpy - see Tips:#6. Otherwise it is hard to edit in a mobile device),to the following
Now save the file (ctrl + x), and run it.
Now head on to How to use it? and How to access XFCE desktop? (in previous parts of the answer). You can optionally follow Enabling sound to enable sound.
System requirements:
Security
By default, Ubuntu rootfs cannot access the files in your Android phone. Data in Termux is isolated from other data in Android. And you can easily delete all files in Termux (including Ubuntu) by deleting the application data in Android settings. However, I bear no responsibility for any kind of issue arising from following this answer. The number of stars in GitHub would give you an idea about how many people are using these scripts. They are not malware.
Tips:
700x1500
(in portrait mode) works very well in my 6.5 inch phone screen.start-ubuntu20.sh
/startubuntu.sh
to access the internal storage and sdcard of your phone.su -s username
, and give them sudo access.quality: high
, or24-bit color (4 bpp)
in the VNC Viewer for better picture quality.Feel free to edit this answer to make it better.