systemd
systemd A new init system for Linux
systemd A new init system for Linux Makes booting  faster
systemd A new init system for Linux Makes 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 Linux Makes booting  faster
Do it in parallel?
systemd A new init system for Linux Makes booting  faster
Do it in parallel? Dependencies!
upstart A new init system for Linux
upstart A new init system for Linux Makes booting  faster  by encoding dependencies between modules
upstart A new init system for Linux Makes 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 Linux Makes 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 Linux Makes 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 Linux Makes 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 Linux Makes 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 daemon Per-socket startup – e.g. rsync, nrpe
xinetd List of sockets
When a connection is made, start the related daemon Per-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 it Only 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 it Only 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 filesystems autofs!
systemd – and others... This isn't actually new
systemd – and others... This isn't actually new Mac OS X - launchd
systemd – and others... This isn't actually new Mac OS X – launchd
xinetd!
systemd A new init system for Linux Makes booting  faster
systemd A new init system for Linux Makes booting  faster Start processes in parallel
systemd A new init system for Linux Makes booting  faster Start 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

CLUG 2010 09 - systemd - the new init system