Course contentsShow
← Linux
Lesson 579 of 1,8196. Systemd Internals and Unit OrchestrationFree lesson

Analyzing the Systemd Initialization Chain

Trace the boot process from kernel loading to the final reaching of the default target.

In this lesson, you will learn how to trace the transition from the kernel’s initial execution to the fully operational user-space environment managed by systemd.

The Handover from Kernel to Init

When you power on your machine, the kernel initializes hardware and mounts the root filesystem. Once the kernel finishes its setup, it executes the first process, which is traditionally assigned PID 1. In modern Linux distributions, this is the systemd binary. At this exact moment, the kernel "hands over" control of the system to systemd, which becomes the parent of all subsequent processes.

The Initialization Chain

systemd does not start services in a linear list; it treats them as a complex graph of dependencies. Here is how the chain unfolds:

  1. Initial Target: systemd first looks for the default.target (usually graphical.target or multi-user.target), which acts as the "goal" state for the boot.
  2. Dependency Resolution: Because systemd is designed for speed, it analyzes the Wants= and Requires= directives in unit files. It calculates the most efficient order to start services in parallel.
  3. The Chain of Units: You can visualize the current chain of your boot process by running:
    systemd-analyze
    
    This command tells you exactly how much time was spent in the kernel vs. user-space. If you want to see the specific chain of execution for a target, use:
    systemd-analyze critical-chain
    

Why Trace the Chain?

The critical-chain command is vital for debugging slow boots. It identifies which unit was the bottleneck—the service that took the longest to initialize and held up other dependent processes. Each unit in the chain must complete its start-up sequence (which often involves opening sockets or mounting internal paths) before the next link in the dependency graph can safely proceed. By tracing this chain, you see exactly where systemd is orchestrating the transition from a blank state to a functional desktop or server environment.

Key Takeaway: The systemd initialization chain is a dependency-driven graph that starts at PID 1 and parallelizes service activation to reach a defined target state as efficiently as possible.