CLUG 2010 09 - systemd - the new init system

  • Upload
    paulway

  • View
    1.548

  • Download
    1

Embed Size (px)

Citation preview

Default

systemd

systemd

A new init system for Linux

systemd

A new init system for LinuxMakes booting faster

systemd

A new init system for LinuxMakes booting faster

How?

systemd

How does init work anyway?

System V init

The init process is started by the kernel

System V init

The init process is started by the kernel

It reads /etc/inittab to find the default run level (initdefault)

[root@tachyon ~]# grep initdefault /etc/inittab
id:5:initdefault:

System V init

The init process is started by the kernel

It reads /etc/inittab to find the default run level (initdefault)

It then reads the files starting with S in /etc/rc.d/rc${initdefault}.d
[root@tachyon ~]# ls -1 /etc/rc.d/rc5.d/S*
/etc/rc.d/rc5.d/S02lvm2-monitor
/etc/rc.d/rc5.d/S08ip6tables
/etc/rc.d/rc5.d/S08iptables
/etc/rc.d/rc5.d/S11auditd
/etc/rc.d/rc5.d/S11portreserve
...

System V init

The init process is started by the kernel

It reads /etc/inittab to find the default run level (initdefault)

It then reads the files starting with S in /etc/rc.d/rc${initdefault}.d

It executes each one in order, one at a time.

systemd

A new init system for LinuxMakes booting faster

Do it in parallel?

systemd

A new init system for LinuxMakes booting faster

Do it in parallel?Dependencies!

upstart

A new init system for Linux

upstart

A new init system for LinuxMakes booting faster by encoding dependencies between modules

upstart

A new init system for LinuxMakes booting faster by encoding dependencies between modules

upstart then resolves these dependencies and starts up as many things as it can in parallel

upstart

Then everyone gets kittens!

upstart

A new init system for LinuxMakes booting faster by encoding dependencies between modules

upstart then resolves these dependencies and starts up as many things as it can in parallel

Only problem is...

upstart

A new init system for LinuxMakes booting faster by encoding dependencies between modules

upstart then resolves these dependencies and starts up as many things as it can in parallel

Only problem is...Encoding the dependencies.

upstart

A new init system for LinuxMakes booting faster by encoding dependencies between modules

upstart then resolves these dependencies and starts up as many things as it can in parallel

Only problem is...Domain-specific language required...

upstart

A new init system for LinuxMakes booting faster by encoding dependencies between modules

upstart then resolves these dependencies and starts up as many things as it can in parallel

Only problem is...We're still starting too much...

Booting a system

What actually needs to get started?

Booting a system

What actually needs to get started?System V init:Try to think of everything and boot it in what we hope is the right order...

Booting a system

What actually needs to get started?System V init:Try to think of everything and boot it in what we hope is the right order...

upstart:Try to think of everything, resolve dependencies and hope that works...

Booting a system

How do we know what needs to get started?

Booting a system

How do we know what needs to get started?We wait for something to use it!

Booting a system

How do we know what needs to get started?We wait for something to use it!

Then we catch the request and start the daemon.

Booting a system

How do we know what needs to get started?We wait for something to use it!

Then we catch the request and start the daemon.

Is there something that already works like this?

Booting a system

How do we know what needs to get started?We wait for something to use it!

Then we catch the request and start the daemon.

Is there something that already works like this?Yes:

Booting a system

How do we know what needs to get started?We wait for something to use it!

Then we catch the request and start the daemon.

Is there something that already works like this?Yes: xinetd

xinetd

List of sockets

xinetd

List of sockets

When a connection is made, start the related daemon

xinetd

List of sockets

When a connection is made, start the related daemonPer-socket startup e.g. rsync, nrpe

xinetd

List of sockets

When a connection is made, start the related daemonPer-socket startup e.g. rsync, nrpe

Hand socket to daemon 'wait' option

Sockets in startup

Lots of services use sockets

Sockets in startup

Lots of services use sockets/var/run/cups/cups.sock

Sockets in startup

Lots of services use sockets/var/run/cups/cups.sock

/var/run/dbus/system_bus_socket

Sockets in startup

Lots of services use sockets/var/run/cups/cups.sock

/var/run/dbus/system_bus_socket

/var/run/rpcbind.sock

Sockets in startup

Lots of services use sockets/var/run/cups/cups.sock

/var/run/dbus/system_bus_socket

/var/run/rpcbind.sock

/dev/log

systemd - sockets

Work out what sockets we need to set up

systemd - sockets

Work out what sockets we need to set up

Set them all up in parallel

systemd - sockets

Work out what sockets we need to set up

Set them all up in parallel

When the socket is opened, start up its related daemon

systemd - sockets

Work out what sockets we need to set up

Set them all up in parallel

When the socket is opened, start up its related daemon and hand the socket to it

systemd - sockets

Work out what sockets we need to set up

Set them all up in parallel

When the socket is opened, start up its related daemon and hand the socket to itOnly that application gets paused

systemd - sockets

Work out what sockets we need to set up

Set them all up in parallel

When the socket is opened, start up its related daemon and hand the socket to itOnly that application gets paused

Only for that request

systemd - sockets

Work out what sockets we need to set up

Set them all up in parallel

When the socket is opened, start up its related daemon and hand the socket to it

Same logic for D-Bus

systemd - sockets

Work out what sockets we need to set up

Set them all up in parallel

When the socket is opened, start up its related daemon and hand the socket to it

Same logic for D-Bus

Same logic for filesystems

systemd - sockets

Work out what sockets we need to set up

Set them all up in parallel

When the socket is opened, start up its related daemon and hand the socket to it

Same logic for D-Bus

Same logic for filesystemsautofs!

systemd and others...

This isn't actually new

systemd and others...

This isn't actually newMac OS X - launchd

systemd and others...

This isn't actually newMac OS X launchd

xinetd!

systemd

A new init system for LinuxMakes booting faster

systemd

A new init system for LinuxMakes booting fasterStart processes in parallel

systemd

A new init system for LinuxMakes booting fasterStart processes in parallel

Start fewer processes

systemd results so far

System V init:[paulway@tachyon ~]$ echo $$
2440

systemd results so far

System V init:[paulway@tachyon ~]$ echo $$
2440

MacOS:154

systemd results so far

System V init:[paulway@tachyon ~]$ echo $$
2440

Lennart's system:grep: 77 times

MacOS:154

systemd results so far

System V init:[paulway@tachyon ~]$ echo $$
2440

Lennart's system:grep: 77 times

awk: 92 times

MacOS:154

systemd results so far

System V init:[paulway@tachyon ~]$ echo $$
2440

Lennart's system:grep: 77 times

awk: 92 times

sed: 74 times

MacOS:154

systemd managing processes

System V init also restarts things

systemd managing processes

System V init also restarts things

Then they go off and do what they like

systemd managing processes

Manage daemon processes

systemd managing processes

Manage daemon processesstartup

systemd managing processes

Manage daemon processesstartup

shutdown

systemd managing processes

Manage daemon processesstartup

shutdown

log on failure

systemd managing processes

Manage daemon processesstartup

shutdown

log on failure

maintain their resources

systemd managing processes

Manage daemon processesstartup

shutdown

log on failure

maintain their resources

What about rogue processes?

systemd managing processes

Kernel cgroups (Control Groups)

systemd managing processes

Kernel cgroups (Control Groups)cgroup inheritance

systemd managing processes

Kernel cgroups (Control Groups)cgroup inheritance

Info via /proc/$$/cgroup

systemd managing processes

Kernel cgroups (Control Groups)cgroup inheritance

Info via /proc/$$/cgroup

Notify when cgroup is empty

systemd managing processes

Kernel cgroups (Control Groups)cgroup inheritance

Info via /proc/$$/cgroup

Notify when cgroup is empty

Resource limits for entire group

systemd - units

Units

systemd - units

UnitsService standard daemon

systemd - units

UnitsService standard daemon

Socket unix, internet, fifo

systemd - units

UnitsService standard daemon

Socket unix, internet, fifo

Device from udev

systemd - units

UnitsService standard daemon

Socket unix, internet, fifo

Device from udev

Mount standard filesystem mount

systemd - units

UnitsService standard daemon

Socket unix, internet, fifo

Device from udev

Mount standard filesystem mount

Automount paired with mount

systemd - units

UnitsService standard daemon

Socket unix, internet, fifo

Device from udev

Mount standard filesystem mount

Automount paired with mount

Target logical group of units

systemd - units

UnitsService standard daemon

Socket unix, internet, fifo

Device from udev

Mount standard filesystem mount

Automount paired with mount

Target logical group of units

Snapshot save and restore state

systemd - units

Units - configurationService

Socket

Device

Mount

Automount

Target

Snapshot

systemd - units

Units - configurationService System V init file

Socket

Device

Mount

Automount

Target

Snapshot

systemd - units

Units - configurationService System V init file - LSB

Socket

Device

Mount

Automount

Target

Snapshot

systemd - units

Units - configurationService System V init file - LSB

Socket cups.socket

Device

Mount

Automount

Target

Snapshot

systemd - units

Units - configurationService System V init file - LSB

Socket cups.socket

Device udev

Mount

Automount

Target

Snapshot

systemd - units

Units - configurationService System V init file - LSB

Socket cups.socket

Device udev

Mount /etc/fstab

Automount

Target

Snapshot

systemd - units

Units - configurationService System V init file - LSB

Socket cups.socket

Device udev

Mount /etc/fstab

Automount home.automount

Target multi-user.target

Snapshot suspend.snapshot

systemd other features

Units all have dependencies

systemd other features

Units all have dependencies

Fully compatible with System V init scripts

systemd other features

Units all have dependencies

Fully compatible with System V init scripts, /etc/fstab and other files

systemd other features

Units all have dependencies

Fully compatible with System V init scripts, /etc/fstab and other files

Native config overrides legacy config

systemd other features

Units all have dependencies

Fully compatible with System V init scripts, /etc/fstab and other files

Native config overrides legacy config

Templating / instance mechanism

systemd other features

Units all have dependencies

Fully compatible with System V init scripts, /etc/fstab and other files

Native config overrides legacy config

Templating / instance mechanismgetty

systemd other features

Units all have dependencies

Fully compatible with System V init scripts, /etc/fstab and other files

Native config overrides legacy config

Templating / instance mechanismgetty

Ethernet control units

systemd other features

Units all have dependencies

Fully compatible with System V init scripts, /etc/fstab and other files

Native config overrides legacy config

Templating / instance mechanism

Arbitrary number of sockets on launch

systemd other features

Units all have dependencies

Fully compatible with System V init scripts, /etc/fstab and other files

Native config overrides legacy config

Templating / instance mechanism

Arbitrary number of sockets on launch

Supplies /dev/initctl and wtmp/utmp

systemd more features

Transaction system

systemd more features

Transaction system

Start/exit time of each daemon

systemd more features

Transaction system

Start/exit time of each daemon

Full restart of init at any time

systemd more features

Transaction system

Start/exit time of each daemon

Full restart of init at any time

Basic daemon startup coded in C

systemd more features

Transaction system

Start/exit time of each daemon

Full restart of init at any time

Basic daemon startup coded in C

Full Dbus introspection

systemd - when?

Coming soon to a distro near you!

systemd - when?

Coming soon to a distro near you!Fedora 14

systemd - when?

Coming soon to a distro near you!Fedora 15

systemd - when?

Coming soon to a distro near you!Fedora 15

OpenSuSE

systemd - when?

Coming soon to a distro near you!Fedora 15

OpenSuSE

Debian

systemd - when?

Coming soon to a distro near you!Fedora 15

OpenSuSE

Debian

Gentoo

ArchLinux

systemd - when?

Coming soon to a distro near you!Fedora 15

OpenSuSE

Debian

Gentoo

systemd - when?

Coming soon to a distro near you!Fedora 15

OpenSuSE

Debian

GentooNo packages for Ubuntu?!

Your daemon and systemd

Your daemon now has to:

Your daemon and systemd

Your daemon now has to do a lot less

Your daemon and systemd

Your daemon now has to do a lot lessDon't fork or double-fork

Your daemon and systemd

Your daemon now has to do a lot lessDon't fork or double-fork

Don't drop user privileges

Your daemon and systemd

Your daemon now has to do a lot lessDon't fork or double-fork

Don't drop user privileges

Don't write PID files

Your daemon and systemd

Your daemon now has to do a lot lessDon't fork or double-fork

Don't drop user privileges

Don't write PID files

Things become easier

Your daemon and systemd

Your daemon now has to do a lot lessDon't fork or double-fork

Don't drop user privileges

Don't write PID files

Things become easierWrite error to stderr

Your daemon and systemd

Your daemon now has to do a lot lessDon't fork or double-fork

Don't drop user privileges

Don't write PID files

Things become easierWrite error to stderr

Sockets and stuff in unit file

systemd

systemd

Don't be afraid

Click to edit the title

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline LevelNinth Outline Level

CLUG 2010-09

systemd the new init system that everyone's talking about

Click to edit the title text format

Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline LevelNinth Outline Level

CLUG 2010-09

systemd the new init system that everyone's talking about