Skip to content

The forge · Stage of the build

Stage 2

Warm blooded at last. The self-hosting rootfs where compilation happens natively under musl: wrought enough now to keep its own heat.

Saphira Linux dragon mascot

Self-hosting under musl

Stage 2 turns the minimal Stage 1 rootfs into a complete system: native GCC and binutils now run inside it, compiling further packages without help from the host. Everything is driven by stage2/bootstrap-final.sh, with fingerprinted inputs so any change invalidates exactly what must be rebuilt and nothing more.

The stage also fits out the runtime for booting: fstab, os-release, agetty configuration for console and serial, OpenRC scripts and a GRUB configuration are laid down through the rootfs overlay, along with a rescue entry. Kernel configuration can be adjusted interactively through menuconfig.sh.

The non usr merged layout is enforced from here forward. Early boot executables live in /sbin and OpenRC scripts start with #!/sbin/openrc-run. By the end of Stage 2 the tree knows how to become a bootable image, which is precisely what Stage 3 does next.

Continue the chain

Next: Stage 3, back to Stage 1, or the forge overview.