Systemd is a system and session manager that is responsible for managing all services running on the system over the entire operating time of the computer, from the start-up process to shutdown. Processes are always started in parallel (as far as possible) in order to keep the boot process as short as possible. But how to know which process took how much time while booting your system, well for that we can use the Systemd as well.
Let’s see the Systemd commands to analyze Linux boot time
The below-given steps can be used for Ubuntu, Linux Mint, CentOS, RHEL, Kali Linux, Debian, MX Linux, Rocky Linux, and other systems booted using Systemd.
Systemd-analyze
systemd-analyze is, as the name suggests, a command-line tool from systemd, with which the system, especially the boot process, can be analyzed. The knowledge gained in this way can then be used, for example, to carry out optimizations.
Hence to use it simply open your command terminal and immediately check & display the boot processes by running:
systemd-analyze
In the below screenshot, you can see the overview of which system components need how long to boot.
If the operating system is installed on a computer with UEFI, the start time of the UEFI (firmware) is also presented. The start time of the boot loader is then output (loader). The start times of the system-related components (kernel) and the user environment are also specified.
Systemd-analyze blame
To get a more precise list of the data for all services started with system boot, use the blame option. The output data will be sorted according to their start time. With this, the user can find services that delay the system start.
Hence, the more precise output can be obtained with the command
systemd-analyze blame
This gives you a list of all services along with the time started when booting happens.
Linux Boot time details in SVG graphics
Those who want to the details of boot process time in graphical presentable form can go for the Plot option. In this, the output will be exported as SVG graphics. This gives you even more detailed results. the export takes place with
systemd-analyze plot> boot.svg
In the above command, we are saving the output in boot.svg
file. To open it use the Image Viewer. You can simply go to the saved image file and double click to open it or use the eog
command.
eog boot.svg
However, the exported graphic is quite large, hence to get the proper view of the process you have to zoon and scroll a lot to analyze it. The start time is indicated in seconds horizontally. The individual services are listed vertically.
Apart from these commands, you can also use the other Options with systemd-analyze
command to get more information.
Systemd-analyze commands
command | Explanation |
time |
Shows how long the system took until the userspace was fully loaded and initialized (= until the system could be “used”). The output is divided into firmware , loader (= loading initrd), kernel anduserspace |
blame |
Outputs a list of all running units of systemd, sorted according to the time they took for initialization. |
critical-chain |
Displays a “time-critical” list of running units. Time-critical means that the unit above in the list could only be started due to dependencies when the lower unit was completely initialized. |
plot |
Plots the system starts as a diagram in SVG format. The time is plotted on the X-axis of the plot and the units on the Y-axis. The output should be direct to a file redirected to, eg systemd-analyze plot > graph.svg . |
dot |
Generates a dependency graph of the units in Graphviz’s dot format. sudo apt install graphviz |
dump |
Outputs the status of each loaded unit in detail. Since the list is very long – usually several tens of thousands of lines – the output should either be redirected to a file or filtered directly with grep or something similar. |
verify [UNITDATEI] |
Checks the correctness of all active units. If a unit file is also UNITDATEI specified, only this and the units required to start this unit are checked. Root rights are required for this. |
Conclusion:
The outputs from systemd-analyze
are not only interesting but also make it possible to see at a glance why the boot process is taking so long. Services that slow down the boot process can thus be identified directly where lengthy troubleshooting or analysis might otherwise be necessary.