How to install Arch Linux ARM on Android phone (Termux Proot-distro)

🇹🇼 中文版

Proot-distro of Termux allows you to install Linux distributions on your Android phone. No root required. Proot-distros are containers, which are limited but still possible to run some dekstop appliations in it.

In this article, I will guide you to install Proot Arch Linux ARM with a Desktop Environment from scratch (kind of) in Termux.

You would have to install the whole system from command lines.

1. Prerequisites

WARNINGS:

  • Proot-distro is not a fully GNU/Linux system. It’s a container.
  • You cannot start systemd services in proot.
  • Make sure your device has 10GB+ storage and 4GB+ RAM.
  1. Install Termux.

  2. Install RealVNC Viewer.

  3. Disable Phantom killing on Android 12+ devices.

2. Install Proot Arch Linux base system

Scroll down the top menu, press ACQUIRE WAKELOCK to keep Termux running in the background.

  1. Install proot-distro, pulseaudio, vim
1
2
pkg update
pkg install proot-distro pulseaudio, vim
  1. Edit .profile with vim:
1
vim .profile
  1. Add these lines:
1
2
3
# Start pulse auadio server after launching Termux
pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1
pacmd load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1
  1. Install Proot Arch Linux (base system)
1
proot-distro install archlinux
  1. Login to Arch Linux
1
proot-distro login archlinux

3. Switch mirrors and update system pacakges

  1. (Optional) Go to mirror list to pick a fastest mirror in your country. Then edit /etc/pacman.d/mirrorlist with vi. Replace every link before $repo to the mirror link.

  2. Update system

1
pacman -Syu

4. Add a normal user

  1. Change password of root
1
passwd
  1. Add a new userivon. Then add him to group wheel and change his password.
1
2
3
pacman -S sudo vim
useradd -m -g users -G wheel,audio,video,storage -s /bin/bash ivon
passwd ivon
  1. Add user ivon to sudoers. Edit/etc/sudoerswith vi, add following lines beneath"root ALL=(ALL) ALL":
1
ivon ALL=(ALL) ALL
  1. Make sure you login to Arch as a normal user. Never login as root.
1
2
su ivon
cd
  1. Edit~/.profile with vi, add following lines:
1
2
# Start pulse audio server in proot after login
export PULSE_SERVER=127.0.0.1 && pulseaudio --start --disable-shm=1 --exit-idle-time=-1

5. Install a Desktop Environment and common tools

  1. Install Firefox, Noto Fonts, SSH, TigerVNC and other common tools
1
sudo pacman -S vim firefox networkmanager xorg xorg-server pulseaudio noto-fonts git openssh fakeroot base-devel tigervnc neofetch
  1. Install yay - the AUR helper:
1
sudo pacman -S --needed git base-devel && git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si
  1. Edit /etc/makepkg.conf with vim. Uncomment MAKEFLAGS="-j2". Change -j2 to -j + (2 x phone processor cores). This could speed up AUR compiling time.

  2. Install XFCE4 Desktop environment

1
sudo pacman -S xfce4 xfce4-goodies lightdm
  1. Or install KDE Plasma (WARNING: It’s huge)
1
2
sudo pacman -S plasma-meta
yay -S tablet-mode

6. Configure VNC server

VNC server is the easiet way to connect to the desktop envirment. By the way it’s possible to login from VNC client on PC in the same network.

  1. Create a password for vncserver
1
vncpasswd
  1. Add following lines to ~/.vnc/config
1
2
3
4
5
# The session we want to start
session=xfce4
# Screen resolution
geometry=1920x1080
localhost
  1. Add following lines to ~/.vnc/xstartup, so it will execute XFCE4 after starting vncserver.
1
2
3
4
5
6
#!/bin/bash
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
export PULSE_SERVER=127.0.0.1 && pulseaudio --start --disable-shm=1 --exit-idle-time=-1
# Execute XFCE4
dbus-launch --exit-with-session startxfce4

7. Timezone & hostname & locales

  1. Setup timezone
1
sudo ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
  1. Edit ``/etc/hostnameand/etc/hosts` to rename your machine.

  2. Edit /etc/locale.gen, uncomment your language, for example en_US.UTF-8

  3. Generating locales

1
2
sudo locale-gen
echo "LANG=en_US.UTF-8" >> /etc/locale.conf

8. All done

Congrats! Now you have installed Arch Linux on your Android phone! Read below to learn how to log in and log out.

  1. Launch Termux, login to Arch Linux as a normal user.
1
proot-distro login --user ivon archlinux
  1. Starting a vncserver, the ports starts from 5900.
1
vncserver :1
  1. Launch RealVNC Viewer, add new connectionlocalhost:5901 and type in password to connect to the vncserver。

  2. Click i to adjust picture quality. Now you are good to go, try to run some desktop programs!

  3. To log out, first close VNC Viewer. Then go back to Termux, press CTRL+Z to stop vncserver. Finally type exitto log out from the proot-distro。

9. Some tips & tricks

9.1. If Proot audio not working

  1. Run this command in Proot-distro:
1
export PULSE_SERVER=127.0.0.1 && pulseaudio --start --disable-shm=1 --exit-idle-time=-1
  1. Run this command in Termux (not in proot!)
1
2
pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1
pacmd load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1

9.2. Access Android internal storage from proot-distro

Proot-distro will automatically bind mount Android internal storage to /sdcard directory.

9.3. Backup proot system

Backup your proot system:

1
proot-distro backup --output archbackup.tar.gz archlinux

Restore your proot system:

1
proot-distro restore archbackup.tar.gz

9.4. Run desktop environment in XWayland server

Why? Because the performance would be better.

See: How to use Termux-X11 - The XWayand server on Android phone

10. Further readings

If this article is helpful to you please consider supporting me.