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

Make sure your device has 10GB+ storage and 4GB+ RAM.

  1. Install Termux

  2. Install Termux X11

  3. Install virglrenderer

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. Install Proot Arch Linux (base system)
1
proot-distro install archlinux
  1. Login to Arch Linux
1
proot-distro login archlinux  --user root --shared-tmp

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 useruser. 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 user
passwd user
  1. Add user user to sudoers. Edit/etc/sudoerswith vi, add following lines beneath"root ALL=(ALL) ALL":
1
user ALL=(ALL) ALL
  1. Make sure you login to Arch as a normal user. Never login as root.
1
2
su user
cd

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
  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

6. 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

7. Start desktop enviornment manually

Congrats! Now you have installed Arch Linux on your Android phone! Read below to learn how to desktop enviornment manully.

  1. Relaunch Termux

  2. Launch Termux X11 app, keep it opening in the background. Go back to Termux and type the following commands to run Termux X11.

1
2
3
4
5
6
7
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

export DISPLAY=:0
termux-x11 :0 &

virgl_test_server_android &
  1. Login to Arch Linux as a normal user.
1
proot-distro login archlinux --user user --shared-tmp
  1. Start desktop environment
1
2
3
export DISPLAY=:0
PULSE_SERVER=tcp:127.0.0.1
dbus-launch --exit-with-session startxfce4 &
  1. You shall see XFCE4 desktop showing at Termux X11. Tap flaoting window and revoke permission to make it go full screen.

8. Start desktop environment in one-click

We can use Termux Widget to start everything automatically. Thanks to Korean developers’ tutorial!

  1. Install Termux API and Termux Widget

  2. Go to system settings β†’ all apps, turn on “Permit Drawing Over Other Apps” for Termux.

  3. Restart Termux. Create a shortcut in Termux (not in proot-distro)

1
2
mkdir .shortcuts
vim .shortcuts/startproot_arch.sh
  1. Type these
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#!/bin/bash

killall -9 termux-x11 Xwayland pulseaudio virgl_test_server_android termux-wake-lock

termux-toast "Starting X11"
am start --user 0 -n com.termux.x11/com.termux.x11.MainActivity
XDG_RUNTIME_DIR=${TMPDIR}
termux-x11 :0 -ac &
sleep 3

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

virgl_test_server_android &

proot-distro login archlinux --user user --shared-tmp -- bash -c "export DISPLAY=:0 PULSE_SERVER=tcp:127.0.0.1; dbus-launch --exit-with-session startxfce4"
  1. Make it executable.
1
chmod +x .shortcuts/startproot_arch.sh
  1. Go to your home screen, long press and add widgets β†’ select “Termux Widget”. You would see the shortcut we made is on the list.

  2. Click “startproot_arch.sh” then the XFCE desktop would opened automatically.

  3. Swipe down the notification bar, click Preferences of Termux X11. Then you can switch touch screen mode to simulating touchpad.

  4. To use soft keyboard of phone in Termux X11, swipe the bar at the bottom and you will see a field for inputing texts.

  5. If the fonts are too small in Termux X11, click Settings Manager at top-left β†’ Appearance and change font size or select 2x window scaling.

  6. To stop the XFCE session, press CTRL+C in Termux. Then logout of proot Arch Linux.

1
exit

Further readings


Thanks for your reading. You are welcome to share articles of Ivon's Blog (ivonblog.com). Please include the original URL when reprinting or citing articles, and abide by CC BY-NC-ND 4.0 license. For commercial use, please write an e-mail to me.

written by human, not by AI

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

Leave a comment

Choose the commenting system you like.

Please login to your Github account to leave a comment. You can post codes here for discussion. For images, please upload to Imgur and copy links. Your comments would be visible to everyone on Github Discussions.

This comment system is provided by Disqus, you may see some Disqus ADs on this page. You can leave a comment anonymously but you won't receive reply notifications.