3,886 bytes added,
14:43, 19 September 2019 {{InfoBoxTop}}
{{AppliesToAxel}}
{{AppliesToAxelEsatta}}
{{AppliesToAxelLite}}
{{InfoBoxBottom}}
{{ImportantMessage|text=This application note has been validated starting from the '''XELK 3.0.x''' kit version.}}
==History==
{| class="wikitable" border="1"
!Version
!Date
!XELK version
!Notes
|-
|1.0.0
|Sep 2019
|[[Axel_Embedded_Linux_Kit_(XELK)#XELK_4.0.0|4.0.0]]
|
|-
|}
==Introduction==
Starting from [[Axel_Embedded_Linux_Kit_(XELK)#XELK_4.0.0|XELK 4.0.0]] the root file system generated by NXP Yocto recipes produces a root file system using [https://www.freedesktop.org/wiki/Software/systemd/ systemd].
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 [[Axel_Embedded_Linux_Kit_(XELK)#XELK_3.0.0|XELK 3.0.0]].
== Brief description ==
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 ==
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 ===
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 ==
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 ===
Here below there is a list of power on/off targets and related SystemV runlevels:
{| class="wikitable"
|-
! Function !! 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
|-
| Experimental || 4 || runlevel4.target, multi-user.target
|-
| Multi user with network, graphical mode || 5 || runlevel5.target, graphical.target
|-
| Reboot || 6 || runlevel6.target, reboot.target
|}
<code>multi-user</code> target can be identified as the <code>runlevel 3</code>.
On the
/etc/systemd/system/''<target_name>''.target.wants
directory there is a list of services related to that target.
For example:
<pre>
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
</pre>
=== Active targets ===
It is possible to display all active targtes with:
systemctl -t target
Changing a target
systemctl isolate graphical
The actual target is shown with:
systemctl get-default
Changing the default target:
systemctl set-default multi-user