+ All Categories
Home > Documents > Useful systemd functionalities

Useful systemd functionalities

Date post: 10-Apr-2022
Category:
Upload: others
View: 14 times
Download: 0 times
Share this document with a friend
26
Embedded Linux Embedded Linux Conference Europe Conference Europe October 6th 2015 Dublin October 6th 2015 Dublin Useful systemd functionalities Useful systemd functionalities without systemd without systemd Bartosz Golaszewski [email protected]
Transcript
Page 1: Useful systemd functionalities

Embedded Linux Embedded Linux Conference EuropeConference Europe

October 6th 2015 DublinOctober 6th 2015 Dublin

Useful systemd functionalities Useful systemd functionalities without systemdwithout systemd Bartosz Golaszewski

[email protected]

Page 2: Useful systemd functionalities

Bartosz GolaszewskiBartosz Golaszewski

➢ > 6.5 years professional experience in embedded Linux

➢ Contributor to the linux kernel, busybox, buildroot, uClibc, sigrok

➢ Part of the firmware team in Project Ara

➢ Maintainer of ACME software

Page 3: Useful systemd functionalities

AgendaAgenda

➢ ACME, sigrok & faster boot➢ Why not systemd?➢ Recreating functionalities

➢ Parallel startup➢ Readahead➢ Security➢ Watchdogs

Page 4: Useful systemd functionalities

ACME, sigrok & faster bootACME, sigrok & faster boot

Page 5: Useful systemd functionalities

ELC 2015 – San JoseELC 2015 – San Jose

➢ « Tunning systemd for embedded » by Alison Chaiken

➢ systemd philosophy & design➢ Pros & cons➢ Demoed systemd's cgroups support,

privilage limitation, watchdogs

Page 6: Useful systemd functionalities

ACME CapeACME Cape

➢ Low-cost multi-channel power monitor➢ Based on TI ina226 power monitor➢ Open hardware/open source➢ Standard BeagleBone Black cape➢ USB, Jack & HE10 connectors➢ http://baylibre.com/acme/➢ ACME wiki

Page 7: Useful systemd functionalities

SigrokSigrok

➢ Portable, cross-platform, free signal analysis software suite

➢ Broad hardware support➢ Various frontends➢ Reusable libraries➢ http://sigrok.org/

Page 8: Useful systemd functionalities

Sigrok + ACME + PulseViewSigrok + ACME + PulseView

➢ X.org, fluxbox x 2, Qt5, Xvfb, x11vnc, PulseView x 2

➢ Boost, uClibc, etc.➢ Startup scripts in /etc/init.d➢ No parallelization

Page 9: Useful systemd functionalities

Why not systemd?Why not systemd?

Page 10: Useful systemd functionalities

Buildroot/busybox initBuildroot/busybox init

➢ Minimalistic version of SysV init➢ No runlevels in busybox init➢ Scripts in /etc/init.d with start/stop

commands➢ No restart, status, etc. commands➢ Startup scripts privided by buildroot

packages

Page 11: Useful systemd functionalities

systemdsystemd

➢ Available as buildroot package➢ Painless configuration➢ Mostly just works➢ Drastic improvement in boot-time➢ X.org is integrated and supports socket

activation

Page 12: Useful systemd functionalities

Reasons not to use systemd in Reasons not to use systemd in embedded devicesembedded devices➢ Merciless deprecation of features

➢ udev firmware loader➢ readahead

➢ Dependence on newer kernels➢ Dependence on glibc➢ Size & attack surface➢ Level of complication

Page 13: Useful systemd functionalities

Dependence on newer kernelsDependence on newer kernels

➢ Forcing kernel updates is great… but not always feasible

➢ Old kernels often in use by companies➢ Out-of-tree SoC support➢ Upgrade not always possible

Page 14: Useful systemd functionalities

Size, attack surface & level of Size, attack surface & level of complicationcomplication➢ Unnecessarily many functionalities in

PID 1➢ Could be avoided with

prctl(PR_SET_CHILD_SUBREAPER, ...)

➢ Priviliged process with many inputs and code paths

➢ >330000 LOC (src/core alone >36000 LOC)

Page 15: Useful systemd functionalities

Recreating systemd functionalitiesRecreating systemd functionalities

Page 16: Useful systemd functionalities

Parallel service startupParallel service startup

➢ systemd :➢ several startup notification types➢ Requires=, After= & Before= configuration

options

➢ Busybox :➢ Block runit startup scripts to wait for

dependencies➢ Use inotifyd to find out when the pidfile has been

created

Page 17: Useful systemd functionalities

Demo: parallel startupDemo: parallel startup (with busyboxed runit and inotifyd)(with busyboxed runit and inotifyd)

Page 18: Useful systemd functionalities

ReadaheadReadahead

➢ Obsolete on modern desktops➢ Still useful on boards with slow

eMMC's➢ systemd implementation nuked...➢ busybox applet

➢ works out-of-the-box ➢ can be run as init

Page 19: Useful systemd functionalities

Demo: readaheadDemo: readahead (busybox applet)(busybox applet)

Page 20: Useful systemd functionalities

Security featuresSecurity features

➢ Extensive cgroups usage for security and resource management in systemd

➢ Not all these features needed in embedded systems

➢ Use cgroup-tools & unshare to achieve similar results

Page 21: Useful systemd functionalities

Demo: security featuresDemo: security features (cgroups + unshare)(cgroups + unshare)

Page 22: Useful systemd functionalities

Software watchdogsSoftware watchdogs

➢ systemd:➢ ShutdownWatchdogSec= option for hw watchdog➢ WatchdogSec= and Restart=on-failure for sw

watchdog➢ process required to call

sd_notify("WATCHDOG=1") periodically

➢ Alternative:➢ Use some trivial action to determine whether a

process is still alive

Page 23: Useful systemd functionalities

Demo: software watchdogsDemo: software watchdogs (without dbus/libsystemd)(without dbus/libsystemd)

Page 24: Useful systemd functionalities

ConclusionConclusion

➢ Philosophy of systemd is: Extract duplicate functionality from daemons and move it to systemd core or kernel.

➢ Most of this functionality already exists in a tiny busybox binary and also mostly does the job.

Page 25: Useful systemd functionalities

ReferencesReferences

➢ http://she-devel.com/ELC_systemd.pdf

➢ http://0pointer.net/blog/➢ busybox documentation➢ systemd manuals➢ http://ewontfix.com/14/

➢ http://busybox.net/~vda/

Page 26: Useful systemd functionalities

Q & AQ & A

Bartosz GolaszewskiBartosz [email protected]@baylibre.com


Recommended