Lesson 1 of 9 · 22m
The Boot Mental Model: PID 1 to a Reachable System
What systemd actually does after the kernel hands off control, how targets replace runlevels, and why boot is a dependency graph rather than a script.
The first systemd lesson I give new hires is simple: boot is not a shell script with extra steps. It is a dependency solver building a graph of desired state, then activating units in parallel as requirements become satisfiable. Once you see that, odd boot behavior stops being mysterious.
The handoff
The kernel finishes initialization, mounts the initial root filesystem, and executes /sbin/init — usually a symlink to /lib/systemd/systemd. systemd becomes PID 1 and inherits the duties no other process can perform safely: reaping orphaned children, handling system-manager signals, and starting everything else.
ls -l /sbin/init
# lrwxrwxrwx ... /sbin/init -> /lib/systemd/systemd
ps -p 1 -o pid,comm,args
# 1 systemd /sbin/initPID 1 is special. If a daemon misbehaves, systemd can restart it. If PID 1 crashes, the kernel panics.
Targets are synchronization points
sysvinit had runlevels. systemd has targets: graph landmarks such as multi-user.target, graphical.target, rescue.target, and emergency.target. A service does not "start in runlevel 3." It is wanted by a target through a symlink:
/etc/systemd/system/multi-user.target.wants/ssh.service -> /usr/lib/systemd/system/ssh.serviceThat tiny symlink is the whole enablement mechanism. systemctl enable ssh.service creates it; boot reaches multi-user.target; the target pulls SSH in.
Parallelism changes what "first" means
systemd starts everything whose dependencies are satisfied at the same time. Your service may start before networking has an address, before a filesystem is mounted, or before time synchronization has happened. If correctness depends on those things, encode it in the unit — never add sleep 5 and hope.
Inspect the graph, not the vibes
systemctl get-default
systemd-analyze blame
systemd-analyze critical-chain multi-user.target
systemctl list-dependencies graphical.targetblame answers "what was slow." critical-chain answers "what actually delayed login." They are not the same question.
Field notes
- A unit can be active while the system is still not "ready"; active only means activation succeeded.
- Do not experiment with
systemctl isolate rescue.targeton a remote production box. - Never edit vendor units under
/usr/lib/systemd/system; override them under/etc/systemd/system. - If boot ordering feels random, it usually means a missing dependency — parallelism exposed the assumption.
Was this lesson helpful?