Skip to content

Instantly share code, notes, and snippets.

@schappim
Created November 6, 2025 07:15
Show Gist options
  • Select an option

  • Save schappim/5c6e8ad2925f6cb086edebc225d476d6 to your computer and use it in GitHub Desktop.

Select an option

Save schappim/5c6e8ad2925f6cb086edebc225d476d6 to your computer and use it in GitHub Desktop.

1) Measure (so you know what to kill)

systemd-analyze
systemd-analyze blame
systemd-analyze critical-chain

These show kernel vs userspace time and the slowest units. (wiki.archlinux.org)

2) Hardware + firmware quick wins

  • Boot from NVMe (Pi 5) and put it first in the boot order:

    sudo -E rpi-eeprom-config --edit
    # e.g. try NVMe first, then SD:
    BOOT_ORDER=0xf416

    (Right-to-left order; f=retry). (jeffgeerling.com)

  • Keep only the devices you’ll ever boot from in BOOT_ORDER (don’t include USB/network if unused) to avoid probe timeouts. (Volumio Community)

3) Filesystem: remove boot blockers

  • Read-only root (overlayfs) via raspi-config (“Performance → Overlay FS”). This avoids fsck and journaling delays.

    • On Bookworm, raspi-config sets overlayroot=tmpfs; if external drives turn read-only, change to overlayroot=tmpfs:recurse=0 (or tune /etc/overlayroot.conf). (Raspberry Pi Stack Exchange)
  • If you can’t go RO, at least add fsck.mode=skip to /boot/firmware/cmdline.txt (or /boot/cmdline.txt pre-Bookworm) to skip filesystem checks on clean boots. (Ask Ubuntu)

  • Mount noatime on your RW partitions to cut write work during boot. (General Linux best-practice.)

Bookworm moved the boot partition to /boot/firmware—that’s where config.txt/cmdline.txt live now. (Raspberry Pi)

4) Kill waits and unused hardware

  • Headless? Disable radios and audio in /boot/firmware/config.txt:

    dtoverlay=disable-wifi
    dtoverlay=disable-bt
    dtparam=audio=off
    

    (Saves driver init time.) (Raspberry Pi Stack Exchange)

  • Don’t block on networking at boot:

    • Mask whatever “wait-online” you have (varies by image):

      sudo systemctl mask systemd-networkd-wait-online.service || true
      sudo systemctl mask NetworkManager-wait-online.service || true

      Or configure wait-online to --any / specific interface only. (wiki.archlinux.org)

    • If you use dhcpcd, run it in background (doesn’t hold boot) or use a static IP. (bbs.archlinux.org)

  • Boot to console, not desktop (unless you need a GUI):

    sudo systemctl set-default multi-user.target

    Then only start your app. (You can still launch a compositor later.)

5) Trim userspace to the bone

Disable services you don’t need (examples—pick from your systemd-analyze blame output):

sudo systemctl disable --now bluetooth.service hciuart.service avahi-daemon.service triggerhappy.service

Re-run systemd-analyze blame and repeat until only essentials remain. (Red Hat Documentation)

6) Optional but impactful

  • Remove serial console from /boot/firmware/cmdline.txt if you don’t use it (drop console=serial0,115200 so the kernel isn’t spewing to UART).
  • Autologin straight to your app (TTY): make getty@tty1 autologin and exec your binary; or even use init=/usr/bin/your-app to make your process PID 1 for ultra-fast boots (advanced; you must mount /proc,/sys,/dev yourself). (docs.kernel.org)
  • Custom/minimal OS (Buildroot/BusyBox + only built-in drivers + LZ4 kernel): this is how folks get ~2–3s to app on older Pis; <5s is easy. (bootlin.com)

7) A concrete “<5s” recipe (Pi OS Lite → headless service)

  1. NVMe first in BOOT_ORDER and update EEPROM. (jeffgeerling.com)
  2. Enable overlay FS (or add fsck.mode=skip). (Raspberry Pi Stack Exchange)
  3. systemctl set-default multi-user.target and mask wait-online. (wiki.archlinux.org)
  4. Disable Wi-Fi/BT/audio overlays and unneeded services. (Raspberry Pi Stack Exchange)
  5. Autostart your app on TTY1; keep network coming up in the background.

That combo typically lands around 1–2s kernel + 2–3s userspace on Pi 5 with NVMe—i.e. ~3–5s to your app. Community reports show even ~4.0–4.5s to a full desktop with aggressive trimming. (forums.raspberrypi.com)


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment