Post

Use Gnu/Linux on Android

Amogus

Requirements:

  • A Android phone with enought storage
  • GNU/Linux installed PC or VM
  • Basic commandline knowledge
  • Root access for chroot method

Chroot method

  1. Install Chmount script to mount rootfs: Chmount github repository

  2. Download Distro RootFS:
  3. Extract Rootfs and copy to phone

exapmle: tar -xvf debian-rootfs.tar.gz -C && adb push debian-rootfs /data/debian-rootfs

Note: You can extract rootfs on your phone using Termux or any other terminal emulator

Do not extract rootfs under NTFS filesystems. NTFS does not support symlinks!

Do not move rootfs to internal storage. Internal storage is mounted with noexec flag. You can’t execute any binary from internal storage!

  1. Open your favorite Terminal emulator and: type su and chmount /path/to/extracted_rootfs bash

Note: You can use any shell or you can start a graphical environment using VNC or XServer

Proot method (Termux)

  1. Install Termux from F-Droid

Google Play Store version of Termux is outdated and it’s not supported by Termux developers.

  1. Install proot and wget using pkg install proot proot-distro
  2. proot-distro install <distro_name>

Note: You can list all available distros using proot-distro list

  1. proot-distro login <distro_name>

Configure GUI

Install DE or WM on your distro (optional)

  • Debian: apt install xfce4
  • Archlinux: pacman -S xfce4
  • Alpine: apk add xfce4

Note: You can use any DE or WM you want but I recommend lightweight DEs like XFCE4, LXDE, LXQT, MATE, etc.

VNC

  1. Install VNC Viewer from F-Droid
  2. Install VNC Server on your distro:
    • Debian: apt install tightvncserver
    • Archlinux: pacman -S tigervnc
    • Alpine: apk add tigervnc
  3. Start VNC Server with DE or app: vncserver & xfce4-session

Note: You can start Full DE or single app. You can also start multiple VNC servers on different ports.

  1. Open VNC Viewer and connect to localhost:1

XServer

Android

  1. download and install XServer XSDL
  2. open XServer XSDL and start server
  3. open your favorite terminal emulator and type export DISPLAY=:0 && startxfce4

Note: You dont need to run full desktop environment. You can run single app using export DISPLAY=:0 && <app_name> or you can run multiple apps using export DISPLAY=:0 && <app_name> & <app_name> & <app_name> & ...

Windows

  1. download and install Xserver. some of them are:
  2. Enable public access to Xserver
  3. Open your favorite terminal emulator and type export DISPLAY=<ip_address>:0 && startxfce4

Note: ip_address is the local ip address of your PC

This post is licensed under CC BY 4.0 by the author.