meta data for this page
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
linux:systemd [2015/10/15 13:02] – niziak | linux:systemd [2017/05/22 14:22] – niziak | ||
---|---|---|---|
Line 1: | Line 1: | ||
===== HowTo ===== | ===== HowTo ===== | ||
==== start / stop ==== | ==== start / stop ==== | ||
+ | Rerun all generators, reload all unit files and recreate dependency tree: | ||
<code bash> | <code bash> | ||
systemctl daemon-reload | systemctl daemon-reload | ||
Line 16: | Line 17: | ||
<code bash> | <code bash> | ||
+ | systemd-analyze blame | ||
systemd-analyze critical-chain | systemd-analyze critical-chain | ||
+ | systemd-analyze critical-chain | ||
+ | systemctl list-dependencies network.service | ||
systemctl --failed | systemctl --failed | ||
</ | </ | ||
+ | <code bash> | ||
+ | systemd-cgtop | ||
+ | </ | ||
==== emergency mode ==== | ==== emergency mode ==== | ||
Line 42: | Line 49: | ||
< | < | ||
- | === Start service when MMC card is inserted === | + | Enable debug console on tty9 |
+ | <code bash> | ||
+ | |||
+ | ==== Start service when MMC card is inserted | ||
Create directory " | Create directory " | ||
List of devices: <code bash> | List of devices: <code bash> | ||
Line 70: | Line 80: | ||
=== [Unit] === | === [Unit] === | ||
+ | * Requires | ||
+ | * Conflicts - negative dependencies, | ||
+ | |||
* Requisite - similar to require, but if not met, service will be not started (fail immediately). Usefull to perform action when removable device is inserted. | * Requisite - similar to require, but if not met, service will be not started (fail immediately). Usefull to perform action when removable device is inserted. | ||
* Requisite=!local-fs.target | * Requisite=!local-fs.target | ||
+ | |||
* BindsTo - similar to require, but also declares to stop unit when other units dissapers (aslo nice for removable devices handling) | * BindsTo - similar to require, but also declares to stop unit when other units dissapers (aslo nice for removable devices handling) | ||
+ | * PartOf - stops/ | ||
+ | |||
* After - start service after other services are started completely. | * After - start service after other services are started completely. | ||
+ | * Before | ||
+ | |||
=== [Service] === | === [Service] === | ||
+ | * Type | ||
+ | * Type=simple | ||
+ | * Type=forking - process will spawn child and exit. Child should live as daemon. | ||
+ | * PIDFile=/ | ||
+ | * Type=oneshot - process should exit. Systemd is not waiting for finish. Like batch file. | ||
+ | * usefull for setup some things, not starting daemons. See '' | ||
+ | * Multiple ExecStart= allowed, and will be executed sequentially | ||
+ | * Type=dbus | ||
+ | * Type=notify | ||
+ | * Type=idle | ||
+ | |||
+ | |||
+ | * ExecStart= - first argument MUST be full path to executable | ||
+ | * ExecStart=-/ | ||
+ | * Multple ExecStart= are allowed, and executed sequentially. If one command fails, other lines are not executed and unit is failed. | ||
+ | * ExecStartPre= - '' | ||
+ | * ExecStartPost= - will be executed only if service has started successfully | ||
+ | * ExecStop= | ||
+ | * ExecReload= | ||
+ | |||
* Nice=-20 | * Nice=-20 | ||
* IOSchedulingClass=0 | * IOSchedulingClass=0 | ||
* IOSchedulingPriority=0 | * IOSchedulingPriority=0 | ||
* StandardOutput=tty |none | journal+console | * StandardOutput=tty |none | journal+console | ||
+ | |||
+ | * Restart=always | ||
+ | * RestartSec=10s | ||
+ | |||
+ | * RemainAfterExit=Yes - keep service active status, even all process exits. usefull for '' | ||
Line 87: | Line 130: | ||
=== Remove startup console clearing === | === Remove startup console clearing === | ||
- | <code> | + | <file | / |
- | / | + | |
[Service] | [Service] | ||
TTYVTDisallocate=no | TTYVTDisallocate=no | ||
+ | </ | ||
+ | |||
+ | === udev === | ||
+ | In udev rules.d add TAG+=" | ||
+ | < | ||
+ | SUBSYSTEM==" | ||
+ | SYMLINK+=" | ||
+ | TAG+=" | ||
+ | OPTIONS+=" | ||
</ | </ | ||
+ | And now device is visible from systemd: | ||
+ | <code bash> | ||
+ | systemctl -l -a | ||
+ | dev-input-event0.device | ||
+ | dev-input-lcd_sandwich_touchscreen.device | ||
+ | </ | ||
+ | You can create refer to device, e.g. create .wants directory | ||
+ | < | ||
+ | === udev: start service === | ||
+ | To start service if device is inserted: | ||
+ | <file | mu.rule> | ||
+ | ..., TAG+=" | ||
+ | </ | ||
+ | === do not mount crypted volumes === | ||
+ | After switching to systemd by command <code bash> | ||
+ | system boot stops and waits for password for encrypted partition (with user data - no needed to system start). | ||
+ | |||
+ | To prevent automount of crypted volumes, additional parameters ' | ||
+ | <file | / | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | === Debian: Set network service timeout === | ||
+ | System startup can hang forever if there is no link on ethernet cable: | ||
+ | < | ||
+ | To set timeout, add file: | ||
+ | <file | / | ||
+ | [Service] | ||
+ | TimeoutStartSec=15 | ||
+ | </ | ||