meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
linux:systemd [2015/10/15 13:02] niziaklinux:systemd [2017/05/16 08:53] – [info/status] niziak
Line 16: Line 16:
  
 <code bash> <code bash>
 +systemd-analyze blame
 systemd-analyze critical-chain systemd-analyze critical-chain
 +systemd-analyze critical-chain  network.service
 +systemctl list-dependencies network.service
 systemctl --failed systemctl --failed
 </code> </code>
  
 +<code bash>
 +systemd-cgtop
 +</code>
  
 ==== emergency mode  ==== ==== emergency mode  ====
Line 42: Line 48:
 <code>setenv bootargs ${bootargs} systemd.unit=emergency.target</code> <code>setenv bootargs ${bootargs} systemd.unit=emergency.target</code>
  
-=== Start service when MMC card is inserted ===+Enable debug console on tty9 
 +<code bash>systemctl enable debug-shell.service</code> 
 + 
 +==== Start service when MMC card is inserted ====
 Create directory "dev-mmcblk0.device.wants" and put symlink to service inside it. Create directory "dev-mmcblk0.device.wants" and put symlink to service inside it.
 List of devices: <code bash>systemctl --all --full -t device</code> List of devices: <code bash>systemctl --all --full -t device</code>
Line 70: Line 79:
  
 === [Unit] === === [Unit] ===
 +  * Requires  - units listed here, are also activated with unit. If any start fail, this unit will be not activated.
 +  * Conflicts - negative dependencies, opposite to Requires
 +
   * 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/starts unit when unit listed is stopped/started
 +
   * After - start service after other services are started completely.   * After - start service after other services are started completely.
 +  * Before
 +
  
 === [Service] === === [Service] ===
 +  * Type
 +    * Type=simple  - default -
 +    * Type=forking - process will spawn child and exit. Child should live as daemon.
 +      * PIDFile=/var/run/service.pid - set it to give systemd possibility to known forked child PID
 +    * Type=oneshot - process should exit. Systemd is not waiting for finish. Like batch file.
 +      * usefull for setup some things, not starting daemons. See ''ReamainAfterExit=Yes'')
 +      * Multiple ExecStart= allowed, and will be executed sequentially
 +    * Type=dbus    - systemd assume process started when process name connects to D-Bus
 +    * Type=notify  - systemd assume process started when process explicitly notify systemd using ''sd_notify()''
 +    * Type=idle
 +
 +
 +  * ExecStart= - first argument MUST be full path to executable
 +    * ExecStart=-/bin/false   - minus sign = ignore exit code and assume always success
 +    * Multple ExecStart= are allowed, and executed sequentially. If one command fails, other lines are not executed and unit is failed.
 +  * ExecStartPre= - ''ExecStart='' will run only if all ''ExecStartPre='' command exits with success. May not to start long processes.
 +  * 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 ''Type=oneshot''
  
  
Line 87: Line 129:
  
 === Remove startup console clearing === === Remove startup console clearing ===
-<code> +<file | /etc/systemd/system/getty@tty1.service.d/noclear.conf>
-/etc/systemd/system/getty@tty1.service.d/noclear.conf+
  
 [Service] [Service]
 TTYVTDisallocate=no TTYVTDisallocate=no
 +</file>
 +
 +=== udev ===
 +In udev rules.d add TAG+="systemd":
 +<code>
 +SUBSYSTEM=="input", KERNEL=="event[0-9]*", ENV{ID_INPUT_TOUCHSCREEN}=="1", ATTRS{name}=="edt-ft53*", \
 +    SYMLINK+="input/lcd_sandwich_touchscreen input/touchscreen_edt", \
 +    TAG+="systemd", \
 +    OPTIONS+="link_priority=100"
 </code> </code>
 +And now device is visible from systemd:
 +<code bash>
 +systemctl -l -a
 +  dev-input-event0.device                                                                        loaded    active   plugged   /dev/input/event0
 +  dev-input-lcd_sandwich_touchscreen.device                                                      loaded    active   plugged   /dev/input/lcd_sandwich_touchscreen
 +</code>
 +You can create refer to device, e.g. create .wants directory
 +<code>/etc/systemd/system/ev-input-lcd_sandwich_touchscreen.device.wants</code>
  
 +=== udev: start service ===
 +To start service if device is inserted:
 +<file | mu.rule>
 +..., TAG+="systemd", ENV{SYSTEMD_WANTS}="netctl-auto@mywifi.service"
 +</file>
  
 +=== do not mount crypted volumes ===
 +After switching to systemd by command <code bash>apt-get install systemd-sysv</code>, new problem occurs: 
 +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 'noauto' and 'noearly' must be added to /etc/crypttab:
 +<file | /etc/crypttab>
 +/MyMountPoint /dev/vg_MyName/lv_MyName none luks,noauto,noearly
 +</file>
 +
 +=== Debian: Set network service timeout ===
 +System startup can hang forever if there is no link on ethernet cable:
 +<code>   **] A start job is running for LSB: Raise network interf...38s / no limit)</code>
 +To set timeout, add file:
 +<file | /etc/systemd/system/networking.service.d/reduce-timeout.conf>
 +[Service]
 +TimeoutStartSec=15
 +</file>