Turn an Old Android Phone into a 24/7 Low-Power Home Server with Termux & PRoot-Distro
Most of us have at least one old Android smartphone gathering dust in a drawer. It might have a scratched screen, outdated software, or sluggish gaming performance, but underneath that glass lies surprisingly capable hardware: an octa-core ARM processor, 3GB to 8GB of RAM, high-speed flash storage, Wi-Fi, and a built-in battery that acts as an integrated uninterruptible power supply (UPS).
Instead of letting it become e-waste or spending $80+ on an overpriced single-board computer, you can turn that old handset into a silent, 24/7 mini Linux home server that consumes less than 3 to 5 Watts of power.
Following up on our guides on setting up cloud servers and automating tasks with Termux and Tasker, this weekend project walks you through installing a full Linux distribution (Ubuntu/Debian) on Android via Termux and PRoot-Distro, enabling remote SSH access, configuring autostart, and keeping the battery healthy for long-term reliability.
Why an Old Phone Beats a Raspberry Pi
Before jumping into the commands, consider why an old Android phone is one of the best homelab platforms for lightweight workloads:
- Built-in UPS: If your house loses power, the server doesn’t shut down or corrupt your filesystem.
- Ultra-Low Power: An idle smartphone draws between 1.5W and 3W—costing pennies a month on your electricity bill.
- Integrated Display & Network: You already have a screen for debugging, dual-band Wi-Fi, Bluetooth, and optional 4G/5G failover.
- Zero Added Cost: You’re giving high-quality silicon a second life for free.
Step 1: Install Termux the Right Way (Skip Google Play)
Important Note: Do not install Termux from the Google Play Store. The version on Google Play has been deprecated due to Android SDK target requirements and no longer receives repository updates.
Instead, download the latest build from F-Droid or the official Termux GitHub releases:
- Download and install Termux from F-Droid (or grab the APK from GitHub).
- Also download Termux:Boot from F-Droid (we will need this to start our server automatically on phone reboots).
Prevent Android from Killing Termux
Android’s aggressive battery management will kill background tasks unless you exempt Termux:
- Go to Android Settings > Apps > Termux > Battery and set it to “Unrestricted” (or disable battery optimization).
- Disable any vendor-specific “battery savers” (like Samsung’s Put to Sleep or Xiaomi’s MIUI Battery Saver).
Step 2: Initialize Termux & Prevent Sleep
Launch Termux. First, acquire a wake lock so Android’s CPU governor doesn’t throttle background processes into deep sleep when the screen turns off:
termux-wake-lock
You will see a persistent notification in your status bar indicating that Termux is holding a wake lock. Now, update the base packages:
pkg update && pkg upgrade -y
Tip: If prompted about configuration files during upgrades, press Enter to keep default versions.
Step 3: Enable Remote Access via SSH
Typing long Linux commands on a mobile virtual keyboard gets old quickly. Let’s install OpenSSH so you can control your phone headlessly from your PC or Mac terminal.
pkg install openssh -y
Set a password for your Termux user:
passwd
Start the SSH server:
sshd
Now check your phone’s local IP address on your home Wi-Fi:
ip -4 addr show wlan0
Note down your IP (e.g., 192.168.1.150). On your computer, open your terminal or PowerShell and connect:
ssh 192.168.1.150 -p 8022
Note: Termux runs SSH on port 8022 by default because non-root Android apps cannot bind to privileged ports below 1024.
Step 4: Install a Full Linux OS with PRoot-Distro
While Termux offers plenty of native packages, many standard tools and services expect a standard Linux root filesystem with apt, standard glibc paths, and system directories. PRoot-Distro provides a chroot-like environment without requiring root permissions.
Install PRoot-Distro:
pkg install proot-distro -y
You can see the list of available distributions by running proot-distro list. We’ll install Ubuntu:
proot-distro install ubuntu
Once downloaded and unpacked, enter your new Ubuntu environment:
proot-distro login ubuntu
You are now running root inside a full Ubuntu userspace! Update your Ubuntu repositories and install essential developer tools:
apt update && apt upgrade -y
apt install curl wget git nano python3 python3-pip -y
Step 5: Bonus Project 1 – Expose It Securely with Cloudflare Tunnels
In our earlier guide on Cloudflare Zero Trust, we discussed how Tunnels allow you to reach local servers without port forwarding or dynamic DNS. You can run Cloudflare’s tunnel agent (cloudflared) directly on your Android phone!
Inside Termux, grab the official ARM64 binary:
# Download official ARM64 cloudflared binary
curl -L -o cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm64
chmod +x cloudflared
mv cloudflared $PREFIX/bin/
Test an instant zero-config tunnel pointing to any local port (for example, port 8000):
cloudflared tunnel --url http://localhost:8000
Cloudflare will generate a public https://<random-id>.trycloudflare.com URL. You can share this link or connect to it from any browser on any network—complete with SSL, bypassing your home router’s firewall and carrier CGNAT completely!
Step 6: Bonus Project 2 – Lightweight Python Status Dashboard
Want a clean, dark-mode web page showing your Android server’s CPU load, memory, and battery status? Here is a zero-dependency Python script using standard library modules.
Create a file named server_stats.py:
import http.server, socketserver, json, subprocess, time
from datetime import timedelta
PORT = 8000
def get_stats():
# Uptime
with open("/proc/uptime", "r") as f:
uptime = str(timedelta(seconds=int(float(f.readline().split()[0]))))
# Load
with open("/proc/loadavg", "r") as f:
load = " ".join(f.readline().split()[:3])
# Memory
with open("/proc/meminfo", "r") as f:
lines = dict(l.split(":") for l in f if ":" in l)
tot = int(lines["MemTotal"].strip().split()[0]) // 1024
free = int(lines.get("MemAvailable", lines["MemFree"]).strip().split()[0]) // 1024
mem = f"{tot - free} MB / {tot} MB ({int(((tot-free)/tot)*100)}%)"
return uptime, load, mem
class Handler(http.server.BaseHTTPRequestHandler):
def do_GET(self):
up, ld, mm = get_stats()
html = f"""<html><head><meta name="viewport" content="width=device-width,initial-scale=1">
<style>body{{background:#0f172a;color:#f8fafc;font-family:sans-serif;display:flex;justify-content:center;align-items:center;height:100vh;margin:0;}}
.c{{background:#1e293b;padding:24px;border-radius:12px;border:1px solid #334155;min-width:280px;}}
h2{{color:#38bdf8;margin-top:0;}} p{{margin:8px 0;font-size:14px;}} b{{color:#94a3b8;}}</style></head>
<body><div class="c"><h2>Android Server</h2><p><b>Uptime:</b> {up}</p><p><b>Load:</b> {ld}</p><p><b>RAM:</b> {mm}</p></div></body></html>"""
self.send_response(200)
self.send_header("Content-Type", "text/html")
self.end_headers()
self.wfile.write(html.encode())
with socketserver.TCPServer(("", PORT), Handler) as s:
print(f"Server running on port {PORT}")
s.serve_forever()
Run it in the background with:
python3 server_stats.py &
Now visit http://<your-phone-ip>:8000 from any device on your Wi-Fi (or pair it with the Cloudflare Tunnel above to check it on the go).
Step 7: Autostart Everything on Reboot (Termux:Boot)
If your phone ever restarts, you want your wake lock, SSH server, and scripts to initialize automatically without having to unlock the device.
- Open the Termux:Boot app once after installing from F-Droid to grant startup permissions.
- Inside Termux, create the boot scripts directory:
mkdir -p ~/.termux/boot/ - Create a startup script named
start-server.sh:nano ~/.termux/boot/start-server.sh - Add the commands you want executed on startup:
#!/data/data/com.termux/files/usr/bin/sh termux-wake-lock sshd python3 /data/data/com.termux/files/home/server_stats.py & - Make the script executable:
chmod +x ~/.termux/boot/start-server.sh
Crucial: Battery Care & Safety for 24/7 Operation
Lithium-ion smartphone batteries are not meant to remain at 100% charge under continuous heat indefinitely. Over months, this can cause the battery to swell (the “spicy pillow” effect).
Protect your hardware with one of these strategies:
- Smart Plug Automation (Recommended for unrooted phones): Plug the phone’s charger into a smart plug (Sonoff, Tuya, Kasa). Use Home Assistant or an automation script to charge the phone when battery drops below 30% and turn off power when it reaches 80%.
- Simple Mechanical Timer Plug: If you don’t have smart plugs, an inexpensive mechanical outlet timer set to provide power for 1 hour every 4 hours works surprisingly well.
- Charge Limiters (For Rooted Phones): If your phone is rooted, install apps like Battery Charge Limit or Advanced Charging Controller (ACC) to cap charging strictly at 65–70%.
- Keep It Cool: Remove bulky protective cases and keep the phone in a well-ventilated area standing upright or on a wire rack.
Summary
With just Termux, PRoot-Distro, and a few terminal commands, you can turn a retired smartphone into a resilient, silent, zero-cost home server. It’s an ideal sandbox for learning Linux, running background automations, and experimenting with networking without touching your daily driver computer.