INIT(8) | Manual del Administrador del Sistema Linux | INIT(8) |
init, telinit - control de inicialización de procesos
/sbin/init [ -a ] [ -s ] [ -b ] [
-z xxx ] [ 0123456Ss ]
/sbin/init [ --version ]
/sbin/telinit [ -t SEGUNDOS ] [ 0123456sSQqabcUu ]
/sbin/telinit [ -e VAR[=VAL] ]
Init es el padre de todos los procesos. Su papel primario es crear procesos a partir de un guión guardado en el fichero /etc/inittab (véase inittab(5)). Este fichero normalmente tiene entradas que harán que se levante gettys en cada línea en que los usuarios puedan conectarse. También controla procesos autónomos requeridos por un sistema particular.
A runlevel is a software configuration of the system which allows only a selected group of processes to exist. The processes spawned by init for each of these runlevels are defined in the /etc/inittab file. init can be in one of eight runlevels: 0–6 and S (a.k.a., s). The runlevel is changed by having a privileged user run telinit, which sends appropriate signals to init, telling it which runlevel to change to.
Runlevels S, 0, 1, and 6 are reserved. Runlevel S is used to initialize the system on boot. When starting runlevel S (on boot) or runlevel 1 (switching from a multi-user runlevel) the system is entering “single-user mode”, after which the current runlevel is S. Runlevel 0 is used to halt the system; runlevel 6 is used to reboot the system.
After booting through S the system automatically enters one of the multi-user runlevels 2 through 5, unless there was some problem that needs to be fixed by the administrator in single-user mode. Normally after entering single-user mode the administrator performs maintenance and then reboots the system.
For more information, see the manpages for shutdown(8) and inittab(5).
Runlevels 7–9 are also valid, though not really documented. This is because "traditional" Unix variants don't use them.
Runlevels S and s are the same. Internally they are aliases for the same runlevel.
After init is invoked as the last step of the kernel boot sequence, it looks for the file /etc/inittab to see if there is an entry of the type initdefault (see inittab(5)). The initdefault entry determines the initial runlevel of the system. If there is no such entry (or no /etc/inittab at all), a runlevel must be entered at the system console.
Runlevel S or s initialize the system and do not require an /etc/inittab file.
In single user mode, /sbin/sulogin is invoked on /dev/console.
When entering single user mode, init initializes the consoles stty settings to sane values. Clocal mode is set. Hardware speed and handshaking are not changed.
Cuando se entra por primera vez en un modo multiusuario, init realiza las entradas boot y bootwait para permitir que se monten los sistemas de ficheros antes de que los usuarios se presenten al sistema. Entonces se procesan todas las entradas para este nivel.
When starting a new process, init first checks whether the file /etc/initscript exists. If it does, it uses this script to start the process.
Cada vez que un hijo termina, init registra el hecho y la razón de su muerte en /var/run/utmp y /var/log/wtmp, suponiendo que estos ficheros existen.
Tras haber lanzado todos los procesos especificados, init espera a que alguno de sus procesos descendientes muera, una señal de fallo de alimentación o hsata que se le indique por telinit que cambie el nivel de ejecución del sisema. Cuando alguna de las tres condiciones anteriores ocurre, re-examina el fichero /etc/inittab. Se pueden añadir nuevas entradas a este fichero en cualquier momento. Sin embargo, init aun espera a que alguna de las tres condiciones anteriores suceda. Para proporcionar un respuesta inmediata, telinit Q o el mandato q puede levantar init para que re-examine el fichero /etc/inittab.
If init is not in single user mode and receives a powerfail signal (SIGPWR), it reads the file /etc/powerstatus. It then starts a command based on the contents of this file:
If /etc/powerstatus doesn't exist or contains anything else then the letters F, O or L, init will behave as if it has read the letter F.
Usage of SIGPWR and /etc/powerstatus is discouraged. Someone wanting to interact with init should use the /run/initctl control channel – see the initctl(5) manual page for more documentation about this.
Cuando se lesolicita a init que cambie el nivel, envía la señal de aviso SIGTERM a todos los procesos que no están definidos en el nuevo nivel de ejecución. Espera 3 segundos antes de forzar la terminación de estos procesos mediante la señal SIGKILL. Observe que init supone que todos estos procesos (y sus descendientes) permanecen en el mismo grupo de procesos que init creó originalmente para ellos. Si cualquier proceso cambia la afiliación de grupo de proceso no recibirá estas señales. Tales procesos necesitan ser terminados de forma separada.
/sbin/telinit está enlazado con /sbin/init. Toma un argumento de un solo carácter y señala a init para realizar la acción apropiada. Los siguientes argumetos sirven como directivas para telinit:
telinit ptambién puede decir a init cuanto esperará entre los envíos a los procesos de las señales SIGTERM y SIGKILL. El valor por defecto es is 3 segundos, pero se puede cambiar con la opción -t.
telinit -e tells init to change the environment for processes it spawns. The argument of -e is either of the form VAR=VAL which sets variable VAR to value VAL, or of the form VAR (without an equality sign) which unsets variable VAR.
telinit solo se puede llamar por usuarios con los privilegios apropiados.
The init binary checks if it is init or telinit by looking at its process id; the real init's process id is always 1. From this it follows that instead of calling telinit one can also just use init instead as a shortcut.
Init fija las siguientes variables de entorno para todos sus hijos:
It is possible to pass a number of flags to init from the boot monitor (e.g., LILO or GRUB). init accepts the following flags:
init listens on a fifo in /dev, /run/initctl, for messages. Telinit uses this to communicate with init. The interface is not very well documented or finished. Those interested should study the initreq.h file in the src/ subdirectory of the init source code tar archive.
Init reacciona ante diversas señales:
init is compatible with the System V init. It works closely together with the scripts in the directories /etc/init.d and /etc/rc{runlevel}.d. If your system uses this convention, there should be a README file in the directory /etc/init.d explaining how these scripts work.
/etc/inittab /etc/initscript /dev/console /var/run/utmp /var/log/wtmp /run/initctl
init supone que procesos y descendientes de procesos permanecen en el mismo grupo de procesos que se creó originalmente para ellos. Si los procesos cambian su grupo init no puede matarlos y v.d. puede acabar con dos procesos leyendo de una línea del terminal.
On a Debian system, entering runlevel 1 causes all processes to be killed except for kernel threads and the script that does the killing and other processes in its session. As a consequence of this, it isn't safe to return from runlevel 1 to a multi-user runlevel: daemons that were started in runlevel S and are needed for normal operation are no longer running. The system should be rebooted.
Si init encuantra que está levantando continuamente una entrada, más de 10 veces en dos minutos, supondrá que es un error en la cedena del mandato, genera un mensaje de error en la consola del sistema y rehusa levantar esta entrada hasta que hayan pasado 5 minutos o recibas una señal. Esto no previene de que se coma los recursos del sistema cuando alguien comete un error tipográfico en el fichero /etc/inittab o en el programa para el que se elimina la entrada.
Miquel van Smoorenburg , página de manual inicial por Michael Haardt.
getty(1), login(1), sh(1), runlevel(8), shutdown(8), kill(1), initctl(5), inittab(5), initscript(5), utmp(5)
29 de julio de 2004 | sysvinit |