3. Selecting Init Systemο
This section wonβt discuss the different available init systems or what they are just how to select one in yocto project.
Specifically how to select systemd as the choosen init system.
3.1. Creating Distro Configο
Change directories into your custom layer created in previous section and create a poky distro config.
mkdir -p conf/distro
touch conf/distro/mydistro.conf
Add the following into conf/distro/mydistro.conf
3.2. Select Systemd Over SysVο
require conf/distro/poky.conf
# Replaces sysvinit init system with systemd init system
VIRTUAL-RUNTIME_initscripts = ""
VIRTUAL-RUNTIME_init_manager = "systemd"
VIRTUAL-RUNTIME_dev_manager = "udev"
PREFERRED_PROVIDER_udev = "systemd"
PREFERRED_PROVIDER_udev-utils = "systemd"
DISTRO_FEATURES_BACKFILL_CONSIDERED:append = " sysvinit"
DISTRO_FEATURES += "usrmerge systemd"
See Yocto Project Variable Glossary for more details.
PREFERRED_PROVIDER_<package name> Used if multiple recipes provide the same file(s). In therecipe however you have to set thePROVIDESvariable.When yocto project goes to build a system image whateverrecipe provides<package name>files will be usedduring builds and in the final system image.In the example above the provider for the linux kernel devicemanager isudevthis value could be similarly set tobusybox-mdev.
VIRTUAL-RUNTIME Similar toPREFERRED_PROVIDERselects which package getsused for a specific functionality at runtime. Thus, specifyingwhatever recipePROVIDESsaid package. That package will thenbe used to perform functionality.In above exampleinit_managerchoosen is systemd. This couldvery well be set to sysvinit. The chosesndev_manager(device manager)isudevthis value could be similarly set tobusybox-mdev.VIRTUAL-RUNTIMEgets utilized by variables such asIMAGE_INSTALL,RDEPENDS,RRECOMMENDS, etc.. internally by multiple recipes.
DISTRO_FEATURES_BACKFILL_CONSIDERED Features that should not be added intoDISTRO_FEATURESduring builds.
DISTRO_FEATURES Each linux distro has a set of features that make it unique.In terms on the Yocto project this variable is used by multiplerecipes and classes to specify what actions need to be performedto support a given linux system image feature.See Yocto Project Distro Features for more information.
3.3. Building System Imageο
$ MACHINE="qemux86-64" DISTRO="mydistro" bitbake core-image-base
3.4. Testing In A VMο
You should now see systemd in the serial output.
$ runqemu tmp/deploy/images/qemux86-64/core-image-base-qemux86-64.rootfs.qemuboot.conf \
core-image-base \
slirp \
serialstdio