XELK-AN-008: How to use systemd on an Embedded system
|This application note has been validated starting from the XELK 3.0.x kit version.|
History[edit | edit source]
Introduction[edit | edit source]
Systemd is a System and Service Manager which has enough different settings and configuration from systemV which was used on all XELK BSPs up to XELK 3.0.0.
Brief description[edit | edit source]
Systemd, differing from SystemV, manages not only services but many different objects called Unit. Unit are related to the resources that systemd can manage. Unit configurations are defined into the Unit files.
Units categoris (identified by the file extension) are:
.service .target .socket .device .mount .automount .swap .path .timer .snapshot .slice .scope
Major insteresting Units are services and targets. They will be analyzed in the following paragraphs.
Services[edit | edit source]
It is possible to display all started services with the following userspace command:
systemctl -t service
It is possible to display all services (including disabled and stopped services):
systemctl -t service --all
Other useful service commands[edit | edit source]
Starting a service from userspace:
systemctl start <service_name>
Stopping a service from userspace
systemctl stop <service_name>
Starting a service at boot time:
systemctl enable <service_name>
Disabling service (already started at boot time):
systemctl disable <service_name>
Targets[edit | edit source]
Targets are used byt systemd for having a synchronization point between different services at boot time or during runtime changes.
They can be used for set the system to a new state.
All services linked to a target are linked to the modification to the same target. These can be seen in a similar way of SystemV runlevels with many other added functionalities.
Target and runlevels[edit | edit source]
Here below there is a list of power on/off targets and related SystemV runlevels:
|Description||SystemV (runlevel)||Systemd (target)|
|System halt||0||runlevel0.target, poweroff.target|
|Single user mode||1, s, single||runlevel1.target, rescue.target|
|Multi user||2||runlevel2.target, multi-user.target|
|Multi user with network||3||runlevel3.target, multi-user.target|
|Multi user with network, graphical mode||5||runlevel5.target, graphical.target|
multi-user target can be identified as the
directory there is a list of services related to that target.
root@imx6qxelk:~# ls /etc/systemd/system/multi-user.target.wants/ atd.service busybox-syslog.service gpuconfig.service ofono.service systemd-networkd.service avahi-daemon.service connman.service mytest.service psplash-quit.service systemd-resolved.service busybox-klogd.service crond.service ntpdate.service remote-fs.target
Active targets[edit | edit source]
It is possible to display all active targtes with:
systemctl -t target
Changing a target
systemctl isolate graphical
The actual target is shown with:
Changing the default target:
systemctl set-default multi-user