Building the Smallest Practical Operating System from First Principles
Introduction
- What This Book Does
- The Reference System
- What You Will Know After Reading
- How to Use This Book
- A Note on Versions
Chapter 1: The Minimal System Problem
- Why Smaller Matters
- What Minimal Actually Means
- The Dependency Chain
- Reference System Overview
- Measuring Minimality
Chapter 2: Reference Architecture and Build Environment
- Choosing a Platform
- The Build Host
- Directory Layout and Build Scripts
- QEMU Setup and Validation
- The Target Specification
Chapter 3: Firmware and the Boot Journey
- Power-On and Firmware
- The BIOS Boot Process
- The UEFI Boot Process
- The Bootloader’s Job
- Alternative Boot Paths
- The Kernel Command Line
- Tracing the Boot
Chapter 4: Kernel Configuration and Compilation
- Reading the Kernel Config
- Starting from Defconfig
- The Minimal Kernel Config
- Core Subsystems
- Network and Security
- Building the Kernel
- Verifying the Kernel Configuration
- Common Pitfalls
Chapter 5: The ELF Format and Executable Loading
- ELF Structure
- The Loader in the Kernel
- Entry Points and Startup
- Examining Binaries
- Static vs. Dynamic ELF
Chapter 6: Building the Toolchain from First Principles
- The Toolchain Triad
- The Bootstrap Problem
- Building Binutils
- Building GCC
- Building musl
- Completing the Toolchain
- Validation and Reproducibility
Chapter 7: libc: The User-Kernel Boundary
- What libc Actually Does
- glibc Deep Dive
- musl as Alternative
- Other libc Implementations
- Choosing and Building libc
Chapter 8: The Dynamic Linker and Shared Libraries
- How Dynamic Linking Works
- The Dynamic Linker’s Role
- Shared Library Layout
- Debugging Linking Problems
- Static vs. Dynamic Tradeoffs
Chapter 9: Linking, Relocation and Symbol Resolution
- Object Files and Symbol Tables
- The Linker’s Job
- Relocation Types
- Linker Script Control
- Linker Optimization
Chapter 10: BusyBox and the Mono-Utility Philosophy
- How BusyBox Works
- Configuring BusyBox
- BusyBox vs. GNU Coreutils
- BusyBox vs. Dropbear and OpenSSH
- Building BusyBox for the Reference System
Chapter 11: The Minimal Userspace: Core Utilities
- The Interactive Shell
- The Network Appliance
- The Container Host
- The Rescue Environment
- The Single-Purpose Server
- Determining the True Minimum
Chapter 12: Building the Initramfs: Early Userspace
- What Initramfs Does
- Initramfs vs. Direct Root Mount
- Building an Initramfs
- The Initramfs Init Script
- Integrating with the Kernel
Chapter 13: Init: The First Process and Service Supervision
- What Init Must Do
- Traditional Init
- systemd
- Lightweight Init
- Building Our Init
- Service Supervision
- Shutdown and Recovery
Chapter 14: Device Management: /dev, /proc, /sys
- /dev and Device Nodes
- /proc: Process and Kernel Information
- /sys: The Device Model
- /run and Temporary State
- Summary
Chapter 15: Filesystems, Mounts and Storage
- Root Filesystem Choice
- Partitioning
- Creating and Formatting
- Mounting and fstab
- Minimal Filesystem Trees
Chapter 16: Process Management: Fork, Exec and Signals
- The fork System Call
- The exec Family
- Signal Handling
- Process Groups and Sessions
- /proc and Process Inspection
Chapter 17: Memory Management and Virtual Memory
- Virtual Memory Fundamentals
- Page Faults and Demand Loading
- The Page Cache
- Swap and Memory Pressure
- Observing Memory Usage
Chapter 18: Namespaces, Cgroups and Container Foundations
- What Namespaces Are
- Creating Namespaces
- Cgroups and Resource Control
- Namespaces and Cgroups Together
- Minimal Container Environment
Chapter 19: Networking: Interfaces, Routing, DNS and Time
- The Network Stack
- Interface Configuration
- Routing and Connectivity
- DNS Resolution
- Time and NTP
Chapter 20: Security: Hardening, Capabilities and Least Privilege
- Minimizing Attack Surface
- Kernel Security Options
- Capabilities and Privilege
- seccomp and System Call Filtering
- MAC Frameworks
- Secure Boot and Supply Chain
Chapter 21: Observability: Tracing, Debugging and eBPF
- strace and System Call Tracing
- ftrace and Kernel Tracing
- eBPF and Advanced Observability
- perf and Performance Analysis
- Boot Debugging
Chapter 22: Minimization Strategies and Dependency Analysis
- Dependency Mapping
- Stripping Unnecessary Components
- Binary Analysis
- Iterative Reduction
- The Danger Zone
Chapter 23: Workload-Specific Minimal Systems
- Single-Purpose Network Appliance
- Embedded System
- Container Host
- Rescue and Recovery Environment
- The Absolute Floor
Chapter 24: Packaging, Deployment and Lifecycle
- Creating Disk Images
- VM Deployment
- Initramfs Deployment
- Upgrades and Rollback
- Configuration Management
- Backups and Disaster Recovery
- Lifecycle Management
Chapter 25: Conclusion: The Philosophy of Minimal Systems
- What We Built and What It Cost
- The Nature of Minimalism
- When Not to Go Minimal
- The Future of Minimal Linux
- Keeping the System Alive
- Final Thoughts
Chapter 26: References and Resources
- Kernel Documentation and Source
- Userspace Projects and Standards
- Toolchain and Build Resources
- Security and Hardening References
- Further Reading
- Tools Used in This Book