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.
This page records the on-going progress of packaging OpenRC for debian as an alternative to sysv-rc.
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
Compile Out OpenRC
You can try to build the Debian package:
apt-get install git-buildpackage build-essential debhelper git clone git://anonscm.debian.org/collab-maint/openrc.git cd openrc ./debian/rules make-orig-file git-buildpackage
Then you can try out what has been built in ../build-area. Note that this package already incorporate the lsb2rcconf patch from heroxbd, doesn't package /sbin/start-stop-daemon (and its associated man page) and /etc/init.d scripts from OpenRC. Though the package can be installed, the result isn't a fully working system (eg: scripts in /etc/init.d aren't started at boot time, which is still to be fixed).
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.
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.