If you have an old phone lying around or like to experiment on your current devices, Termux is probably my favorite app. I decided to use an old Samsung phone, specifically my wife’s old Samsung phone, to build a pocket Linux server. My plan is to use the server as a home for my Syncthing drive that’s more convenient and portable for my purposes.
For this to work, you’ll want to download and install Termux from F-Droid4 ways Python has turned my Android phone into the ultimate homelab companion I turned my Android phone into a homelab without buying anything new.
As with any project, there are some steps you must follow for diving in. For purposes of this experiment, I’ll go over what I did with my device. I used an old phone. I performed a factory reset, followed by a de-bloat using Canta and Shizuku. After that, I installed an APK of F-Droid and grabbed Termux from there.
Then, I followed our handy guide to installing Linux on Android. I chose to install Ubuntu using proot-distro install [your Linux distro container]. I selected Ubuntu.
Since I’m setting up my pocket server to use Syncthing, I figured it would be easier to have a desktop interface, so I downloaded Andronix (an app that installs your Linux distro and a desktop for it) and RVNC (a server where you interact with your Linux desktop).
After running the Andronix > Termux > RVNC Server process, I had Ubuntu running on my wife’s old phone.
Getting onto Ubuntu wasn’t difficult, although it felt like the installation through Termux took an eternity to complete. I immediately loaded the Terminal Emulator and punched in apt install syncthing. It installed the application just fine. So far, so good. I opened the web browser. Instant input/output error. Modern versions of Ubuntu use snaps for packages, but they won’t work on the phone.
This is because proot-distro doesn’t have root access and can’t use systmd. Essentially, running in a containerized environment. Fortunately, there was a workaround.
There’s a hidden world of apps that Google really doesn’t want you to find. Here are three of them that are accessible through Termux. On the desktop instance of Ubuntu, I tried using Dillo, but it didn’t work because it doesn’t support JavaScript (Syncthing requires it). I also tried Falkon, but Ubuntu really didn’t like it.
So, I ditched the GUI and ran everything straight through Termux. I set up a new user, so I wouldn’t be running Syncthing as root. Although you’re running Linux through Termux, you can use a standard browser that’s already on your phone to access your server. I used Vivaldi for this setup because I tend to prefer its speed and ease of use over other browsers.
It’s also less temperamental than trying to use a modern browser inside what is essentially a shared kernel container.
Things ran much more smoothly when I switched to just the command line. I switched users and launched Syncthing by typing syncthing into the command line on Termux. To open the Syncthing GUI, you need the GUI Listen address, which is 127.0.0.1:8384 . It only listens for connections from the same computer running Syncthing, making it a safer option. I set up a username and password to further increase security.
Then, I set up a folder in Syncthing (using the same method I have in the past) and attached the two other devices I’ll be using with it. The devices need to be connected to the same Wi-Fi network so they can talk to each other. Beyond that, connecting devices with Syncthing is straightforward.
I upload music or other files to be instantly accessible from any shared device.
I can use this to help my workflow. I take a lot of pictures for articles. Getting them to my computer is easier with something like this, simply because I’ll take them with the same phone (the camera still works fine), save them to my synced folder, and then just download them on my connected machine.
Keeping the server running without interruptions is probably the biggest challenge when using this type of setup. Termux already helps with offering a wake lock, which you can turn on using termux-wake-lock to prevent the phone from going into a deep sleep.
Since I’ll be using this device daily and keeping it on, adjusting battery settings to prevent the phone from going into power-saving mode (and killing the app), and preventing your browser from killing the Syncthing GUI by disabling page preloading. And since it’ll likely be plugged in constantly, keep an eye out for battery swelling.
Building a pocket server from an old, unused phone is a great way to learn and get more hands-on with self-hosting. I like the flexibility of a pocket server and the low cost. I will say this experiment was definitely one of the more complex ones I’ve done with Termux.
Starting with a desktop version was a mistake, when the CLI worked just fine for a headless server. Given the hassle, challenge, and limitations of this project, but as a fun weekend or “because I can” home lab project, I think it’s worthwhile to dive in and do some hands-on learning/experimentation.