Credit: https://systemd.io
OUR EXPERT
Mats Tage Axelsson can be counted on to find new ways to simplify your Linux usage in complex ways. Anything to seem as cool as he thinks he is.
OUR EXPERT
Mats Tage Axelsson can be counted on to find new ways to simplify your Linux usage in complex ways. Anything to seem as cool as he thinks he is.
How do you start a computer? “Press the power button!” is not a valid response. Most of you know that the firmware loads the kernel, which in turn hands it over to the system. Maybe you know that it starts process one, aka PID=1, and that this process is the key not just to booting fast and securely, but also to keep all things running.
As expected with Linux, you have many options to handle your own boot. Even the distinction that PID=1 also handles services and other things is not always a given. It started with shell scripts, which users and administrators enhanced with SysV, and via other ideas we mostly now use Systemd.
That is almost a universal Linux truth, but nothing is ever certain in our world, so new ideas have come out. We’ll cover here what changes there have been, where it got us and a hint about things to come.
To start: history
In the early days of Unix, the system would start with init as process number one. The process number one is still the way your computer starts. Originally, the init ran shell scripts to run everything. This worked well for the small systems of the time, though even then it had limitations. One major limitation is that they run one after another. If one script fails, the whole boot fails. And when one script starts slowly, the whole boot slows down. As systems became bigger and needed more services running, administrators needed to manage services from boot and beyond. While scripting makes it possible, it is clumsy. In the beginning, it required bespoke shell scripts at every step. With init only starting 12 TTY sessions, the user had to start all services on their own. The first solution was to hardcode specific files where these scripts should go. That’s the start of SysV’s init and init.rc files.
When using SysV, you have shell scripts in /etc/init.d/ and you can add your own if you follow the rules.
WHAT ABOUT THE BSD?
As BSD has a longer history than Linux, it has an older initialisation system. It even predates SysV and has a similar structure to store files. A directory named /etc/rc.d contains the service files. They execute according to keywords embedded inside the files. Administrators must determine these dependencies when writing the scripts. This makes the system easy to handle for administrators, which is why it is still popular among BSD users. It starts services the same way as SysV, using the path to the service script and the start parameter.
Despite this apparent simplicity, it requires exact scripts that determine all the actions to start and stop. Dependencies are also supported, but each and every service you need must be in the file.
The BSD initialisation system is older than Systemd. Despite this, it works reliably and has been updated over the years. These updates make it a useful tool but not as encompassing as Systemd. Whether that is good or bad is a matter of opinion.
Given these differences, your choice depends on what demands you have on the power of the system versus the power you can wield for different situations. With Systemd, apps and daemons already have support for the desktop. On servers, you have other systems with other needs. Finally, with embedded systems, you want to tweak everything to the last byte, in which case, you can get away with other solutions.
WHAT ABOUT THE BSD?