archive / 2023

My homelab: a Raspberry Pi, a second-hand mini PC and too many containers

What runs in my utility closet, why I picked a second-hand mini PC instead of a real server, how much power it all draws and what I'd do differently.

Everyone who has ever worked with Kubernetes eventually gets the urge to “set something up at home”. I suppressed that urge for years with the argument that I already see enough servers during the day. Since I went freelance, that argument is gone: I no longer have a platform team testing things for me, and I want a place where I can experiment without fear.

This is what’s in my utility closet now, half a year in.

The hardware#

DeviceSpecsCostPower (idle)
Raspberry Pi 44 GB RAM, SSD over USB 3was already in a drawer~3 W
Lenovo ThinkCentre M720q Tinyi5-8500T, 16 GB RAM, 512 GB NVMe + 2 TB SATA SSD190 euros second-hand + 120 euros of storage~9 W
Managed switch, 8 portsVLAN-capable35 euros~4 W

I bought the Pi 4 in 2020, as a successor to the original 2012 Pi that took a hundred days to arrive (that one is retired now, in a drawer, next to its plastic box). For a while the Pi 4 served as “a project I’ll finish someday”. The Pi 5 was just announced and I’m curious, but my Pi 4 does what it needs to do, so that upgrade can wait.

The mini PC is the real discovery. Companies replace these things in bulk after three or four years of leasing, and then they show up on second-hand sites for very little money. You get a proper x86 machine with a six-core CPU that’s silent, sips power and is smaller than a book. I briefly looked at a real rack server. Then I calculated the power usage, heard the fans in my head, and pictured the look on my partner’s face. So, no.

The software#

Both machines run Debian 12 “bookworm”, which came out in June. No Proxmox, no Kubernetes. I hesitated, but at home I specifically wanted not to do the same thing I do all day. Docker Compose is plenty.

On the Raspberry Pi run the things that always need to work, even when I’m messing around on the mini PC:

  • Pi-hole as the DNS server for the whole house, with ad blocking as a bonus
  • Uptime Kuma, which watches the other services and pings me when something is down
  • WireGuard, so I can reach the home network from outside without opening ports for every service

On the mini PC runs everything else:

  • Home Assistant for the thermostat, a few smart plugs and a sensor in the bathroom
  • Jellyfin for films and series we bought on DVD and Blu-ray
  • Paperless-ngx for all the paper clutter. Since I went freelance, there’s a lot of it. My accountant is particularly happy about this one.
  • Forgejo as a git server for my own projects and experiments
  • Restic for backups, more on that below

A simplified version of the Compose file on the mini PC:

services:
  homeassistant:
    image: ghcr.io/home-assistant/home-assistant:stable
    network_mode: host
    volumes:
      - ./homeassistant:/config
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped

  jellyfin:
    image: jellyfin/jellyfin:latest
    ports:
      - "8096:8096"
    volumes:
      - ./jellyfin/config:/config
      - ./jellyfin/cache:/cache
      - /srv/media:/media:ro
    devices:
      - /dev/dri:/dev/dri   # hardware transcoding via the Intel iGPU
    restart: unless-stopped

  paperless:
    image: ghcr.io/paperless-ngx/paperless-ngx:latest
    depends_on: [paperless-db, paperless-redis]
    ports:
      - "8000:8000"
    environment:
      PAPERLESS_DBHOST: paperless-db
      PAPERLESS_REDIS: redis://paperless-redis:6379
      PAPERLESS_OCR_LANGUAGE: nld+eng
    volumes:
      - ./paperless/data:/usr/src/paperless/data
      - ./paperless/media:/usr/src/paperless/media
      - ./paperless/consume:/usr/src/paperless/consume
    restart: unless-stopped

  paperless-db:
    image: postgres:15
    environment:
      POSTGRES_DB: paperless
      POSTGRES_USER: paperless
      POSTGRES_PASSWORD_FILE: /run/secrets/pg_password
    secrets: [pg_password]
    volumes:
      - ./paperless/pgdata:/var/lib/postgresql/data
    restart: unless-stopped

  paperless-redis:
    image: redis:7
    restart: unless-stopped

secrets:
  pg_password:
    file: ./secrets/pg_password.txt

Yes, there’s latest in there. Yes, I know. This is my homelab, not a client’s production. At home I’m allowed to sin.

Backups, or: why this stopped being a toy#

The moment Paperless contained my invoices and VAT documents, this was no longer a hobby project. At that point a dead SSD isn’t “a shame”, it’s a problem with the tax office.

I follow the well-known 3-2-1 rule: three copies, on two kinds of media, one of them off-site. Every night, restic makes an encrypted, deduplicated backup to an external drive and to object storage at a cloud provider:

#!/usr/bin/env bash
set -euo pipefail

export RESTIC_PASSWORD_FILE=/root/.restic-password

# Dump the database consistently first, don't copy the raw data files
docker compose -f /srv/stack/compose.yaml exec -T paperless-db \
  pg_dump -U paperless paperless > /srv/backup/paperless.sql

for repo in /mnt/usb-backup/restic "s3:https://s3.example-provider.eu/homelab-backup"; do
  restic -r "$repo" backup /srv/stack /srv/backup --exclude-caches
  restic -r "$repo" forget --keep-daily 7 --keep-weekly 4 --keep-monthly 12 --prune
done

And once a month I do a restore test into a temporary directory. A backup you’ve never restored is a hope, not a backup. Jef already told me that back in 2011, after spending an entire afternoon trying to restore a site from a tarball that turned out to be empty.

What I’d do differently#

  • Put DNS on a separate device from day one. If Pi-hole runs on the same machine as your experiments, the internet at home goes down every time you break something. Your household will not forgive you.
  • Label the cables. It takes ten minutes. It saves you an hour when you’re standing in a dark utility closet at eleven at night.
  • Don’t expose everything. Everything is only reachable through WireGuard. I have zero services directly on the internet, and I sleep better for it.
  • Measure the power draw. A smart plug in between told me the whole lot uses about 16 watts. That’s less than I feared, and less than the old NAS I got rid of.

Next steps#

On the list: VLANs to separate the smart plugs from the rest of the network (I trust cheap IoT firmware about as far as I can throw a printer), and maybe a small k3s cluster to test things for clients.

Or I could spend a weekend doing nothing at all. Meanwhile Segfault’s favourite place to sleep is on top of the mini PC. At 9 watts it stays nicely lukewarm. I suspect that’s his real reason for supporting the whole project.

    Tip: / opens search, ↑↓ to select, ↵ to open.