Repurpose Your Old Android Phone into a Linux Desktop or Smart Home Server with Termux
GitHub Repo
MIT
July 5, 2026 at 02:22 AM
0 views

Repurpose Your Old Android Phone into a Linux Desktop or Smart Home Server with Termux

@mayukh4Project Author

Repurpose Your Old Android Phone: Turn It into a Linux Desktop or a Smart Home Server with Termux

If you’ve ever wondered what to do with a stubbornly old Android device, there’s a vibrant, practical answer: give it a new lease on life as a Linux desktop or a smart home server — all without rooting, without cloud dependencies, and without needing a separate PC. The recipe is simple: Termux, a lightweight Linux environment for Android, and a few carefully chosen scripts. This guide walks you through two complementary paths you can choose (or even run on the same device): a full Linux desktop on your phone, or a Home Assistant-powered smart home hub. The process is designed to be accessible, repeatable, and entirely local.

Visual guide to the pathways

Image: https://github.com/user-attachments/assets/bb2efabe-ffff-4098-ba58-45d1e68a6aaf This diagram (referenced from the input) sketches how an old Android phone with Termux can become either a Linux desktop or a Home Assistant smart home server, with GPU acceleration for desktop use and a self-contained Home Assistant core for home automation. It’s a quick mental map of the two routes you’ll follow.

Pick your path: Linux Desktop or Smart Home Server

Two clear destinations, two distinct sets of use cases, and one footprint that fits in your pocket.

  • Linux Desktop

  • What you get: a full GUI desktop environment on your phone, ready for daily Linux tasks, development, browsing, and media consumption.

  • Use cases: learn Linux, practice Python development, run an SSH server for remote work, browse the web, watch videos, and tinker with software in a mobile-friendly desktop.

  • Script to run: termux-linux-setup.sh

  • Time: about 10–30 minutes to install, depending on network speed and chosen desktop environment.

  • Jump to: Desktop setup

  • Smart Home Server

  • What you get: a dedicated Home Assistant Core hub that talks to your WiFi devices, automations, and dashboards — all inside your Android device without cloud ties.

  • Use cases: control lights and plugs, monitor sensors, build dashboards for home automation, and access control panels from any device on your network.

  • Script to run: setup-homeassistant.sh

  • Time: about 15–45 minutes to install, with the main bottleneck often being Python package compilation inside the container.

  • Jump to: Home Assistant setup

You can run both on the same phone — they don’t conflict. They’re designed to be isolated enough to coexist, letting you enjoy both a desktop workstation and a smart home hub from the same hardware. A video walkthrough is available for people who prefer a guided, visual demonstration: https://youtu.be/tYm2rQpkOcg?si=moV59vk5J7B4h46N

Requirements: hardware and software essentials

Before you begin, gather the required gear and software. The project is accessible, but some specifications matter for smooth performance.

Hardware

  • Android phone with an arm64 (64-bit) processor
  • 3 GB+ RAM recommended (4 GB+ if you want a smoother KDE Plasma experience)
  • 5–10 GB of free storage (more if you plan to install Wine)
  • A Qualcomm Snapdragon chip is ideal for better GPU acceleration (Turnip/Adreno). The script also works with Mali and other GPUs, but the performance is lighter on those platforms.

Software

  • Termux (from F-Droid; avoid the outdated Play Store version)
  • Termux-X11 (latest apk from GitHub Releases)

Notes on rooting and ROMs

  • The tool works on stock Android as well as LineageOS and similar custom ROMs. Root access is not required by the scripts. The video demonstration uses LineageOS on a OnePlus 5T, but you can proceed on stock Android with comparable results.

Desktop environments: choosing the best fit

The desktop experience on a phone is unconventional, so selecting the right environment matters.

  • XFCE4 (default)

  • Best for most users: fast, customizable, with a macOS-style dock option

  • Resource usage: Low–Medium

  • LXQt

  • Good for older or very memory-constrained devices (2–3 GB RAM)

  • Resource usage: Very Low

  • MATE

  • Classic desktop feel

  • Resource usage: Medium

  • KDE Plasma

  • A powerful, polished experience for high-end phones

  • Resource usage: High

If you’re unsure, start with XFCE4. It provides a balanced mix of speed and usability that suits many devices and workflows.

Installation: step-by-step setup

The process is designed to be straightforward. Here are the core steps, with the essential commands you’ll run.

Step 1 — Install required apps

  • Install Termux from F-Droid.
  • Install Termux-X11 from GitHub Releases.
  • Grant both apps the necessary permissions.

Step 2 — Pre-upgrade Termux (important)

  • In Termux, run:
  • bash termux-wake-lock
  • pkg upgrade -y
  • Why this matters: termux-wake-lock keeps Termux alive when the screen turns off, preventing Android from terminating the process mid-install. Upgrading first helps avoid a known crash involving libpcre and libandroid-selinux.

Step 3 — Download and run the script

  • Execute these commands:
  • bash curl -O https://raw.githubusercontent.com/mayukh4/linux-anroid/main/termux-linux-setup.sh
  • chmod +x termux-linux-setup.sh
  • bash termux-linux-setup.sh
  • What to expect: the script will ask you to choose a desktop environment and whether you want Wine. installation takes about 10–30 minutes depending on network speed. A full log is saved to ~/termux-setup.log if something goes wrong.

Step 4 — Start your desktop

  • Start the desktop with:
  • bash ~/start-linux.sh
  • Then open the Termux-X11 app on your phone. Your Linux desktop will render inside that app.
  • To stop the desktop:
  • bash ~/stop-linux.sh

What gets installed: a quick tour of components

Here’s what appears on your system as you go through the install. The exact set may vary slightly depending on your choices, but these are the typical components.

  • Termux-X11: Display server that renders your desktop on screen
  • Desktop Environment: XFCE4, LXQt, MATE, or KDE (your choice)
  • Mesa / Zink: OpenGL via Vulkan for GPU acceleration
  • Turnip driver: Qualcomm Adreno open-source Vulkan driver (when detected)
  • PulseAudio: The audio server
  • Firefox: Full desktop web browser
  • VLC: Video and audio player
  • Git, wget, curl: Essential developer tools
  • Python 3 + pip: Python runtime and package manager
  • OpenSSH: SSH server and client for remote access
  • Wine (optional): Run Windows x86 apps through Hangover + Box64

GPU acceleration: what to expect

The script detects your GPU environment automatically. For Qualcomm Adreno GPUs (Snapdragon devices), it uses the Turnip Vulkan driver with Zink to run OpenGL on Vulkan, delivering near-native performance for supported workloads. For Mali and other GPUs, it falls back to Zink with SwRast (software Vulkan). This setup makes GPU-accelerated desktops feasible on many Android devices, especially when using XFCE4 or LXQt. The GPU configuration is stored in ~/.config/linux-gpu.sh and is automatically loaded every time you start the desktop. You can edit that file to tweak Mesa flags for advanced users.

SSH: access from a PC or laptop

OpenSSH is installed automatically, enabling you to SSH into the phone from any other device on the same Wi-Fi network.

First-time SSH setup

  • In Termux (not inside the desktop): start the SSH server and set a password:
  • # Start the SSH server
  • sshd
  • # Set your Termux password
  • passwd
  • Find the phone’s IP address:
  • ip addr show wlan0 | grep 'inet '
  • Look for the inet line (e.g., inet 192.168.1.42/24)

Connecting from a PC

  • From a Linux/macOS PC (or Windows with a terminal):
  • ssh [email protected] -p 8022
  • Port 8022 is the default Termux SSH port (not 22)

Optional SSH config for convenience

  • On your PC, you can avoid typing the full command by adding an entry to ~/.ssh/config:
  • Host myphone
  • HostName 192.168.1.42
  • User u0_a123
  • Port 8022
  • Then you can simply connect with:
  • ssh myphone

File transfer with SCP or SFTP

  • Copy a file from your PC to the phone:
  • scp -P 8022 myfile.txt [email protected]:~
  • Copy a file from the phone to the PC:
  • scp -P 8022 [email protected]:~/somefile.txt ./
  • You can also use an SFTP client (FileZilla, Cyberduck) by connecting to the same IP and port 8022.

Keeping SSH running when you close Termux

  • By default, sshd stops if Termux is closed. Keep it running by:
  • echo 'sshd 2>/dev/null' >> ~/.bashrc
  • This makes sshd start again whenever you open Termux.

Windows App Support (Wine)

If you chose to install Wine, it uses Hangover Wine with Box64 to translate Windows x86 calls to ARM64. This is suitable for many simple utilities and lightweight programs, but heavy software and modern games may not run reliably. To configure Wine:

  • Run winecfg inside the desktop environment
  • Or click the Wine Config shortcut on the desktop

Home Assistant — turn the phone into a smart home server

Turn your old Android phone into an always-on smart home hub that talks to WiFi devices without cloud dependencies. Home Assistant Core runs inside a lightweight Ubuntu container (via proot-distro) on your phone.

What it can control

  • WiFi smart lights (e.g., TP-Link Kasa, Govee, LIFX) via direct IP on your local network
  • WiFi smart plugs (e.g., TP-Link Kasa, Wemo) via direct IP
  • Cloud-connected devices (e.g., Tuya / Smart Life, Govee) via cloud API
  • Other WiFi devices like smart switches, sensors, and cameras by IP or cloud integration

Android limitations to keep in mind

  • No Bluetooth access from HA in this setup
  • No USB Zigbee/Z-Wave USB dongles without root/kernel support
  • No automatic mDNS discovery (Android 10+ blocks /proc/net/dev). You must add devices by IP or cloud API
  • No Docker or Add-ons (HA OS features). Core integrations (2000+) work, but community add-ons that require Docker won’t

Installation

  • Run the setup script:
  • bash curl -O https://raw.githubusercontent.com/mayukh4/linux-anroid/main/setup-homeassistant.sh
  • bash setup-homeassistant.sh
  • Installation takes about 15–45 minutes, with the longest step being the compilation of some Python dependencies inside the Ubuntu container.

Starting and stopping Home Assistant

  • Start:
  • bash ~/start-homeassistant.sh
  • Stop:
  • bash ~/stop-homeassistant.sh

Accessing the dashboard

  • Open a browser on any device on your WiFi network and navigate to:
  • http://:8123
  • To find the phone IP, use:
  • ip addr show wlan0 | grep 'inet '
  • The first launch may take 5–10 minutes as initial setup completes. You’ll create an admin account in the browser.

Adding devices by IP and the Tuya path

  • TP-Link Kasa devices
  1. Note the device IP from the Kasa app (Device Settings → Device Info)
  2. In Home Assistant: Settings → Devices & Services → + Add Integration → TP-Link Kasa Smart
  3. Enter the device IP; it should appear in the dashboard
  • Tuya / Smart Life devices
  1. Create a free developer account at IoT Tuya Console
  2. Create a Cloud Project, select your data center region, and add the Smart Home API
  3. In Tuya IoT console, link your Tuya app account; scan the QR code in the Smart Life / Tuya app
  4. In Home Assistant: Settings → Devices & Services → + Add Integration → Tuya
  5. Enter the Access ID and Access Secret from the Tuya console

Keeping Home Assistant running in the background

Android can suspend Termux when the app isn’t in the foreground. To keep Home Assistant running 24/7:

  • Option 1: nohup approach
  • nohup bash ~/start-homeassistant.sh > ~/hass.log 2>&1 &
  • Option 2: auto-start on Termux launch
  • Add to ~/.bashrc:
    • termux-wake-lock && nohup bash ~/start-homeassistant.sh > ~/hass.log 2>&1 &
  • The termux-wake-lock utility is essential to prevent the device from suspending the process.

Video-use-case ideas: what you can build

  • Smart home controller: Run Home Assistant 24/7 on the phone; control lights and plugs from any device on your network
  • Linux desktop for learning: A compact environment to explore Linux without investing in a separate PC
  • SSH development server: Code on your laptop and run the code on the phone via SSH
  • Python development workstation: A ready-to-use Python 3 + pip environment for learning and small projects
  • Media or file server: Serve files over your LAN with Python’s HTTP server or set up Samba for network shares
  • Network monitoring dashboard: Access both Home Assistant and system stats in a single browser

Troubleshooting: common issues and quick fixes

  • Script exits mid-install without a clear error
  • Check ~/termux-setup.log for the failing package and error line
  • Desktop doesn’t appear after starting
  • Open the Termux-X11 app manually, since the desktop renders inside that app
  • Black screen in Termux-X11
  • Stop and restart: stop-linux.sh, then start-linux.sh
  • KDE Plasma can take longer on first boot
  • Library not found or cannot link executable during install
  • This is typically the libpcre crash. Fully close Termux, reopen, run pkg upgrade -y, then re-run the script
  • Package install failures due to conflicts
  • The installer is designed to be conflict-safe. If you still see issues, check the log and consider opening an issue with device model and Android version
  • Audio not working
  • Wait a few seconds after the desktop appears for PulseAudio to initialize
  • SSH connection refused
  • Ensure sshd is running (ps aux | grep sshd)
  • Confirm you’re using port 8022 (not 22)
  • Wine doesn’t launch
  • Ensure the desktop is running, then run winecfg inside the desktop
  • Home Assistant: numpy or cryptography compilation errors
  • Switch to a proot-distro Ubuntu login and install build dependencies (python3-dev, libffi-dev, libssl-dev, cargo), then retry the virtual environment activation and installation
  • Home Assistant dashboard not loading at port 8123
  • First launch can take time; verify the process is running and that the phone and browser are on the same WiFi network
  • Home Assistant: address already in use
  • Stop any existing hass process and retry
  • Devices not discovered automatically (Android limitation)
  • Add devices by IP or rely on cloud integrations (Tuya, Govee Cloud, etc.)

Advanced notes for power users

  • Customize GPU flags
  • You can tweak ~/.config/linux-gpu.sh to force software rendering, enable debug output, or override OpenGL versions
  • Examples:
    • export GALLIUM_DRIVER=llvmpipe
    • export MESA_DEBUG=1
    • export MESAGLVERSION_OVERRIDE=3.3
  • SSH key authentication
  • Generate a key on your PC: ssh-keygen -t ed25519
  • Copy the key to the phone: ssh-copy-id -p 8022 [email protected]
  • After this, SSH logins will be passwordless
  • Auto-start the desktop when Termux opens
  • Edit ~/.bashrc and uncomment:
    • # bash ~/start-linux.sh
  • How the conflict-safe installer works
  • Termux’s package ecosystem contains conflicting packages. The installer’s safeinstallpkg function reads conflict declarations and skips risky installations automatically, allowing the setup to complete safely on a broad range of devices
  • Termux path considerations
  • Paths are now generalized with $PREFIX, so the script works on custom Termux installs and multi-user setups
  • Licensing and contributions
  • The project is MIT licensed, encouraging use, modification, and sharing

Images and visual references

  • Visual diagram: the mayukh_builds diagram referenced in the input provides a quick view of the two paths (Linux Desktop and Home Assistant) and how they connect to an old Android phone. You can reference or reopen the image for a quick mental map of the workflow.
  • Image: mayukh_builds (3)
  • URL: https://github.com/user-attachments/assets/bb2efabe-ffff-4098-ba58-45d1e68a6aaf

Conclusion: a compact, flexible upgrade for an aging device

Turning an old Android phone into a Linux desktop or a Home Assistant smart home server is a practical, gratifying project. It gives you a portable Linux workstation and a robust, private home automation hub in a single device. The scripts are designed to minimize friction, handle GPU acceleration intelligently, and keep things local—no cloud lock-in, no root required. Whether you’re learning Linux, building automation dashboards, or simply wanting a compact, always-on server you can carry in your pocket, this approach makes the most of hardware that would otherwise collect dust.

If you try this setup, share your experience: which desktop environment did you prefer on your phone, what devices did you integrate with Home Assistant, and what tips helped you during installation? The best part of projects like this is the community knowledge that grows with every new device and use case. Happy repurposing!

Enjoying this project?

Discover more amazing open-source projects on TechLogHub. We curate the best developer tools and projects.

Project
repurpose-android-phone-linux-termux
Created
July 5
Last Updated
July 5, 2026 at 02:22 AM

Find more projects like this

One email a week: new and trending developer tools, fresh comparisons, and what shipped. Unsubscribe in one click.