RUNLEVEL.CONF5April 2003Debian ProjectDebian GNU/Linux
NAME

runlevel.conf - The file-rc runlevel configuration file


DESCRIPTION

runlevel.conf is the configuration file for the package file-rc an alternative init(8) boot concept. While the SysV init scheme implements runlevels through symlinks in /etc/rc ? .d/* , file-rc uses only one file runlevel.conf to replace all these symlinks.

This file consists of 4 columns separated by TABs or spaces with the following contents:
-
The first column is the sort criteria for starting and stopping the scripts.
-
The second column consists of a comma-separated list of runlevels in which the script should be switched `off' or a single if the script should never be stopped (within that sort-number).
-
The third column consists of a comma-separated list of runlevels in which the script should be switched `on' or a single if the script should never be started (with that sort-number).
-
The last column specifies the full name of the script.

Lines beginning with and empty lines are ignored.
Overview All scripts executed by the init system are located in /etc/init.d . If a scripts has the ".sh" suffix it is a bourne shell script and MAY be handled in an optimized manner. The behaviour of executing script in an optimized way will not differ in any way from it being forked and executed in the regular way. The following runlevels are defined:
N
System bootup (NONE).
S
Single user mode (not to be switched to directly)
0
halt
1
single user mode
2 .. 5
multi user mode
6
reboot
Boot When the systems boots, the lines with ' S ' in the third column are executed. It in turn executes all these scripts in alphabetical (and thus numerical) order. The first argument passed to the executed scripts is start . The runlevel at this point is ' N ' (none). Only things that need to be run once to get the system in a consistent state are to be run. The ' S ' state is NOT meant to replace rc.local . One should not start daemons in this runlevel unless absolutely necessary. Eg, NFS might need the portmapper, so it is OK to start it early in the bootprocess. But this is not the time to start the squid proxy server.
"Going multiuser" After the ' S ' scripts have been executed, init switches to the default runlevel as specified in /etc/inittab , usually ' 2 '. init(8) then executes the /etc/init.d/rc script which takes care of starting the services with ' 2 ' in the third column. Because the previous runlevel is ' N ' (none) the scripts with ' 2 ' in the second column will NOT be executed - there is nothing to stop yet, the system is busy coming up. If for example there is a service that wants to run in runlevel 4 and ONLY in that level, it will place ' 2,3,5 ' in the second column to stop the service when switching out of runlevel 4. We do not need to run that script at this point. The scripts will be executed in alphabetical order, with the first argument set to ' start '.
"Switching runlevels" When one switches from (for example) runlevel 2 to runlevel 3, /etc/init.d/rc will first execute in alphabetical order all scripts with ' 3 ' in the second column with ' stop ' as first argument and then all scripts with ' 3 ' in the third column with ' start ' as first argument. As an optimization, a check is made for each "service" to see if it was already running in the previous runlevel. If it was, and there is no entry present in the second column for the new runlevel, there is no need to start it a second time so that will not be done. On the other hand, if there was an entry in the second column, it is assumed the service was stopped on purpose first and so needs to be restarted. We MIGHT make the same optimization for stop scripts as well - if no entry in the third column was present in the previous runlevel, we can assume that service was not running and we don't need to stop it either. In that case we can remove the "coming from level N" special case mentioned above. But right now that has not been implemented.
"Single user mode" Switching to single user mode is done by switching to runlevel 1. That will cause all services to be stopped (assuming they all have ' 1 ' in the second column). The runlevel 1 scripts will then switch to runlevel ' S ' which has no scripts - all it does is spawn a shell directly on /dev/console for maintenance.
"Halt/reboot" Going to runlevel 0 or 6 will cause the system to be halted or rebooted, respectively. For example, if we go to runlevel 6 (reboot) first all scripts with ' 6 ' in the second column will be executed alphabetically with ' stop ' as the first argument. Then the scripts with ' 6 ' in the third column will be executed alphabetically with ' stop ' as the first argument as well. The reason is that there is nothing to start anymore at this point - all scripts that are run are meant to bring the system down.


EXAMPLES


#<sort> <off> <on> <script>
05 - 0 /etc/init.d/halt
05 - 1 /etc/init.d/single
05 - 6 /etc/init.d/reboot
10 0,1,6 2,3,4,5 /etc/init.d/sysklogd
12 0,1,6 2,3,4,5 /etc/init.d/kerneld
[...]
89 0,1,6 2,3,4,5 /etc/init.d/cron
99 - 2,3,4,5 /etc/init.d/rmnologin
99 0,1,6 2,3,4,5 /etc/init.d/xdm

FILES

/etc/runlevel.conf


AUTHOR

file-rc was originally written by Winfried Tr?mper <[email protected]> and adapted to the Debian system by Tom Lees <[email protected]>, Martin Schulze <[email protected]> and Roland Rosenfeld <[email protected]>.

This man page was written by Roland Rosenfeld <[email protected]>.