SystemD
From FrugalWiki
Dansk – Deutsch – English – Español – Français – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Polski – Português – Română – Slovenský – Suomi – Svenska – Türkçe – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어
systemd is a system and service manager for Linux, compatible with SysV and LSB init scripts. systemd provides aggressive parallelization capabilities, uses socket and D-Bus activation for starting services, offers on-demand starting of daemons, keeps track of processes using Linux cgroups, supports snapshotting and restoring of the system state, maintains mount and automount points and implements an elaborate transactional dependency-based service control logic. It can work as a drop-in replacement for sysvinit.
See Lennart's blog story for a longer introduction, and the two status updates since then. Also see the Wikipedia article and the project web page.
Home page: http://freedesktop.org/wiki/Software/systemd
Contents |
Installation
To try out systemd on Frugalware you need to
- install systemd
Using systemd
- systemctl: used to introspect and control the state of the systemd system and service manager
- systemd-cgls: recursively shows the contents of the selected Linux control group hierarchy in a tree
- systemadm: a graphical frontend for the systemd system and service manager that allows introspection and control of systemd. Part of the systemd-gtk page. This is a early version and needs more work. Do not use it for now unless you are a developer.
View the man pages for more details.
Listing running services
or
The available services or units can be seen in /lib/systemd/system and /etc/systemd/system (the latter takes precedence).
Activates a service immediately:
Deactivates a service immediately:
Restarts a service:
Reloads a service:
Shows status of a service including whether it is running or not:
Enables a service to be started on bootup:
Disables a service to not start during bootup:
Refer to man systemctl for more details.
Notice that you need to use the full name of a service file. E.g., in order to restart the avahi daemon, issue:
Shut down and reboot the system
Runlevels/targets
Systemd has a concept of targets which serve a similar purpose as runlevels but act a little different. Each target is named instead of numbered and is intended to serve a specific purpose. Some targets are implemented by inheriting all of the services of another target and adding additional services to it. There are systemd targets that mimic the common SystemVinit runlevels so you can still switch targets using the familiar telinit RUNLEVEL
command. The runlevels that are assigned a specific purpose on vanilla Fedora installs; 0, 1, 3, 5, and 6; have a 1:1 mapping with a specific systemd target. Unfortunately, there's no good way to do the same for the user-defined runlevels like 2 and 4. If you make use of those it is suggested that you make a new named systemd target as /etc/systemd/system/$YOURTARGET
that takes one of the existing runlevels as a base (you can look at /lib/systemd/system/graphical.target
as an example), make a directory /etc/systemd/system/$YOURTARGET.wants
, and then symlink the additional services that you want to enable into that directory. (The service unit files that you symlink live in /lib/systemd/system
).
SystemVinit Runlevel | Systemd Target | Notes |
---|---|---|
0 | runlevel0.target, poweroff.target | Halt the system. |
1, s, single | runlevel1.target, rescue.target | Single user mode. |
2, 5 | runlevel2.target, runlevel5.target, multi-user.target | User-defined/Site-specific runlevels. By default, identical to 3. |
3 | runlevel3.target, multi-user.target | Multi-user, non-graphical. Users can usually login via multiple consoles or via the network. |
4 | runlevel4.target, graphical.target | Multi-user, graphical. Usually has all the services of runlevel 3 plus a graphical login. |
6 | runlevel6.target, reboot.target | Reboot |
emergency | emergency.target | Emergency shell |
Changing runlevels:
SystemVinit Command | Systemd Command | Notes |
---|---|---|
telinit 3 | systemctl isolate multi-user.target (OR systemctl isolate runlevel3.target OR telinit 3) | Change to multi-user run level. |
sed s/^id:.*:initdefault:/id:3:initdefault:/ | ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target | Set to use multi-user runlevel on next reboot. |
Unit vs rc scripts
some units can be find here : http://0pointer.de/public/systemd-units
Identifying your problem area
- Remove ro and quiet from the kernel command line.
- Add systemd.log_level=debug to the kernel command line to log systemd with debug output enabled.
- Add systemd.log_target=kmsg to the kernel command line to let systemd buffer to be written to the kernel log buffer.
- plymouth don't start :
If for some reasons you don't see the splash edit /lib/systemd/system/plymouth-start.service and change
[Service] ExecStart=/sbin/plymouthd --mode=boot --pid-file=/run/plymouth/pid
by
[Service] ExecStart=/sbin/plymouthd --mode=boot --pid-file=/run/plymouth/pid --debug --debug-file=/tmp/plymouth-debug-out
that will create a /tmp/plymouth-debug-out with some informations
When shutdown hangs
Drop a shell script in /lib/systemd/system-shutdown/ with a content like the following
#!/bin/sh mount / -o rw,remount dmesg > /shutdown.dmesg mount / -o ro,remount
then make that executable and boot with systemd.log_level=debug systemd.log_target=kmsg on the kernel command line, that will enable debug logging and the script you dropped in /lib/systemd/system-shutdown/ will be executed when we go down really really late, right before shutdown, so this script stores away kmsg from there.
TODO
NOTE: please do not remove items from the list without first asking on the list or discussing on #frugalware.dev. thank you.
- checklist:
- systemctl list-units --all, there should be no red in the output - should be ok now
- upgrade: does the box reboot properly after installing systemd? - should be ok now
- systemd.unit=emergency.target (and rescue, multi-user, graphical) works properly? - should be ok now
- need to test with a full install as well - should be ok now
- could we have progressbar again on fsck -> it's now part of upstream TODO
- localization? as far as i see systemd does not support it yet, though the doc states one benefit of the file format is that it's easy to localize...
Changes after release 1.5
- separate unit files for kdm/gdm/xdm/etc - for now we'll just keep doing what rc.4 used to do
- change the 'tty1..11 getty + tty12: x' layout
- (hermier) It would means 8 tty and use tty9 as first graphical target, and let us 3 open and directly accessible graphical tty by keyboard if more sessions are needed.
- we can start removing sysvinit scripts (but not before! and not support in general, needed by 3rd-party legacy software)
How to submit units upstream
It's critical that (in most cases, expect for low-level stuff like lvm2) once you wrote a unit for a package, you should not add it to the Frugalware build script but submit it upstream, and then backport that patch, once it's accepted. An example is the strongswan unit.