Changes

Jump to: navigation, search

XELK-AN-008: How to use systemd on an Embedded system

2,321 bytes added, 11:06, 20 September 2019
no edit summary
time to sleep during ''start'' or ''stop'' before considering the process failed on start or stop. Start and stop timeout can be set with different values using <code>TimeoutStartSec=</code> nad e <code>TimeoutStopSec=</code>
 
 
== Network Configuration ==
 
One of the most systemt configuration used is the '''Network configuration'''.
 
systemd uses a slightly different configuration mechanism than SystemV. The configuration file is the following one with an example of configuration:
 
/etc/systemd/network/eth0.network
 
<pre>
[Match]
Name=eth0
 
# Prevent the interface loading if the kernel boots from nfs
KernelCommandLine=!nfsroot
 
[Network]
Address=192.168.0.120
Gateway=192.168.0.254
DNS=192.168.0.1
#DNS=8.8.8.8
 
</pre>
 
'''Note:'''
 
The DNS is used only if the <code>systemd-resolved</code> service is enabled and the <code>/etc/resolv.conf</code> has a symbloic link to <code>/run/systemd/resolve/stub-resolv.conf</code>
 
<pre>
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
</pre>
 
=== wireless ===
 
==== wpa_supplicant ====
wpa_supplicant provides different services on systemd:
 
* <code>wpa_supplicant.service</code> uses D-Bus, recommende with the ''NetworkManager''
* <code>wpa_supplicant@interface.service</code> uses the interface name (like ''wlan0'') as parameter ansd executes the wpa_supplicant daemon on that interface. The configuration file is <code>/etc/wpa_supplicant/wpa_supplicant-interface.conf</code>
 
For enabling the interface at boot time it is required to start the service
 
systemctl enable wpa_supplicant@interface
 
==== Configuration example ====
 
Assuming ''wlan0'' as the wireless interface name, the a configuration file example are the following one:
 
/etc/systemd/network/wlan0.network
 
<pre>
[Match]
Name=wlan0
[Network]
# Uncomment for DHCP
#DHCP=yes
Address=192.168.1.120
Gateway=192.168.1.254
DNS=8.8.8.8
 
</pre>
 
/etc/wpa_supplicant/wpa_supplicant-wlan0.conf
 
<pre>
ctrl_interface=/var/run/wpa_supplicant
eapol_version=1
ap_scan=1
fast_reauth=1
 
network={
ssid="SSID1"
psk="password1"
priority=1
}
network={
ssid="SSID2"
psk="password2"
priority=2
}
</pre>
 
For automatically creating the netwrok configuration, the following command can be used:
 
wpa_passphrase <ESSID> <passphrase> >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
 
Then, the sercice should be enabled on the ''wlan0'' interface for instructing systemd to start itusing the (just) created configuration file <code>wpa_supplicant-wlan0.conf</code>:
 
systemctl enable wpa_supplicant@wlan0
8,154
edits

Navigation menu