How I abuse my Raspberry Pi into being a server

published on 26-VIII-2021

~The beginnings~

During one sunny day we finally upgraded our home internet from 6mbps up / 1mbps down ADSL to an FTP cable that is able to transport whopping 95 megabytes per second! Symmetric! (they say temporarily, until they upgrade the area with gigabit fiber. But I'm not sure when we'll see that day come).

What did this mean? What possibilities did this internet upgrade open?

I could

finally

host stuff from my own home

!!!

So I thought

Heck! I'll buy a Raspberry Pi 4 4Gb and I'll play around with having it running as a server in the corner of the room.

And I got that Pi 4. I wanted to do this for a while now, probably since it went selling (but not worth it if I didn't have internet bandwidth); because compared to the Pi 3, this was the 4 looked promising as a small and low power server, Despite the Pi 3 it had a more capable CPU, the ethernet port was gigabit and has USB 3 (that I planned to use with SATA 3 adapters).

The MEAT

image1

After some experimenting with distros I found out that Alpine Linux is one of the distros that work and integrate best with the Raspberry Pi's hardware. Arch Linux was having random crashes very often and as I later found out Debian was the same but they didn't occur as often; so Alpine Linux it is, light AF and stable. Probably no one running a server wants it to stop working and become unresponsive out of nowhere.

It started as a network drive server, I connected a 1 Tb laptop hard disk and used it as a miniature NAS. Experimented with FTP, SFTP, Samba and now I settled on Samba for local access and SFTP for remote. It also ran Transmission Daemon for seeding, that was its main task for a while.

Matrix

Then one day, originating from a random discussion, I really wanted to see a Matrix Space hosted and running on my Raspberry Pi, see how chats are taking place inside that little thing.

This Matrix homeserver is the reason I tried Debian after running Alpine for a bit because I had problems with anything Python on Alpine. Even now when I'm back on Alpine I'm running synapse on a docker container.

This was the first time I hosted a more substantial piece of software, so I was completely fascinated by the idea of how other people can have chats by moving bits in some silicon connected to a copper wire that goes out of my house and somehow, by traveling unbelievably long distances, gets to these people. They are indirectly right in my house. Absolutely mindblowing to think about. Even though each one of us does this everyday these days I was still blown away by the idea, it sounds silly.

XMPP

Prosody! Easy to install, overall really nice experience to set up. Logged in on my phone and computer and it seemed to work.

The reason I set it up was because I suddenly wanted to start to developing one particular thing related to XMPP, without even having used it before.. So I wanted to get that user experience from XMPP so I know what's up. Hopefully I'll get to it properly at one point.....

For phone and video calls I also had to set up coturn, not on the Pi but on a VPS outside the house... Yeah... For some reason calls don't always connect. I might come back here and do an edit if I find why it does that.

Nextcloud

Some time passes and I start to think that just installing Nextcloud will be a lot more convenient than what I was already doing - using Samba and SFTP alone. Especially when considering the SFTP client I had set on my smartphone was a bit shotty and even stopped working in the end (RCX for Android, nice app, it is an Rclone GUI for android basically).

It's also been useful with syncing things like contacts and calendars on my degoogled phone so that's nice.

It loads a bit slowly but works. I tried to stay away from it because I knew it would be slow though...


And now the meat of all them meats:

Misskey!

It was only natural for me to want to try and host a fediverse instance myself. At the time Pleroma seemed like the default way to go, but I thought, if I'm going to go to it why not try something a little more exotic like Misskey. 'Aight, so the plan for the future was settled... but then after I let some time pass something happened:

a trend started on my side of the fediverse. People were trying out Misskey all of a sudden. So I thought I'd join in, in the heat of that moment, and not wait any longer.

In this same timeline I wanted to make the Matrix server suck less and also have enough storage for the Misskey instance. So I got a cheap 240 Gb SSD to plug into the Pi. But what I didn't know is that a Raspberry Pi normally can't power both a hard disk and an SSD at the same time by itself. So I also had to get a cheap USB 3 hub with external power.

I couldn't get it to compile on either my install of Alpine 3.14 on my Pi or Arch Linux on my desktop. Not sure why, maybe because Node is only a few versions newer than what they use in their Docker image (Alpine 3.13 with Node)? So I gave up on running it on native and used Docker.

It works fine under Docker but it takes a while for Misskey to compile on the Raspberry Pi, so it would make sense to compile on my desktop then transfer it over. Problem is that with Docker there is no convenient way of doing that. You see the Pi is ARM, I think you already knew that, - and my desktop is x86, I also think you already assumed that. I tried to use Docker Buildx which uses qemu or something to work. I was able to make it work but for some reason it was building even slower than the Pi itself so it's not worth it.

So for now I have to wait maybe about an hour for Misskey to build on the Pi itself whenever I want to upgrade to a new version.

But how well does it run?

It is definitely usable, not bad at all. But it isn't uncommon at all for some CPU threads to go at 100% because of Misskey, because I clicked on an image from a post to preview it at full quality. Using more than one worker helps a lot, which can be set in Misskey's config file (.config/default.conf); I now have it set to 4, my number of cores.

So there you have it

Let's count: I run 1 2 3... 4 different services on one Raspberry Pi 4! If you don't call that abuse I don't know what you'll call it.

And I didn't even count the Samba server and Transmission daemon.

This little thing might not be the fastest for some tasks but is damn impressive. It does all of these things while being small and power efficient, compared to a normal traditional server which may be just a computer tower or even a laptop

(one of my more power efficient yet very capable laptops has a power brick of 65w, my good-for-nothing Intel Atom netbook has a 25w brick, this thing has a 15w USB-C charger, but I'll also couple it with a 10w USB hub externally powered by a phone charger).