init-manager.rst 3.3 KB

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