Linux System Process Initialization Using Systemd

Traditionally, Linux systems (and Unix systems before them) have used a sequential startup mechanism, which is described here. This page describes a newer mechanism, known as "systemd". See this page for a description of another mechansm, upstart.

Whereas SysV Init is made entirely from scripts, and Upstart is a combination of descriptive configuration files and scripits, systemd configuration is described entirely by configuration files.

After the Linux kernel initialization is completed, the init script executes the program /sbin/init. (In the case of systemd, /sbin/init is actually a symbolic link to another file /usr/lib/systemd/systemd.)

Note that the term "systemd" can refer to the init process (process ID 1), which is what is being described here, or it can refer to an entire collection of system utilities that includes the init process. Moreover, there is another copy of systemd, running at an arbitrary process ID, for each logged in user. What is described here is the copy of systemd running as process ID 1.

The systemd version of init reads a series of files from the directories /etc/systemd/system and /usr/lib/systemd/system. Each of these files is called a "unit" and units can be of various types such as service, target, etc., as indicated by the filename suffix (.service, .target, etc.) A "service" is typically a daemon that runs in the background to perform some system function. Here is a sample of one such systemd configuration file.

Although some files are more complicated, many are as simple as this example.

The init process monitors a service while it is running and can restart it if it fails.

Runlevels as implemented in SysV init are replicated in systemd by "targets" (files with a .target suffix). Some systems provide files such as "runlevel5.target" as a symbolic link in order to mimic SysV runlevel behavior.

There are several files for starting the various login environments. This is described under local login mechanisms.

The advantage of either upstart or systemd over the SysV init process is that whereas the SysV mechanism runs strictly sequentially, upstart and systemd are designed to run initialization steps in parallel. Which of upstart or systemd is preferable is a current subject of heated debate. systemd does away with startup script code, which some people applaud since it prevents having to start shell for each service, while others object to the loss of control of the logic used to start a service.

Next: Login

Return to main PC Boot Sequence page

Return to my writing page

Return to my home page