Linux on Android — Repurpose Your Old Phone
Turn any old Android phone or tablet into a Linux desktop or a smart home server — no PC, no root, no cloud. Just Termux.
One script installs a GPU-accelerated desktop (XFCE4, LXQt, MATE or KDE Plasma) using native Termux packages and Termux-X11 — with Turnip/Zink hardware acceleration on Snapdragon, Firefox, VLC, Python, SSH, and optional Wine for Windows apps. A second script turns the phone into an always-on Home Assistant server with HACS.
Quick start
In Termux from F-Droid, with the Termux-X11 app installed:
pkg upgrade -y && curl -fsSL https://raw.githubusercontent.com/mayukh4/linux-android/main/termux-linux-setup.sh | bash
Then bash ~/start-linux.sh and open Termux-X11. Home Assistant instead? Swap in setup-homeassistant.sh. Full walkthrough below.
Created to accompany a YouTube video walkthrough. Timestamps are referenced in the video description.
graph LR
A["📱 Old Android Phone<br/>+ Termux"] --> B["🖥️ Linux Desktop<br/><i>termux-linux-setup.sh</i>"]
A --> C["🏠 Smart Home Server<br/><i>setup-homeassistant.sh</i>"]
B --> D["GPU-accelerated DE<br/>Firefox, VLC, SSH, Wine"]
C --> E["Home Assistant Core<br/>Control lights & plugs"]
Pick your path
|
Linux Desktop |
Smart Home Server |
| What |
Full GUI desktop environment on your phone |
Home Assistant hub that controls WiFi devices |
| Use cases |
Learning Linux, Python dev, SSH server, web browsing, media |
Control smart lights/plugs, automation, dashboards |
| Script |
bash termux-linux-setup.sh |
bash setup-homeassistant.sh |
| Time |
10–30 min |
15–45 min |
| Jump to |
Desktop setup |
Home Assistant setup |
You can run both on the same phone — they don't conflict.
Watch the full build

▶ Repurpose Your Old Android Phone — full walkthrough — every step in this README, on video, with timestamps in the description.
Requirements
Hardware
- Android phone with an arm64 (64-bit) processor
- 3 GB+ RAM recommended (4 GB+ for KDE Plasma)
- 5–10 GB of free storage (more if you install Wine)
- A Qualcomm Snapdragon chip is ideal — it enables the best GPU acceleration (Turnip/Adreno). The script works on Mali/other GPUs too but performance will be lighter.
Software
| App |
Where to Get It |
| Termux |
F-Droid — do not use the Play Store version, it is outdated |
| Termux-X11 |
GitHub Releases — download the latest .apk |
Note on rooting / custom ROMs: This script works on stock Android too. The video demonstrates it running on LineageOS on a OnePlus 5T. Rooting is not required by the script itself.
Desktop Environments — Which One to Choose?
| # |
Desktop |
Best For |
Resource Usage |
| 1 |
XFCE4 (default) |
Most users. Fast, customizable, macOS-style dock |
Low–Medium |
| 2 |
LXQt |
Old or low-RAM phones (2–3 GB) |
Very Low |
| 3 |
MATE |
Classic desktop feel |
Medium |
| 4 |
KDE Plasma |
Powerful phones only — Windows 11 style |
High |
If you're unsure, go with XFCE4.
Installation
Step 1 — Install required apps
Install Termux from F-Droid and Termux-X11 from GitHub (links above). Grant both apps any permissions they request.
Step 2 — Pre-upgrade Termux (important — do this first)
Open Termux and run:
termux-wake-lock
pkg upgrade -y
The termux-wake-lock command keeps Termux alive when your screen turns off — without it, Android can kill the process mid-install. The pkg upgrade brings your base system up to date before the script runs, preventing a known crash involving libpcre and libandroid-selinux.
Step 3 — Run the script
curl -fsSL https://raw.githubusercontent.com/mayukh4/linux-android/main/termux-linux-setup.sh | bash
The script will ask you to choose a desktop environment and whether you want Wine. Everything else is automatic.
Prefer to read it before running it? Download first:
curl -O https://raw.githubusercontent.com/mayukh4/linux-android/main/termux-linux-setup.sh
less termux-linux-setup.sh
bash termux-linux-setup.sh
Installation takes 10–30 minutes depending on your internet speed. Each package shows a live timer and the latest download line, so you can tell a big download from a real hang. A full log is saved to ~/termux-setup.log. Re-running the script is safe — anything already installed is skipped.
Unattended install (no questions)
Pass choices as flags, and -y to accept defaults for anything not given:
curl -fsSL https://raw.githubusercontent.com/mayukh4/linux-android/main/termux-linux-setup.sh | bash -s -- --de kde --no-wine -y
| Flag |
Meaning |
--de xfce|lxqt|mate|kde |
Desktop to install (default xfce) |
--wine / --no-wine |
Windows app support (default: no) |
-y, --yes |
Don't ask anything |
-h, --help |
Show all options |
setup-homeassistant.sh takes --hacs / --no-hacs and -y the same way.
Step 4 — Start your desktop
bash ~/start-linux.sh
Then open the Termux-X11 app on your phone. Your Linux desktop will appear inside it.
To stop:
bash ~/stop-linux.sh
What Gets Installed
| Component |
Details |
| Termux-X11 |
Display server — renders your desktop on screen |
| Desktop Environment |
Your choice: XFCE4, LXQt, MATE, or KDE |
| Mesa / Zink |
OpenGL via Vulkan — enables GPU-accelerated graphics |
| Turnip driver |
Qualcomm Adreno open-source Vulkan driver (if detected) |
| D-Bus |
Session message bus — required by every desktop's settings daemon |
| PulseAudio |
Audio server |
| Firefox |
Full desktop web browser |
| VLC |
Video and audio player |
| Git, wget, curl |
Standard developer tools |
| Python 3 + pip |
Python runtime and package manager |
| OpenSSH |
SSH server and client — remote access from your PC |
| Wine (optional) |
Run Windows x86 apps via Hangover + Box64 |
GPU Acceleration
The script detects your GPU automatically using hardware properties (not brand name — Samsung ships both Adreno and Mali phones depending on region, so brand detection is unreliable).
Qualcomm Adreno (Snapdragon phones): Uses the open-source Turnip Vulkan driver + Zink (OpenGL on Vulkan). Near-native GPU performance.
Mali / Other GPUs: Falls back to Zink + SwRast (software Vulkan). Functional but lighter desktops (XFCE4, LXQt) are strongly recommended.
Zink comes from Termux's own mesa package ($PREFIX/lib/dri/zink_dri.so), which has shipped it since Mesa 23. The script only falls back to the third-party mesa-zink build on installs whose Mesa genuinely lacks Zink, or that already have mesa-zink from an earlier run — the two stacks ship the same library filenames and cannot be mixed.
The GPU environment is saved in ~/.config/linux-gpu.sh and loaded automatically on every start-linux.sh. You can edit that file to tweak Mesa flags.
Check what the desktop is actually using, from a terminal inside the desktop:
# Which Vulkan driver did the loader pick?
vulkaninfo --summary | head -30
# Which OpenGL renderer is in use? Should say "zink"
glxinfo -B | grep -i "renderer\|opengl version"
SSH — Access Your Phone from a PC or Laptop
OpenSSH is installed automatically by the script. This lets you SSH into your phone from any computer on the same Wi-Fi network — useful for running commands, transferring files, or doing development work on a proper keyboard.
First-time SSH setup
Open a terminal in Termux (not inside the desktop — the regular Termux app) and run:
# Start the SSH server
sshd
# Set your Termux password (you'll use this to log in over SSH)
passwd
Find your phone's IP address:
ip addr show wlan0 | grep 'inet '
The output will look like inet 192.168.1.42/24 — your IP is the part before the /.
Connect from your PC or laptop
On your computer (Linux, macOS, or Windows with Terminal):
ssh your-termux-username@192.168.1.42 -p 8022
Port 8022 is the default Termux SSH port (not the standard port 22, which requires root).
To find your Termux username, run whoami in Termux. On most setups it will be something like u0_a123.
Simplified login with SSH config (optional)
On your PC, add this to ~/.ssh/config to avoid typing the full command every time:
Host myphone
HostName 192.168.1.42
User u0_a123
Port 8022
Then you can connect with just:
ssh myphone
File transfer with SCP or SFTP
Copy a file from your PC to your phone:
scp -P 8022 myfile.txt u0_a123@192.168.1.42:~/
Copy a file from your phone to your PC:
scp -P 8022 u0_a123@192.168.1.42:~/somefile.txt ./
Or use any SFTP client (like FileZilla or Cyberduck) — connect to the same IP and port 8022.
Keep SSH running when you close Termux
By default sshd stops when Termux is closed. To keep it running persistently:
# Add to your ~/.bashrc so sshd auto-starts whenever Termux opens
echo 'sshd 2>/dev/null' >> ~/.bashrc
Windows App Support (Wine)
If you chose to install Wine, it uses Hangover Wine with Box64 to translate Windows x86 calls to ARM64. Simple tools and utilities tend to work; heavy software or games may not.
To configure Wine, run winecfg in your desktop terminal or click the Wine Config shortcut on your desktop.
Home Assistant — Smart Home Server
Turn your old Android phone into an always-on smart home hub that controls WiFi smart lights, plugs, and other devices — accessible from any browser on your network.
Home Assistant Core runs inside a lightweight Ubuntu container (via proot-distro) on your phone. No root, no cloud dependency for local devices.
What it can control
| Device Type |
Brand Examples |
How it connects |
| WiFi smart lights |
TP-Link Kasa, Govee, LIFX |
Direct IP on your local network |
| WiFi smart plugs |
TP-Link Kasa, Wemo |
Direct IP on your local network |
| Cloud-connected devices |
Tuya / Smart Life, Govee |
Via cloud API (works everywhere) |
| Other WiFi devices |
Smart switches, sensors, cameras |
By IP or cloud integration |
Limitations on Android
- No Bluetooth — HA cannot access the phone's Bluetooth stack through Termux
- No USB dongles — Zigbee/Z-Wave USB sticks won't work without root and kernel support
- No auto-discovery (mDNS) — Android 10+ blocks
/proc/net/dev, which breaks Zeroconf. You must add devices by IP address or cloud API instead of relying on automatic detection
- No Docker/Add-ons — This is HA Core, not HA OS. Community add-ons that require Docker won't work. Core integrations (2000+) work fine.
Installation
curl -fsSL https://raw.githubusercontent.com/mayukh4/linux-android/main/setup-homeassistant.sh | bash
Unattended: ... | bash -s -- --hacs -y. Run bash setup-homeassistant.sh --help for all options.
Installation takes 15–45 minutes depending on your phone. The longest step is compiling Home Assistant's Python dependencies (numpy, cryptography, etc.) inside the Ubuntu container.
Starting and stopping
# Start Home Assistant
bash ~/start-homeassistant.sh
# Stop Home Assistant
bash ~/stop-homeassistant.sh
# Upgrade to the newest version your container's Python supports
bash ~/upgrade-homeassistant.sh
HACS — the community add-on store