Contents
Introduction
OpenRC is a dependency based init system originated from Gentoo base system, while being kernel and distro neutral by using only C(ISO/IEC 9899:1999, aka. C99) and POSIX shell script. It supports automatic service ordering, parallel service startup, user services, and more.
This page details openrc usage as alternative init system in Debian.
People Involved
heroxbd (Benda Xu), Gentoo Developer and Debian User, striking force.
rleigh (Roger Leigh), Debian Developer maintaining sysvinit and sysv-rc, mentor.
zigo (Thomas Goirand), Debian Developer.
lu_zero (Luca Barbato), Gentoo Developer, mentor.
patrick aka. bonsaikitten (Patrick Lauer), Gentoo Developer, orginal proposal.
xaionaro (Dmitry Yu Okunev), Debian and Gentoo User, lsb2rcconf and loop solver.
LSB header
By default, sysv-rc uses LSB header to represent dependencies in init scripts, which is parsed by insserv The detailed information on this topic can be found at LSBInitScripts.
OpenRC maintains a dependence tree dynamically, the tool used to read LSB header from scripts to feed into OpenRC is lsb2rcconf. lsb2rcconf also handles naming convention differences across sysv-rc and openrc, documented in the next section.
Virtual Facility Names
In sysv-rc, so called virtual facility names, defined by LSB beginning with "$" sign, are defined in /etc/insserv.conf. While in openrc, no special virtual services are defined, but the feature is realized by "provide" annoucement in dependency block. Refer to source code of lsb2rcconf or lsb.pl for details.
Try It Out
This section gives a tutorial for trying OpenRC out on debian.
WARNING
the instructions are intuitive rather than comprehensive. Trying OpenRC by blindly following the steps might results in an unbootable system. Make sure you know how to recover your system before trying this.
Install OpenRC
(This requires a debian machine running sysvinit.)
apt-get install openrc
This will replace sysv-rc with OpenRC. After doing that, you must reboot your computer. Since sysv-rc is stateless, and OpenRC isn't, there's no way for OpenRC to know which of your daemons are running. So it is advised to shut them down manually one by one, then do the following to do a clean shutdown (umounting your partitions before the shutdown):
for file in /etc/rc0.d/K*; do s=`basename $(readlink "$file")` ; /etc/init.d/$s stop; done
To install openRC on a machine running systemd:
WARNING Make sure to have a backup before attempting this! Run at your own risk!
apt install --allow-remove-essential openrc elogind systemd-
This will install openrc and remove systemd. Note that GNOME is known to not work with the former, and you might need to reinstall some parts of your DE.
Init
The process with id 1 is usually the one starting all services, this is the init. With openrc on debian this defaults to sysvinit. While this also works fine, you might want to switch that to openrc's own init, openrc-init.
Assuming you are using grub, first append /etc/default/grub:
... GRUB_CMDLINE_LINUX_DEFAULT="init=/sbin/openrc-init rw" ...
If you have previous values stored just add them at then end of this line (like quiet). The rw is apparently needed because of bug #960234. Then regenerate your config: sudo grub-mkconfig -o /boot/grub/grub.cfg
Afterwards you have explicitly start tty1 to tty6 as openrc services by default:
As root:
cd /etc/init.d/ for n in `seq 1 6`; do ln -s agetty agetty.tty$n; rc-update add agetty.tty$n default; done
Then reboot. Verify you are using indeed openrc-init:
ps -ef | grep openrc-init should yield something like
root 1 0 0 20:41 ? 00:00:00 /sbin/openrc-init splash
Important:
shutdown, reboot and halt will not work anymore.
New syntax:
shutdown |
openrc-shutdown -p [time] |
reboot |
openrc-shutdown -r [time] |
halt |
openrc-shutdown -H [time] |
For more information read the openrc-shutdown man page. sysvinit-core can't be removed or you'll end up with systemD again.
A new openrc-init package is available that provides /sbin/init, /sbin/halt etc. which will allow native init in the future.
User services
Since openrc 0.62, user services, similar to systemd, are supported.
First, openrc-dbus-user-session needs to be installed. The XDG_RUNTIME_DIR variable must be set before running user services, as it's used to store state for openrc itself and the services it runs. Usually, elogind or turnstile take care of that. Then, services can be loaded from /etc/user/init.d or ${XDG_CONFIG_HOME}/rc/init.d To enable a user service run:
rc-update --user add SERVICE default
User services will only run for a single-user session wrapped with dbus.
Network
OpenRC does not ship with network scripts (netifrc) anymore. Which can be used as an alternative to Debian's default ifupdown scripts.
the Debian Way
In Debian, network is managed by /etc/init.d/{networking, ifupdown, ifupdown-clean}. After installing OpenRC, it should just work normally as expected, though it doesn't have the flexibility of the Gentoo handling. For ease of use NetworkManager can be installed. This requires the orphan-sysvinit-scripts package to be co-installed since it contains the init script for NetworkManager. Don't forget to let the interfaces be managed by NetworkManager. The restart the service:
sudo rc-service network-manager restart
the Gentoo Way
Network scripts have been removed from openrc and can be found in the netifrc package. netifrc is a less painful tool for configuring your network than the ifupdown scripts, but needs to be tweaked for Debian.
You can refer to the Gentoo Handbook to set up the network.
For further information using OpenRC, refer to its wiki page on Gentoo.
