diff options
author | Michael Opdenacker <michael.opdenacker@bootlin.com> | 2023-04-27 17:30:05 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-04-28 14:46:17 +0100 |
commit | b01a12a13531c56a336a399456cb71709bb1a549 (patch) | |
tree | 88f070c0f2aa59f1972b0da62353ffd3b9c9d45d /documentation/dev-manual | |
parent | 7f39a583e772a45003db20d29a1e67faacb6be58 (diff) | |
download | poky-b01a12a13531c56a336a399456cb71709bb1a549.tar.gz |
manuals: expand init manager documentation
- Add details about INIT_MANAGER
Correct the fact that "none" currently generates
an image with "sysvinit", at least on Poky.
This behaviour should probably be changed.
- Expand the "Selecting an Initialization Manager" section.
- Stop mentioning "rescue image" generation, as this
is not detailed anywhere else.
(From yocto-docs rev: fd99f2753b50b7ad6133b787b90331fcb3a35152)
Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
CC: Paul Eggleton <bluelightning@bluelightning.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'documentation/dev-manual')
-rw-r--r-- | documentation/dev-manual/device-manager.rst | 2 | ||||
-rw-r--r-- | documentation/dev-manual/init-manager.rst | 108 |
2 files changed, 74 insertions, 36 deletions
diff --git a/documentation/dev-manual/device-manager.rst b/documentation/dev-manual/device-manager.rst index 4248c23b44..0343d19b9c 100644 --- a/documentation/dev-manual/device-manager.rst +++ b/documentation/dev-manual/device-manager.rst | |||
@@ -1,5 +1,7 @@ | |||
1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK |
2 | 2 | ||
3 | .. _device-manager: | ||
4 | |||
3 | Selecting a Device Manager | 5 | Selecting a Device Manager |
4 | ************************** | 6 | ************************** |
5 | 7 | ||
diff --git a/documentation/dev-manual/init-manager.rst b/documentation/dev-manual/init-manager.rst index 10c4754e62..fd8747b9b0 100644 --- a/documentation/dev-manual/init-manager.rst +++ b/documentation/dev-manual/init-manager.rst | |||
@@ -1,71 +1,107 @@ | |||
1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK |
2 | 2 | ||
3 | .. _init-manager: | ||
4 | |||
3 | Selecting an Initialization Manager | 5 | Selecting an Initialization Manager |
4 | *********************************** | 6 | *********************************** |
5 | 7 | ||
6 | By default, the Yocto Project uses SysVinit as the initialization | 8 | By default, the Yocto Project uses :wikipedia:`SysVinit <Init#SysV-style>` as |
7 | manager. However, there is also support for systemd, which is a full | 9 | the initialization manager. There is also support for BusyBox init, a simpler |
8 | replacement for init with parallel starting of services, reduced shell | 10 | implementation, as well as support for :wikipedia:`systemd <Systemd>`, which |
9 | overhead and other features that are used by many distributions. | 11 | is a full replacement for init with parallel starting of services, reduced |
12 | shell overhead, increased security and resource limits for services, and other | ||
13 | features that are used by many distributions. | ||
14 | |||
15 | Within the system, SysVinit and BusyBox init treat system components as | ||
16 | services. These services are maintained as shell scripts stored in the | ||
17 | ``/etc/init.d/`` directory. | ||
10 | 18 | ||
11 | Within the system, SysVinit treats system components as services. These | 19 | SysVinit is more elaborate than BusyBox init and organizes services in |
12 | services are maintained as shell scripts stored in the ``/etc/init.d/`` | 20 | different run levels. This organization is maintained by putting links |
13 | directory. Services organize into different run levels. This | 21 | to the services in the ``/etc/rcN.d/`` directories, where `N/` is one |
14 | organization is maintained by putting links to the services in the | 22 | of the following options: "S", "0", "1", "2", "3", "4", "5", or "6". |
15 | ``/etc/rcN.d/`` directories, where `N/` is one of the following options: | ||
16 | "S", "0", "1", "2", "3", "4", "5", or "6". | ||
17 | 23 | ||
18 | .. note:: | 24 | .. note:: |
19 | 25 | ||
20 | Each runlevel has a dependency on the previous runlevel. This | 26 | Each runlevel has a dependency on the previous runlevel. This |
21 | dependency allows the services to work properly. | 27 | dependency allows the services to work properly. |
22 | 28 | ||
29 | Both SysVinit and BusyBox init are configured through the ``/etc/inittab`` | ||
30 | file, with a very similar syntax, though of course BusyBox init features | ||
31 | are more limited. | ||
32 | |||
23 | In comparison, systemd treats components as units. Using units is a | 33 | In comparison, systemd treats components as units. Using units is a |
24 | broader concept as compared to using a service. A unit includes several | 34 | broader concept as compared to using a service. A unit includes several |
25 | different types of entities. Service is one of the types of entities. | 35 | different types of entities. ``Service`` is one of the types of entities. |
26 | The runlevel concept in SysVinit corresponds to the concept of a target | 36 | The runlevel concept in SysVinit corresponds to the concept of a target |
27 | in systemd, where target is also a type of supported unit. | 37 | in systemd, where target is also a type of supported unit. |
28 | 38 | ||
29 | In a SysVinit-based system, services load sequentially (i.e. one by one) | 39 | In systems with SysVinit or BusyBox init, services load sequentially (i.e. one |
30 | during init and parallelization is not supported. With systemd, services | 40 | by one) during init and parallelization is not supported. With systemd, services |
31 | start in parallel. Needless to say, the method can have an impact on | 41 | start in parallel. This method can have an impact on the startup performance |
32 | system startup performance. | 42 | of a given service, though systemd will also provide more services by default, |
43 | therefore increasing the total system boot time. systemd also substantially | ||
44 | increases system size because of its multiple components and the extra | ||
45 | dependencies it pulls. | ||
33 | 46 | ||
34 | If you want to use SysVinit, you do not have to do anything. But, if you | 47 | On the contrary, BusyBox init is the simplest and the lightest solution and |
35 | want to use systemd, you must take some steps as described in the | 48 | also comes with BusyBox mdev as device manager, a lighter replacement to |
36 | following sections. | 49 | :wikipedia:`udev <Udev>`, which SysVinit and systemd both use. |
37 | 50 | ||
38 | Using systemd Exclusively | 51 | The ":ref:`device-manager`" chapter has more details about device managers. |
52 | |||
53 | Using SysVinit with udev | ||
39 | ========================= | 54 | ========================= |
40 | 55 | ||
41 | Set the :term:`INIT_MANAGER` variable in your distribution configuration | 56 | SysVinit with the udev device manager corresponds to the |
42 | file as follows:: | 57 | default setting in Poky. This corresponds to setting:: |
58 | |||
59 | INIT_MANAGER = "sysvinit" | ||
60 | |||
61 | Using BusyBox init with BusyBox mdev | ||
62 | ==================================== | ||
63 | |||
64 | BusyBox init with BusyBox mdev is the simplest and lightest solution | ||
65 | for small root filesystems. All you need is BusyBox, which most systems | ||
66 | have anyway:: | ||
67 | |||
68 | INIT_MANAGER = "mdev-busybox" | ||
69 | |||
70 | Using systemd | ||
71 | ============= | ||
72 | |||
73 | The last option is to use systemd together with the udev device | ||
74 | manager. This is the most powerful and versatile solution, especially | ||
75 | for more complex systems:: | ||
43 | 76 | ||
44 | INIT_MANAGER = "systemd" | 77 | INIT_MANAGER = "systemd" |
45 | 78 | ||
46 | This will enable systemd and remove sysvinit components from the image. | 79 | This will enable systemd and remove sysvinit components from the image. |
47 | See ``meta/conf/distro/include/init-manager-systemd.inc`` for exact | 80 | See :yocto_git:`meta/conf/distro/include/init-manager-systemd.inc |
81 | </poky/tree/meta/conf/distro/include/init-manager-systemd.inc>` for exact | ||
48 | details on what this does. | 82 | details on what this does. |
49 | 83 | ||
50 | Using systemd for the Main Image and Using SysVinit for the Rescue Image | 84 | Controling systemd from the target command line |
51 | ======================================================================== | 85 | ----------------------------------------------- |
52 | |||
53 | Set these variables in your distribution configuration file as follows:: | ||
54 | 86 | ||
55 | DISTRO_FEATURES:append = " systemd" | 87 | Here is a quick reference for controling systemd from the command line on the |
56 | VIRTUAL-RUNTIME_init_manager = "systemd" | 88 | target. Instead of opening and sometimes modifying files, most interaction |
89 | happens through the ``systemctl`` and ``journalctl`` commands: | ||
57 | 90 | ||
58 | Doing so causes your main image to use the | 91 | - ``systemctl status``: show the status of all services |
59 | ``packagegroup-core-boot.bb`` recipe and systemd. The rescue/minimal | 92 | - ``systemctl status <service>``: show the status of one service |
60 | image cannot use this package group. However, it can install SysVinit | 93 | - ``systemctl [start|stop] <service>``: start or stop a service |
61 | and the appropriate packages will have support for both systemd and | 94 | - ``systemctl [enable|disable] <service>``: enable or disable a service at boot time |
62 | SysVinit. | 95 | - ``systemctl list-units``: list all available units |
96 | - ``journalctl -a``: show all logs for all services | ||
97 | - ``journalctl -f``: show only the last log entries, and keep printing updates as they arrive | ||
98 | - ``journalctl -u``: show only logs from a particular service | ||
63 | 99 | ||
64 | Using systemd-journald without a traditional syslog daemon | 100 | Using systemd-journald without a traditional syslog daemon |
65 | ========================================================== | 101 | ---------------------------------------------------------- |
66 | 102 | ||
67 | Counter-intuitively, ``systemd-journald`` is not a syslog runtime or provider, | 103 | Counter-intuitively, ``systemd-journald`` is not a syslog runtime or provider, |
68 | and the proper way to use systemd-journald as your sole logging mechanism is to | 104 | and the proper way to use ``systemd-journald`` as your sole logging mechanism is to |
69 | effectively disable syslog entirely by setting these variables in your distribution | 105 | effectively disable syslog entirely by setting these variables in your distribution |
70 | configuration file:: | 106 | configuration file:: |
71 | 107 | ||
@@ -73,5 +109,5 @@ configuration file:: | |||
73 | VIRTUAL-RUNTIME_base-utils-syslog = "" | 109 | VIRTUAL-RUNTIME_base-utils-syslog = "" |
74 | 110 | ||
75 | Doing so will prevent ``rsyslog`` / ``busybox-syslog`` from being pulled in by | 111 | Doing so will prevent ``rsyslog`` / ``busybox-syslog`` from being pulled in by |
76 | default, leaving only ``journald``. | 112 | default, leaving only ``systemd-journald``. |
77 | 113 | ||