Source linked

Filippo's NAS Boots Entirely From Initramfs - No Rootfs Needed

words.filippo.io@systems_wire1 hour ago·Systems Engineering·3 comments

A single initramfs image containing a full Alpine Linux system makes deployment atomic, rollbacks trivial, and configuration git-trackable. No package manager at boot, no SD card wear.

alpine linuxinitramfsfilippo valsordazfsdeclarative systemsnas

Filippo Valsorda's home NAS, frood, boots from a single initramfs that contains a complete Alpine Linux system. No root partition. No overlay files. No package manager running at boot to fix missing packages. The whole thing is a cpio archive, built from a git repo, and rolled back by picking a different entry in the bootloader.

If that sounds like a dream after wrestling with lbu(1) apkovl files or NixOS derivations, it is. And it works.

Why Erase the Root Filesystem at Every Boot

Valsorda cites Graham Christensen's "Erase your darlings" pitch: systems accumulate undocumented state in /etc, /var, and friends. Every under-documented "touch /etc/ipsec.secrets or the l2tp tunnel won't work" is a landmine for the next rebuild. Running from memory (initramfs) wipes that state clean on each reboot.

Alpine's built-in "diskless mode" uses an apkovl overlay to persist changes, but that mechanism depends on the package manager running during boot to install missing packages. Over the past year, Valsorda saw that break multiple times - filesystem not found, apks not installed, boot stalls. The complexity of lbu(1) plus Ansible plus overlay save cycles became a multi-layer headache.

Frood sidesteps all of that. The initramfs is the complete system. Nothing to mount. Nothing to overlay. Just a kernel, an initramfs, and a bootloader.

Building the Initramfs: 500 Lines of Script

The starting point is alpine-make-rootfs, a ~500 line script that normally builds container images. Valsorda uses it to populate a rootfs from a root/ directory and a list of packages. Then he extracts /boot separately and packages the rest into a gzip-compressed cpio archive. That's the initramfs.

Key packages: alpine-base (apk, busybox, openrc), linux-lts (kernel + modules - no modloop, modules are always present), linux-firmware-i915 (only the Intel GPU firmware, not the full blob), intel-ucode (microcode as a pre-initramfs blob), and syslinux (simple bootloader, not GRUB).

No hacks needed. Alpine's architecture makes this trivial: the initramfs is just a filesystem image, and there's nothing stopping you from putting the whole OS in it.

Rollbacks as Boot Menu Selection

A/B deployments work because the bootloader (syslinux) picks a kernel+initramfs pair from a partition. Each pair is a complete system snapshot. The build is defined declaratively in a git repo - every file in root/etc/example.conf ends up at /etc/example.conf in the initramfs. No DSL, no abstraction leak.

Testing a new deploy is a qemu one-liner. The only persistent storage is the ZFS pool, while the system drives (often janky SD cards) never see writes after boot. That reduces wear and improves speed.

Valsorda considered NixOS ("just doesn't sound fun"), gokrazy (not ready for ZFS), and buildroot/u-root. He stuck with Alpine because it's simple, well-packaged, and GNU-less. The only thing he changed was the init and persistence mechanism.

Next time you're building a home NAS, or any appliance that should be disposable and reproducible, consider this pattern: a single cpio archive that is the entire machine. No rootfs, no state, no surprises.


Source: Frood, an Alpine Initramfs NAS
Domain: words.filippo.io

Read original source ->

External source stays available while the OJO article and comment thread stay local.

Comments load interactively on the live page.