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

Real-time System Tracing

Use systemd-analyze to profile service startup times and identify slow unit bottlenecks.

In this lesson, you will learn how to use systemd-analyze to peel back the layers of your boot process and pinpoint exactly which services are slowing down your system startup.

Profiling Startup with systemd-analyze

When you notice your Linux system taking a long time to reach the login prompt, it is often because of a "bottleneck" unit—a service that takes an unusually long time to initialize or blocks other services from starting. Instead of guessing, we use the systemd-analyze tool to get a precise breakdown.

Identifying the Bottlenecks

The simplest way to see the "big picture" of your boot timing is to run the following command:

systemd-analyze

This returns a summary of how much time was spent in the kernel, the initrd (initial RAM disk), and userspace. To find the culprits, use the blame subcommand:

systemd-analyze blame

This generates a list of all running units, sorted by the time each took to initialize. You will see the services consuming the most time at the top. If a service like NetworkManager-wait-online.service appears at the top of this list, you’ve found a primary candidate for your performance bottleneck.

Visualizing Dependency Chains

Sometimes, a service is slow not because it is inherently heavy, but because it is waiting on a slow dependency. To visualize the entire startup chain and identify these relationships, you can generate an SVG graphic:

systemd-analyze critical-chain

The output of critical-chain displays a tree structure. The services highlighted in red are the ones currently on the "critical path." If you improve the startup time of one of these, you directly improve the total system boot time.

If you prefer a visual diagram to help you map out how these services interact, you can even export this data:

systemd-analyze plot > boot_analysis.svg

You can then open this boot_analysis.svg file in any web browser to see a color-coded timeline of every unit start event. This makes it trivial to spot long gaps or overlapping processes that might be competing for resources.

Key Takeaway: Use systemd-analyze blame to identify the heaviest services and systemd-analyze critical-chain to map out the dependencies that contribute most to your total boot time.