Return to index

Turning a old phone into a Raspberry Pi-like server with PostmarketOS

If you're reading this article, chances are that you're either in a rough situation financially or are just looking to give your old phone a second life after rotting in the drawer for many years. In this post, we're taking a deep dive into a Linux distro made for mobile, PostmarketOS.

About PostmarketOS

PostmarketOS is a Linux distribution for mobile devices most of the times running on ARM processors. It is practically a copy of Alpine Linux with additional patches to make your phone work as best as it can. While the ultimate goal of this project is to give older phones a more up to date system as evident by their mission statement of "We are sick of not receiving updates shortly after buying new phones" on their homepage, it's far from "daily-drive" ready on most mobile devices. For example, SMS and calls for vast majority of phones do not work yet, let alone 3D acceleration. It is still possible to use this for a microserver.

How do I get it?

First, check on the PostmarketOS wiki if your device is supported. If not, reach out to the good folk on their relevant chat platforms either on IRC or Matrix - they won't bite you! Make sure your device has public kernel source code available (blasphemy for those OEMs that blatantly violate GPL!). Now in the case your device is supported, follow the instructions on your device's wiki page. Once you're done with it, you should be greeted with any desktop environment you chose (or if none, exposed ssh over USB).

Case example "micros3m"

Now that you are up to speed about PostmarketOS, here's how I turned my Samsung Galaxy S III Mini into something that could be used as a tiny server.

s3mini.jpg The Galaxy S III Mini running Phosh.

The installation part was straightforward - I started off by unlocking the bootloader and flashing U-Boot. Rest of the process was very simple and described in the respective wiki page.

I had a choice to either to get rid of the user interface and rely on my wireless connection never failing me or leave Phosh installed so I can easily diagnose on-device if I lose connection to it. While I do not have exactly a specific server task in mind at moment and use it as a backup Matrix session instead, there's still a lot of things to do with a Linuxified phone, for example, if you have a 64-bit (aarch64) phone, you will likely be able to run Pi-hole on it (no luck with armv7, army of compile errors for the architecture on FTL). You have an entire repository of libraries and applications you can use to program something new. You can take a look at the Alpine Linux packages repository to see everything that is available by default through the package manager. You can create a simple OpenVPN server or client if you compile your kernel with tunnel support. You can run your favourite scripting language powered application, you get full access to the ports on your device. To show how simple it is to use PostmarketOS, I made a quick and dirty "status monitor" page in php as example and hosted it on a nginx webserver also powered by the phone all within a few minutes.

s3mini-php.png Running a PHP script on nginx on a phone.

This is essentially a fully fledged Linux distribution on your phone with full access to Alpine Linux package repository. You can essentially do anything that you can do with a Raspberry Pi excluding the GPIO pins (unless you dare to touch the internals of the device). Alpine Linux has a reputation for being extremely lightweight and it shows - you will be able to squeeze the most out of your old phone. It would be a waste to not try this out on a old phone. However, not all phones are created equal...

Alternative method in Android

If you happen to have a locked down device (carrier lock, etc) or don't want to flash anything, there is still hope. Good work has been put towards an app called Termux that you can get on F-Droid. Termux is a proot environment that is also quite extensible and debian-like - there's even a community made Arch Linux chroot for Termux. This is ultimately the safer method to reutilise your phone or even use your current working phone as a mini-server. Do note, that there is a big overhead with Termux as you are more constrained by artificial limitations of Android and lack a ton of kernel modules you could otherwise have used. This also has the short-coming of Android eating quite a bit of your system resources. Another compromise this method has is the fact that you are going to run out-of-date software, seemingly keeping the tradition of Debian going strong. On a more serious note, they do this to assure the packages actually work properly, rather than mindlessly pumping out updates. PostmarketOS can and will run many more programs with less compromises made if your intent is to repurpose a phone.

Thanks for reading!


Socials & where to find me

Matrix space: #main:cernodile.com

Matrix DM: @joann:cernodile.com