Linux, Observed
Build it. Then watch it run. Then name the principle.
There are good guides to building Linux from source — Linux From Scratch has been the standard for decades — and there are good books on system design. What I couldn’t find was the thing in between: a build where, after every component, you stop and look at it running with the instruments the kernel already carries (ftrace, perf, bpftrace, /proc, /sys), and where each thing you see is tied to a principle that shows up again in every large system you will ever design.
That’s this series. Twelve chapters, each with three parts:
- Build — what gets compiled or configured in this chapter, from upstream source, and the decision that mattered.
- Observe — a short experiment, usually a
bpftraceone-liner or an ftrace session, that shows what the new component actually does: which syscalls, which kernel paths, how long, how often. - Principle — one system-design idea the observation makes concrete. Not a slogan; the specific thing the trace just showed you.
The result is a working, bootable Linux of your own: musl, a static BusyBox userland, your own init, and a kernel you configured line by line — and, more usefully, the habit of asking “what is this actually doing?” and knowing how to find out.
Background
This assumes comfort at a shell and the ability to read C. No kernel experience is needed.
What’s unique about it
- Observation is not optional. Most build guides stop at “it compiles”. Here, “it compiles” is the halfway point; the chapter isn’t done until you’ve traced it.
- These are the instruments used in production. No special instrumentation builds. If you can trace it here, you can trace it on a server at 3 a.m.
- Every build is measured. Record three numbers as you go: image size, boot-to-shell time and syscalls to first prompt, with the hash of the manifest that produced them.
- The principles accumulate. There’s a running list of principles: twelve ideas, each anchored to a trace you ran yourself.
Setup
You need a disposable x86-64 Linux VM, and a weekend or more of compile time. The series is pinned to Linux 7.3, while Kernel, Traced uses 6.12 LTS. Chapter 4 boots a kernel before chapter 5 builds yours, so either use a distro kernel there or do chapter 5 first.
Chapters
- 0Why build what you could downloadSet up your build host, write your manifest, and take the first trace: what your distro's
lsactually does.Draft - 1The cross-toolchainBuild binutils, gcc, kernel headers and musl for a target of your own, then trace what a compiler actually does.Draft
- 2A libc, and what it costsCompare static and dynamic binaries, prove musl's loader is its libc, and hijack a function with LD_PRELOAD.Draft
- 3Userland in one binaryBuild BusyBox as the whole of /bin, compare it with toybox, and profile a shell pipeline.Draft
- 4PID 1Write an init in C, boot it, make a zombie on purpose, and find out exactly what the kernel will and won't let happen to process 1.Draft
- 5The kernel, from allnoconfigConfigure a kernel upward from nothing, check that every option survived, boot it, and read its initcall timeline.Draft
- 6Booting: firmware to first promptBuild a root disk, write an initramfs that mounts it, make it fail on purpose, and draw your boot as a timeline.Draft
- 7Storage and the page cacheWatch the page cache absorb a read, build a read-only erofs image, protect it with dm-verity, and tamper with it.Draft
- 8Networking by handBring up networking with
ipalone, connect two namespaces, and follow one connect() from the syscall to the device.Draft - 9Namespaces and cgroupsBuild a container from kernel objects with unshare, pivot_root and cgroup2, then hit its limits on purpose.Draft
- 10Reproducible, or it didn't happenBuild the same thing twice, get the same hash, and find the byte that differs when you don't.Draft
- 11The instrument panelBring the tools onto your own system, cheapest first: ftrace, perf, bpftool, then bpftrace, and measure what looking costs.Draft
- ·PrinciplesThe twelve system-design principles of the series, each anchored to the trace that made it concrete.