Lesson 3 of 9 · 25m
Root Filesystems, Init Systems, and First-Boot Debugging
Choose between initramfs, systemd, and minimal init designs; control boot ordering; and debug silent first-boot failures with evidence.
The kernel finishing boot is not the product booting. It still has to mount a root filesystem, start process one, bring up networking, mount writable state, launch applications, and recover when one step is missing. Many field outages are rootfs contract failures, not kernel failures.
Process one has non-negotiable duties
init must reap orphaned children, handle shutdown signals, mount required filesystems, and start the rest of the system. Three common embedded shapes are BusyBox init, systemd, and a controlled initramfs that performs early work before switch_root.
BusyBox init is tiny and direct. systemd costs footprint but provides dependency management, logging, restart policy, sandboxing, and watchdog integration. Neither is automatically correct. A handful of services can justify simplicity; a fleet product with network dependencies and field diagnostics usually earns systemd's weight.
The kernel command line is the first contract
Boot arguments determine where root comes from and what process one is:
console=ttymxc0,115200 root=PARTUUID=8f3f2d10-02 rootwait rw init=/sbin/initrootwait matters when storage enumeration is asynchronous. Prefer partition UUIDs or labels where supported; probe order can renumber /dev/mmcblk devices. If the kernel reaches VFS: Cannot open root device, the kernel booted and the storage contract failed. Read whether the missing piece is the device node, partition table, or filesystem driver.
systemd units are boot-order truth
A unit declares dependencies, restart behavior, filesystem access, and failure semantics:
[Unit]
Description=Sensor acquisition daemon
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/usr/bin/sensord --config /etc/sensord.conf
Restart=on-failure
WatchdogSec=10
NoNewPrivileges=true
ProtectSystem=strict
ReadWritePaths=/var/lib/sensord
[Install]
WantedBy=multi-user.targetAfter=network.target usually means networking management started, not that a usable network exists. Sometimes network-online.target is correct; often a daemon that retries locally is more robust than making global boot ordering carry application logic.
Read-only roots need explicit writable state
A maintainable split is a read-only versioned root, /var/lib/app for persistent application state, /run for tmpfs runtime state, and /data for larger mutable data. Factory reset then erases state while leaving a known-good root intact. A daemon that writes to /etc on every boot is telling you the state layout is wrong.
Debug with evidence:
systemctl --failed
journalctl -b -p warning --no-pager
systemd-analyze critical-chainField notes
- A missing executable bit on an init script can produce a panic that looks like a root filesystem failure.
Requires=creates hard failure coupling;Wants=is softer. Do not make unrelated services cascade-fail because one peripheral is optional.- Record reboot cause and boot count in persistent state. You cannot diagnose field boot loops you cannot count.
- A boot that works only when serial is attached is often a timing bug hidden by console latency.
Was this lesson helpful?