Show Menu

How OpenRC Works

Init needs a config­uration file that specifies what actions need to be taken. This config­uration file is /etc/i­nittab
init's first action is to mount all file systems. This is defined in the following line from /etc/i­nittab.
si::sy­sin­it:­/sb­in/­openrc sysinit
init's second action is to execute all scripts that had symbolic links in /etc/r­unl­eve­ls/­boot/. This is defined in the following line from /etc/i­nittab.
rc::bo­otw­ait­:/s­bin­/openrc boot
init checks its config­uration file to see what runlevel it should run. To decide this, it reads the following line from /etc/i­nittab.
In this casethe runlevel id is 3. Using this inform­ation, init checks what it must run to start runlevel 3.
l3:3:w­ait­:/s­bin­/openrc default
. The line that defines level 3, again, uses the openrc script to start the services (now with argument default)
init decides what virtual consoles it should activate and what commands need to be run at each console.
c1:123­45:­res­paw­n:/­sbi­n/a­getty 38400 tty1 linux
c2:123­45:­res­paw­n:/­sbi­n/a­getty 38400 tty2 linux
c3:123­45:­res­paw­n:/­sbi­n/a­getty 38400 tty3 linux
c4:123­45:­res­paw­n:/­sbi­n/a­getty 38400 tty4 linux
c5:123­45:­res­paw­n:/­sbi­n/a­getty 38400 tty5 linux
c6:123­45:­res­paw­n:/­sbi­n/a­getty 38400 tty6 linux






Working with initsc­ripts
The scripts that the openrc process starts are called init scripts. Each script in /etc/i­nit.d/ can be executed with the arguments start, stop, restart, zap, status, ineed, iuse, iwant, needsme, usesme, or wantsme.
Start a service
/etc/i­nit.d/­postfix start
Stop a service, but not the services that depend on it
/etc/i­nit.d/­postfix --nodeps stop
See what status a service has
/etc/i­nit.d/­postfix status
Ask what depend­encies the service has
/etc/i­nit.d/­postfix ineed
Ask what services require the service
/etc/i­nit.d/­postfix needsme

Config­uring services

Every init script that can be configured has a file in /etc/c­onf.d/. For instance, the apache2 initscript (called /etc/i­nit.d/­apa­che2) has a config­uration file called /etc/c­onf.d/­apa­che2, which can contain the options to give to the Apache 2 server when it is started. Such a config­uration file contains only variables.

Replacing default runlevel

Replace runlevel
Add a new entry in the bootloader config­uration for the desired runlevel. In that entry, add
as a boot parameter.

Working with runlevel

Change to nonetwork runlevel
rc nonetwork
Change to default runlevel
rc default
Change to shutdown runlevel
rc shutdown
Change to reboot runlevel
rc reboot
Show status info about runlevels
rc-status [runlevel]
Locate and run an OpenRC service
rc-service service cmd [...]
Adding services
rc-update add postfix default
Removing services
rc-update del postfix default
Showing services
rc-update show


No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          More Cheat Sheets by misterrabinhalder

          RPM Cheat Sheet