WTF.dev

A place to talk about software and stuff.

My Raspberry Pi Adventures

24 November 2021

My Raspberry Pi Adventures

Huh, so it turns out I didn’t have as much time for blogging as I had hoped for…

Raspberry Pi is obviously one of the most popular (probably the top choice?) platforms for hobbyist projects. I have used a few Pi systems for various little toy projects, but my current setup has been one of the most rewarding and satisfying hobbyist projects I have worked on. This blog post is not really a tutorial about how to set up a Pi as I have; instead I’m hoping to explain the ideas behind the setup and in particular talk about why it brings me joy.

I originally set up a Pi to interface with my 3D printer (via OctoPrint). I did add a few things onto that, like a webcam for saving timelapses of prints (which later ended up being used to stream prints to YouTube via ffmpeg). I gradually added on different functionality, such as home automation and media streaming. At this point it basically serves any functionality that a regular home server would.

Hardware Selection

This is the set of hardware I am currently using for my home server:

  • Raspberry Pi 4 B (8GB RAM)
    • I use the official Pi 4 B power supply (USB-C)
  • SanDisk MicroSDXC Card (512GB)
  • Argon One M.2 Case
  • An off-brand M.2 SSD (1TB)
  • Aeotec Z-Stick Gen5 Plus

I have the Pi connected to my home networking equipment so that it can access the LAN network and the internet via Cat6A Ethernet.

Software Selection

When I started to set up the system, I made a few decisions about the software that should be installed; primarily I wanted a 64-bit userland which at the time was not available in the official Pi OS images. I had previously used Gentoo; while there are some drawbacks, I do enjoy being able to control the characteristics and performance of the packages. There was a bootstrapping package available at the time for arm64 which I was able to use to get up and running; I also found a lot of useful information (and I pull packages from) the GenPi64 project.

One of the notable choices I made was to use an uncommon init system called runit as opposed to something like systemd; I don’t have any major issues with systemd but I enjoy how lightweight and simple runit is. My installation using runit generally boots very quickly and is fairly stable (i.e. doesn’t break too easily). I also love how easy it is to configure each service.

I did also want to have access to a container manager like Docker or Podman; I had read a bit about Podman so I embarked on the journey to install it; this ended up being an ordeal since at the time it wasn’t available for arm64 in the Gentoo repositories (although it is now). I was able to build and install all of the dependencies and eventually run arbitrary containers, although to be fair it was a painful process.

I also compile the kernel myself from the Pi official sources, to enable certain features such as USB Attached SCSI for the SSD in the case.

Server Uses

These are the main uses I’ve found for the Pi as a home server:

  • OctoPrint: 3D printer control
  • openHAB: home automation
  • multiplayer Minecraft server (works surprisingly well)
  • Jellyfin: media server
  • Pi-hole: network-wide ad blocking (later replaced by functionality in an OPNsense firewall)
  • nginx: general purpose web server
    • ports 80 and 443 are forwarded from my WAN connection to the Pi
  • chrony: NTP server
  • UniFi Controller: manage my Wi-Fi network

Advantages

Using the Pi as a home server results in a fairly robust system; while it does occasionally break when I update something or change a configuration, it’s incredibly easy to remove the MicroSD card, chroot into the OS (QEMU can make this especially easy, since it can run arm64 executables from x86_64), and fix the issue.

Since the Pi is tiny in comparison to an x86 system, its power draw is much lower (although to be fair I haven’t measured it). The fan in the Argon case rarely spins up even though I am running the daemon, so I believe it doesn’t even get warm often.

The entire system is also incredibly inexpensive versus more powerful options like getting a rack cabinet and a server.

Disadvantages

The Pi is an arm64 system, so there is less software available than there is for e.g. x86_64. However as far as server-side software is concerned, I haven’t had any issues installing from an official repository or building from source.

The processor is also a lot more limited than a typical x86 server, so generally intense applications may not run well; it’s important to have reasonable expectations for what kinds of workloads the Pi can handle. With my current setup, htop shows all four cores between 0.7% to 4%. I was able to run the PaperMC Minecraft server, but it did cause lag occasionally.