Article 5 of 15
Core Concept: Runlevel Configuration
Three important pieces of the SysVinit puzzle are:
- A runlevel describes the overall operating state.
- A service is a function the system provides.
- An init script contains instructions for managing the program that provides a service.
But how does SysVinit connect these pieces? How does it know which services should be running in a particular runlevel?
Runlevels Have Their Own Configuration
Each runlevel can have its own configuration describing which services should be started and stopped when the system enters that runlevel.
On BcalcOS, this configuration is found in directories such as:
/etc/rc2.d/
/etc/rc3.d/
/etc/rc4.d/
/etc/rc5.d/
BcalcOS uses runlevel 2 as its normal operating state so /etc/rc2.d/ is the pertinent directory.
If we look inside it, we’ll find entries such as:
S03cron
S03dbus
S04network-manager
S04slim
S05cups
K01speech-dispatcher
These aren’t copies of the init scripts; they are symbolic links to the actual scripts in /etc/init.d/. For example: S03cron → ../init.d/cron.
The system’s package and service-management tools create these links automatically when services are installed or configured. Users rarely create them by hand.
The result is a connection between the runlevel configuration and the init script that manages the service.
What Do the S and K Mean?
The names of these entries follow a simple convention.
An entry beginning with S tells the system to start the associated service when entering that runlevel.
An entry beginning with K tells the system to stop the associated service when entering that runlevel.
For example:
S03cron
means that the cron init script should be run with the start action.
An entry such as:
K01speech-dispatcher
means that the speech-dispatcher init script should be run with the stop action.
The numbers after the S or K determine the order in which these entries are processed.
Why Are They Links?
You might wonder why /etc/rc2.d/ contains links instead of simply containing copies of all the init scripts.
The actual scripts are kept in one central location:
/etc/init.d/
The runlevel directories then contain links to the scripts that should be used for that particular runlevel.
This means the same init script can be used by more than one runlevel without maintaining multiple copies of it.
For example, BcalcOS has:
/etc/rc2.d/S03cron -> ../init.d/cron
The actual script remains:
/etc/init.d/cron
BcalcOS and Runlevels 2 – 5
BcalcOS uses runlevel 2 as its default operating state:
id:2:initdefault:
Its configuration directories for runlevels 2, 3, 4, and 5 are currently identical. That means BcalcOS does not currently use runlevels 3, 4, and 5 as distinct operating configurations.
Putting the Pieces Together
Let’s connect what we’re covered:
Runlevel 2
↓
/etc/rc2.d/
↓
symbolic links to init scripts
↓
/etc/init.d/cron
↓
manages /usr/sbin/cron
↓
provides scheduled task processing
The runlevel configuration tells SysVinit which init scripts belong to that operating state.
The init scripts provide the instructions for managing the programs.
The programs provide the services.
That’s the basic connection between the pieces.
Key Takeaway
A runlevel doesn’t directly contain the services themselves.
Instead, its configuration identifies the init scripts that should be used to manage the programs providing those services.
The entries in the configuration directory (/etc/rc2.d for BcalcOS) tell SysVinit which services to start or stop when entering that runlevel.
Next: The Boot Process