📜 ⬆️ ⬇️

New RHEL 6 Initialization System

The classic System V initialization scheme, on which the RedHat Enterprise Linux distributions prior to version 6 were based, was familiar and fairly easy to understand: init described the entire boot process in its configuration file / etc / inittab, from which other programs and scripts were called at a certain stage launch.
The situation has changed in RHEL 6: Upstart came to replace System V, which somewhat changed the procedure for configuring the operating system boot process. Upstart, which was originally developed for Ubuntu, fit pretty well into the RedHat system, replacing only a part of the usual startup scheme.
Nevertheless, the changes are significant and poorly documented, so in this article I will try to clarify the new boot scheme, and what it introduced.

The first thing that catches your eye is the almost empty "/ etc / inittab": there is only one uncommented line in it that indicates the default run level. The execution levels themselves have not changed: the third level still corresponds to the usual multi-user mode, and the fifth one also runs the graphics server.
The string has the usual look:

id: 5: initdefault:

Here "5" is the default execution level, i.e. This installation will automatically start the graphical server when it is loaded (or at least it will try).
The main structural difference of the new initialization system is that it functions by responding to events. For example: a transition to a new launch level -> an event is processed and scripts are executed; Received an event by pressing "Ctrl-Alt-Delete" - certain actions are performed. All these events are controlled by one program, which has the classic name: "init", and lies in the "/ sbin" directory. After receiving the event, the system performs the actions described in the corresponding file from the "/ etc / init" directory. In this directory there are files that describe the behavior of the system when receiving an event, and, according to terminology, are called task files.
The task file has a simple syntax: it indicates the event upon which the task should be started (“start on” keyword) or stop (“stop on” keyword), and what should be started (“exec” keyword for single commands, "Script" for scripts).
The most difficult moment is to make out and remember what events are, and what they are called. Some of the most common events are:
')
- startup : the first event at system startup. It corresponds to the stage of launching the old “rc.sysvinit” script, which in RedHat was previously started from “/ etc / inittab”, and now it is started from upstart.

- runlevel : the event is generated when the execution level changes. Configs usually indicate the number of the execution level in order to intercept the transition event to a specific level.

- stopped : generated after the completion of the task

- started : generated after the task has started

Consider the startup procedure. The kernel was loaded, caused "/ sbin / init". As I said, the first is the startup event. The handler is in the rcS.conf file:

start on startup
exec /etc/rc.d/rc.sysinit

As a result, the same “rc.sysinit” is executed, which was performed before. The same file contains the “post-stop” script, which is launched after the completion of the “rc.sysinit” script, analyzes / etc / inittab and raises the execution level change event to the default level. When a level is changed, a transition to a new execution level event is generated, and the corresponding handlers are called. One of the pivot points is “rc.conf”:

start on runlevel [0123456]
export RUNLEVEL
exec /etc/rc.d/rc $ RUNLEVEL

In essence, the same thing is done as before: the usual script "/etc/rc.d/rc" is launched with the execution level parameter to which the transition is made, starting services from "/etc/init.d/". The variable “RUNLEVEL” is also exported here so that it can be used further in the script and in other task files.

Consider another handler described in the "/etc/init/prefdm.conf" file:

start rn RUNLEVEL = 5
stop on starting rc RUNLEVEL = [! 5]
respawn
respawn limit 10 120
exec / etc / X11 / prefdm -nodaemon

This is the startup configuration file for the graphical server. The first line indicates the launch of the script upon the “rc” task stop event (which corresponds to the “rc.conf” configuration file), and the “RUNLEVEL” variable is also checked. The second one stops the script at the start of the “rc” task and at any level of execution, except 5.
The “respawn” keyword means the same thing as before: if the process described after the “exec” keyword stops, then upstart will restart it. And below is a limitation: 10 launch attempts are allowed with an interval of 120 seconds so that the problem in the configuration of the graphics server does not loop its launch in an infinite loop.
From all the above, the following conclusion can be made: upstart is partially embedded in RedHat, in fact the contents of the file "/ etc / inittab" are now separated into several configuration files in the directory "/ etc / init", and the old set of initialization and start scripts of the directory "/ etc / rc.d "remained untouched. This scheme is very different from the one used in the same Ubuntu, for which the upstart was originally developed, and services are started directly from it, which ensures concurrency, monitoring and some other functions.
RedHat does not implement all this functionality, most likely for compatibility. To start the service, you need to use the usual “service” command, or specify the full path to the start script. Implementation is likely to take place gradually, and now, from the advantages, we have gained greater flexibility in setting up the launch system, monitoring capabilities, and, in a rudimentary level, parallelism. I don’t see any particular flaws, the system is new and just not familiar at first glance, and a smooth transition will allow you to gradually get used to the system and start using it when solving administrative tasks.

Source: https://habr.com/ru/post/118769/


All Articles