Kernel, init and Services
The Linux Kernel
boot loader loads kernel and an initial RAM-based file system (initramfs) into memory, so it can be used directly by the kernel.
kernel loaded, it immediately initializes and configures the computer’s memory and also configures all the hardware attached to the system.
also load user space applications.
/sbin/init and Services
Once kernel has set up all its hardware and mounted the root filesystem, the kernel runs sbin/init
.
this then becomes the initial process, which then starts other processes to get the system running.
Most other processes on the system trace their origin ultimately to
init
; exceptions include the so-called kernel processes.
Besides starting the system, init
is responsible for keeping the system running and for shutting it down cleanly.
this serial process had the system passing through a sequence of runlevels containing collections of scripts that start and stop services.
Each runlevel supported a different mode of running the system.
however, all major distributions have moved away from this sequential runlevel method of system initialization,
although they usually emulate many System V utilities for compatibility purposes.
Next, we discuss the new methods, of witch systemd has become dominant.
Startup Alternatives
SysVinit viewed things as a serial process, devided into a series of sequential stages.
startup did not easily take advantage of the parallel processing that could be done on multiple processors or cores. (each stage required completion before the next could proceed)
furthermore, shutdown and reboot was seen as a relatively rare event; exactly how long it took was not considered important. (this is no longer true)
some modern methods, such as use of containers, can require almost instantaneous startup times. Thus, systems now require methods with faster and enhanced capabilities.
finally, the older methods required rather complicated startup scripts, which were difficult to keep universal across distribution versions, kernel versions, architectures, and type of systems.
The two main alternatives developed were:
Upstart
- developed by Ubuntu and first included in 2006
- Adopted in Fedora 9 (in 2008) and RHEL 6 and its clones
systemd
- Adopted by Fedora first (in 2011)
- Adopted by RHEL 7 and SUSE
- Replaced Upstart in Ubuntu 16.04
while the migration to systemd was rather controversial, it has been adopted by all major distributions, and so we will not discuss the older System V method or Upstart.
systemd Features
systemd replaced serialized set of steps with aggressive parallelization techniques, which make this faster largely.
complicated shell script are replaced with simpler configuration files, which enumerates …
- preprocess for services
- how to execute service startup
- indicate conditions of the service should be accomplished when startup is finished
/sbin/init now just points to /lib/systemd/systemd