23-oct-2017: Dokuwiki and its plugins were upgraded to the latest release.

Welcome to the Slackware Documentation Project

OpenRC

OpenRC is a dependency based init system that works with the system provided init program, normally /sbin/init (which is svsvinit in Slackware). It is not a replacement for /sbin/init.

Features

OpenRC provides a number of features touted as innovative by recent init systems like systemd or upstart, such as hardware initiated initscript run or cgroups support, without requiring large layout changes to accommodate radically different designs and dependencies.

Installation

Pre installation

The /etc/init.d directory (a symlink to /etc/rc.d/init.d) will need to be moved:

# mv /etc/init.d /etc/init.d.bak

Installing

Two Slackbuilds are available, openrc, which contains the OpenRC init system, and openrc-services, which contains various services for use with OpenRC.

Post installation

After installing, /etc/inittab will need to be replaced. The old one can be backed up:

# cp /etc/inittab /etc/inittab.sysvinit
# mv /etc/inittab.new /etc/inittab

The main configuration file for OpenRC is /etc/rc.conf, and contains various options.

A common option that could be changed is to enable boot logging by setting rc_logger=“YES”, this way any errors encountered via booting could be logged and examined later (default log location is /var/log/rc.log).

On reboot

After installing openrc and openrc-services, on rebooting one is booted to a command line with only the bare minimum of services enabled.

It may show a warning about deprecated support for /etc/mtab as a file, and how to correct it:

# cp /etc/mtab /etc/mtab.bak
# ln -snf /proc/self/mounts /etc/mtab

It may also complain about missing /etc/sysctl.conf file which can be created as:

# touch /etc/sysctl.conf

Enabling some services

Services can be enabled as:

# rc-service add <service> <runlevel>

They can be disabled as:

# rc-service del <service> <runlevel>

Some common services that could be enabled:

# rc-update add dbus default
# rc-update add sysklogd default
# rc-update add dcron default
# rc-update add alsasound default  # for desktop
# rc-update add consolekit default  # for desktop
# rc-update add sshd default  # for server

Enabled services in current runlevel can be queried with:

$ rc-status

Enabled services across all runlevels can be queried with:

$ rc-update

Some services that are enabled by default for the sysinit runlevel include udev and udev-postmount.

Users who use dmcrypt, lvm, or mdraid could add the following services respectively to the boot runlevel:

# rc-update add dmcrypt boot        # dmcrypt
# rc-update add device-mapper boot  # lvm
# rc-update add lvm boot            # lvm
# rc-update add mdraid boot         # mdraid

Network

If using ethernet via DHCP, the dhcpcd service could be enabled:

# rc-update add dhcpcd default

If using wifi with laptops the NetworkManager or wicd service could be enabled. The combination of dhcpcd and wpa_supplicant (along with a frontend like wpa_gui or wpa_cli) could also be used as a lightweight alternative.

A static network can be configured by editing /etc/conf.d/network.

Display manager

To boot to a graphical display manager, /etc/conf.d/xdm can be edited to specify the display manager, and the xdm service could be enabled:

# rc-update add xdm default

If using a laptop, the acpid service could be enabled as well.

Migrating existing enabled services

To check existing enabled services, following code could be used:

for file in /etc/rc.d/*; do
  if [ -x "${file}" ]; then
    echo "enabled ${file}"
  fi
done

For these services corresponding OpenRC services could be enabled, for example:

# rc-update add acpid default
# rc-update add cgmanager default
# rc-update add gpm default
...

All services present can be queried via:

$ rc-update -v

Configuration

OpenRC services are present in the /etc/init.d folder, and corresponding configuration files are present in /etc/conf.d

Some common configuration files include:

/etc/conf.d/modules    # modules to be loaded at boot
/etc/conf.d/hostname   # hostname of the system
/etc/conf.d/keymaps    # console keymap

Services

Services can be started/stopped/restarted as:

# rc-service <service> <action>

For example,

# rc-service sshd start

Troubleshooting

At the moment only a subset of the included services have been tested, so some of them may not run correctly.

If some service does not work try the system provided one in /etc/rc.d if available.

mysqld

Try adding the following lines to /etc/my.cnf

[mysqld]
user = mysql
basedir = /usr
datadir = /var/lib/mysql
pid-file = /run/mysql/mysql.pid
socket = /var/run/mysql/mysql.sock

See Also

Sources

* Originally written by Aaditya


In Other Languages
Translations of this page?:
QR Code
QR Code howtos:general_admin:openrc (generated for current page)