meta data for this page
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:systemd [2015/09/23 11:16] – niziak | linux:systemd [2024/02/09 19:24] (current) – niziak | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== systemd ====== | ||
| + | |||
| + | * [[https:// | ||
| + | |||
| ===== 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 21: | ||
| <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 53: | ||
| < | < | ||
| - | === 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 84: | ||
| === [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 '' | ||
| + | |||
| + | |||
| + | ==== tricks ==== | ||
| + | Condition doesn' | ||
| + | If service is not started by Condtiion it is still conflicting | ||
| + | |||
| + | === Remove startup console clearing === | ||
| + | <file | / | ||
| + | |||
| + | [Service] | ||
| + | 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 | ||
| + | </ | ||
| + | |||
| + | ====== Issues ====== | ||
| + | |||
| + | ===== init.d services not started ===== | ||
| + | |||
| + | < | ||
| + | systemd-sysv-generator[320]: | ||
| + | systemd-sysv-generator[320]: | ||
| + | systemd-sysv-generator[320]: | ||
| + | </ | ||
| + | |||
| + | Reason is that some init scripts are symlinked to files located in **/opt** directory, which is a different FS (in this case BTRFS subvolume), and it was not mounted when **systemd-sysv-generator** was started. | ||
| + | |||
| + | **Solution: | ||
| + | [[https:// | ||
| + | |||
| + | > Under systemd-enabled systems, there' | ||
| + | > You also need to make sure that your filesystem' | ||
| + | |||
| + | |||
| + | |||