Site Map - skip to main content - dyslexic font - mobile - text - print

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes Monday through Friday.


hpr1930 :: A systemd primer

An introduction to the modern linux init system

<< First, < Previous, Latest >>

Hosted by Clinton Roy on 2015-12-25 is flagged as Clean and is released under a CC-BY-SA license.
Listen in ogg, spx, or mp3 format. | Comments (1)

1 What is systemd?

A dependency system for unix services.
And, a set of basic unix services to make a unix system usable.
And, a growing list of not quite so basic services

  • NTP, networkd, timers (crond/atd)

From a programmers perspective, it's the mainloop phenomenon.

2 Alternatives

Solaris: Service Management Facility
Mac OSX: launchd
Ubuntu: upstart (until recently)

3 Replaces

SYSV
LSB (actually implements LSB deps)

4 Terminology

units

  • [auto]mount
  • swap
  • path (inotify triggers)
  • socket
  • timer (crond/atd)
  • service
  • slice (cgroup)
  • pseudo
    • device
    • snapshot
    • scope

targets

  • replace run levels
  • default target at boot
  • can isolate to just one target

5 Advantages - Design

Proper, explicit dependencies between system compontents
Starts components in parallel
A proper separation of concerns, lots of situations covered.

  • configuration files are regular, simple to understand generally small
  • OTOH, there are LOTS of options

Configuration is not runnable shell.

[Unit]
Description=CUPS Scheduler
Documentation=man:cupsd(8)

[Service]
ExecStart=/usr/sbin/cupsd -l
Type=simple

[Install]
Also=cups.socket cups.path
WantedBy=printer.target

Separate system and user daemons.

6 Advantages - Sysadmins

Modify configuration without modifying upstream configuration
Service watching (startup, watchdog, failure modes)
systemd-delta

[EXTENDED]   /lib/systemd/system/rc-local.service → /lib/systemd/system/rc-local.service.d/debian.conf
[EXTENDED]   /lib/systemd/system/systemd-timesyncd.service → /lib/systemd/system/systemd-timesyncd.service.d/disable-with-time-daemon.conf
[EQUIVALENT] /etc/systemd/system/default.target → /lib/systemd/system/default.target

3 overridden configuration files found.

7 Advantages - Programming

Removal of some error and security prone code

  • socket activation (e.g. privileged ports)
  • user/group changing

8 Advantages - Provisioning

standardized cgroup controls
containers
debootstrap ; systemd-spawn-boot * systemd takes care of all pseudo file systems for you

9 Advantages - Users

quick to boot
can reduce load later on (services start & stop as required)

10 Examples

Color legend:

  • black = Requires
  • dark blue = Requisite
  • dark grey = Wants
  • red = Conflicts
  • green = After

systemd-analyze blame

systemd-analyze plot

systemd-analyze plot gdm.service

11 Disadvantages

Journald

  • It’s really nice in theory, but in practice I’ve found it to be slow and buggy

It’s a little new, so LTS distros necessarily have older versions

  • el7 has something like 200 patches

network-online.target is a bit flakey
DBUS

  • Unix is a graveyard of IPC, I don't feel DBUS is much better
  • KDBUS means it will probably be around for ever.

12 Quandries

Deeply hooked into linux specific details, not portable

  • kernel api, cgroups, udev etc.

Some cool features relient on file system e.g. btrfs for snapshot

13 Future

I haven’t had a chance to play with networkd yet, but it sounds like it’s going to be very good.

14 Questions

Migrating

  • It depends…
  • systemd only supports start/stop/reload
  • work with the daemon: oneshot/simple/forking/inetd
  • integrate with systemd: notify, watchdog

Userspace

  • Every login, a separate systemd -> user is spawned
  • Can override with .config/systemd files

Comments

Subscribe to the comments RSS feed.

Comment #1 posted on 2015-12-29T23:01:07Z by Frank

Nicely done. I do appreciate the big picture overview; it provides a context and frame of reference that many stories I've read about SystemD do not.

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to
record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Title:
Comment:
Anti Spam Question: What does the P in HPR stand for ?
Are you a spammer →
Who hosted this show →
What does HPR mean to you ?