How i turned my old phone into home server

Turning some old cheap phone into something useful

Me and my friend have the same old phones — Samsung Galaxy A50, so once he accidentally broke his new phone, he switched back to his old one. One day he came up to me with an idea to install custom ROM on his device, because I used to be pretty into android custom ROMs, and on my old phone it's already installed.

For some reason I couldn't install custom recovery on his phone, we actually have almost the same revision, but that give me an idea to turn my old phone to something useful.

My first thought was about to turn my old phone into a home camera that is going to shoot outside for 24/7. Once I did that, I understood that this wasn’t the best idea.

Performance was terrible, yeah, live stream and using camera at the same time wasn't a good idea, and picture quality also wasn't good.

Then I had another idea to try to turn it into some kind of server (or at least host some scripts on it with termux).

It's important to know that my device was already rooted with custom recovery and PixelOS port, and most of the things bellow operated via termux.

Once I get to realization of my idea, first my thought was to open ssh connection to do all things from pc.

That was really easy, and with that I opened sftp port, termux have a really good [documentation].

Termux don't have things like systemd, instead they have "termux-services", and honestly I hate that thing, I mean if comparing this to systemd, it's too small and simple and loss of basic functions like checking status of running service.

Although I didn't have a choice, it's either termux-services or nothing.

With termux-services I set up auto run sshd and some other little things

The first thing I launched for test is minecraft server, and surprisingly, performance was really good, although I played alone on an empty server))

But I was already surprised that a thing like 2019 cheap phone is capable of running such a complex thing, I guess you can do it even without a root.

I also launched some of the little basic scripts just to make sure everything works fine

The most interesting part, so to be a real actual server, you definitely need docker. But how can we run docker on android?

There are two ways of running docker on android:

  1. creating VM inside termux and then run docker (bruh)
  2. rebuilding your device kernel to add native docker support

I chose a second way because I wanted max performance and I wanted a little challenge, I've never built linux kernel in my life and especially kernel for my device.

Thanks god I had a [instruction] for adding docker support and modifying kernel, BUT this wasn't a kernel build guide though)

So that was my plan—grab any most popular opensource kernel for my device, try to build it with myself, and then start modifying it.

I used [Mint kernel]

To just build kernel, I spend the whole day. I tried everything, but I always had the same error. The only way I build kernel for the first time was only via CI/CD. BTW for building kernel on my machine, I used wsl with Ubuntu-24.04. It turns out a problem was in the ubuntu version, for some reason some important package broke in 24.04, so I had to roll back to 22.04.

After I finally just built the kernel, I started modifying it, and there was a second problem. I spend on it another day. So basically, in the root of a project there was a config file that stores every option that I need, the problem was if I actually changed that config, there were no effects on the build. Thanks god the kernel that I grabbed have a discord server. I just asked some of their contributors, it turns out their kernel auto generates a root config file based on an internal config file, and this was a solution.

You can find out the completed kernel for my device [here]

After I finally just run docker's hello-world on my device, I was truly happy. There were some other little problems, like docker-compose wasn't working properly, but I fixed them quickly.

Unfortunately, android docker supports only host network mode, bridge mode works unstable, but I can live with that.

Right now I have 16 docker containers running, including services like:

and some others

Everything works stable, except that for some reason my phone restarts every 5–7 days, but it's not a problem for me.

Homarr Beszel Portainer