blob: 0617fed51667a029fa269b16a24ba90a42a902ca [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001.. SPDX-License-Identifier: CC-BY-SA-2.0-UK
2
3Selecting an Initialization Manager
4***********************************
5
6By default, the Yocto Project uses SysVinit as the initialization
7manager. However, there is also support for systemd, which is a full
8replacement for init with parallel starting of services, reduced shell
9overhead and other features that are used by many distributions.
10
11Within the system, SysVinit treats system components as services. These
12services are maintained as shell scripts stored in the ``/etc/init.d/``
13directory. Services organize into different run levels. This
14organization is maintained by putting links to the services in the
15``/etc/rcN.d/`` directories, where `N/` is one of the following options:
16"S", "0", "1", "2", "3", "4", "5", or "6".
17
18.. note::
19
20 Each runlevel has a dependency on the previous runlevel. This
21 dependency allows the services to work properly.
22
23In comparison, systemd treats components as units. Using units is a
24broader concept as compared to using a service. A unit includes several
25different types of entities. Service is one of the types of entities.
26The runlevel concept in SysVinit corresponds to the concept of a target
27in systemd, where target is also a type of supported unit.
28
29In a SysVinit-based system, services load sequentially (i.e. one by one)
30during init and parallelization is not supported. With systemd, services
31start in parallel. Needless to say, the method can have an impact on
32system startup performance.
33
34If you want to use SysVinit, you do not have to do anything. But, if you
35want to use systemd, you must take some steps as described in the
36following sections.
37
38Using systemd Exclusively
39=========================
40
41Set these variables in your distribution configuration file as follows::
42
43 DISTRO_FEATURES:append = " systemd"
44 VIRTUAL-RUNTIME_init_manager = "systemd"
45
46You can also prevent the SysVinit distribution feature from
47being automatically enabled as follows::
48
49 DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
50
51Doing so removes any
52redundant SysVinit scripts.
53
54To remove initscripts from your image altogether, set this variable
55also::
56
57 VIRTUAL-RUNTIME_initscripts = ""
58
59For information on the backfill variable, see
60:term:`DISTRO_FEATURES_BACKFILL_CONSIDERED`.
61
62Using systemd for the Main Image and Using SysVinit for the Rescue Image
63========================================================================
64
65Set these variables in your distribution configuration file as follows::
66
67 DISTRO_FEATURES:append = " systemd"
68 VIRTUAL-RUNTIME_init_manager = "systemd"
69
70Doing so causes your main image to use the
71``packagegroup-core-boot.bb`` recipe and systemd. The rescue/minimal
72image cannot use this package group. However, it can install SysVinit
73and the appropriate packages will have support for both systemd and
74SysVinit.
75
76Using systemd-journald without a traditional syslog daemon
77==========================================================
78
79Counter-intuitively, ``systemd-journald`` is not a syslog runtime or provider,
80and the proper way to use systemd-journald as your sole logging mechanism is to
81effectively disable syslog entirely by setting these variables in your distribution
82configuration file::
83
84 VIRTUAL-RUNTIME_syslog = ""
85 VIRTUAL-RUNTIME_base-utils-syslog = ""
86
87Doing so will prevent ``rsyslog`` / ``busybox-syslog`` from being pulled in by
88default, leaving only ``journald``.
89