Debian: Switching Init System Easily (OpenRC, Sysvinit, Runit)

June 2023 update: a new, more relevant post on how to switch to sysvinit in Debian Bookworm is available here: https://ianlecorbeau.github.io/blog/debian-bookworm-sysvinit.html

Obligatory disclaimer: this is not an anti-systemd post, and it won’t be about the pros and cons of each init system because chances are, if you were looking for a post like this, your opinion is already made. This is strictly about how to install, and use, an alternative init system on Debian, which you’ll find to be pretty easy and straightforward.

Last year I made a post about how to switch to OpenRC on Debian Bullseye (before it became Stable, though that doesn’t matter much). The process highlighted worked rather well, but there were still a few quirks that could come out of it, and I found myself having to add more info as time went on. I decided to redo the post, add all new information and also show the process to easily switch to Sysvinit and Runit.

Although you can do this on an already fully configured system, I honestly wouldn’t recommend it, just to be on the safe side. I would also advise trying the process in a Virtual Machine first. The instructions given here were performed on a fresh Debian netinstall, with nothing selected at tasksel (not even the “standard system utilities”). The init system was swapped before installing any other packages.

# Why not use Devuan instead?

I’ll get this out of the way before continuing. The answer is pretty simple: this is an experiment, a way to have fun while tinkering. Devuan already comes without systemd so there’s no experimenting to be done with it in that regard. Obviously, if you’re looking at a guaranteed, 100% hassle-free Debian-without-systemd experience, then Devuan is most definitely a good choice.

# OpenRC and Sysvinit

The process to switch to OpenRC and Sysvinit are put together because they’re pretty much the same, with only one package that differ. On your fresh netinstall, login, run apt update for good measure, then

For OpenRC:

$ sudo apt install openrc sysvinit-core

For Sysvinit:

$ sudo apt install sysv-rc sysvinit-core

Afterwards, the process is the same regardless of the init system you chose:

$ sudo reboot
$ sudo apt install elogind libpam-elogind orphan-sysvinit-scripts systemctl procps
$ sudo reboot
profit

Some people don’t even want elogind, but the reality is that it is required in order to run a rootless Xorg. Running X as root is a terrible idea so you most definitely have to install it.

The systemctl package provides the command of the same name without the systemd dependency (and is needed by some packages) while procps* provides some useful commands.

*procps might already be installed with a netinstall, but if you install Debian with debootstrap (minbase variant), it does need to be installed manually.

# Runit

Switching to Runit requires a few more steps. Take note that this is the one I have tested the least, which is ironic considering it’s the first one I ever tried (during the Buster days).

$ sudo apt install runit-systemd
(this is a transitional package meant to make the switch easier, I'm not sure this step is still required, but I did it anyway to avoid trouble)
$ sudo reboot
$ sudo apt install runit runit-run
(You will be told that what you're about to do can cause problems, and in order to continue, type 'Yes, do as I say!' (without the quotes)).
$ sudo reboot
$ sudo apt install elogind libpam-elogind orphan-sysvinit-scripts systemctl procps
$ sudo reboot

You can now uninstall runit-systemd.

$ sudo apt remove runit-systemd

# Apt pinning and mark holding

You’ll have a much better experience (and might not even encounter any problem, but don’t quote me on that) if you use apt pinning to prevent systemd from getting reinstalled. As root, create the /etc/apt/preferences.d/systemd file, and fill it with:

Package: systemd
Pin: release *
Pin-Priority: -1

Package: *systemd*
Pin: release *
Pin-Priority: -1

Package: systemd:i386
Pin: release *
Pin-Priority: -1

You might also want to use apt-mark to hold libsystemd0, though I haven’t done that step myself:

$ sudo apt-mark hold libsystemd0

# Notes

  • When the switch is done and you have rebooted, you can now start installing your packages, carefully examining the output of apt install to make sure it doesn’t try to reinstall systemd.

  • Using apt pinning as shown above, I have yet to find a situation where something refused to install without bringing systemd back, but experiences may vary.

  • Using an alternative init system on Debian isn’t really hard, but it can be hit or miss. While the devs and package maintainers are doing a rather good job at allowing the alternatives (for example, packages depending on some init component will have both systemd and sysvinit as dependencies, making sure if one is installed, the other will stay away), but there are still some packages where it’s not the case.

  • If you find yourself in a situation where a package you need wants to bring systemd back and nuke sysvinit-core, you can either use aptitude instead of apt (which will offer solutions to the problem) or install sysvinit-core alongside the other package (eg: # apt install firefox-esr sysvinit-core).

  • UFW and Sysvinit: with OpenRC, UFW works perfectly fine, however with sysvinit there is an error during the init process (related to some misconfiguration). It seems to work fine regardless, but with firewalls, I don’t take any chances. My advice is to use nftables directly instead. I’ll do a post on nftables in the near future, but Debian provides a nice default config for workstations, which is sensible unless you’re as paranoid as I am.

  • As mentioned in the beginning, I won’t go in depth into the pros and cons of each init system, but I will say that Sysvinit feels a bit smoother on Debian. This is normal considering it is said to be the most well supported alternative to systemd. I had no issue with OpenRC and Runit, though.

# Is it worth it?

Whether switching init is worth it or not is a question only you can answer. Same can be said about whether you should use Debian without systemd, or a Debian derivative that comes with an alternative by default.

I myself find that it’s worth it on my old laptop (which is dual booted with OpenBSD, always important to point out!). It’s first for pragmatic reasons: this is an older laptop, that still works perfectly fine, but benefits greatly from very minimal resource usage (so that the vast majority of it’s 4gb of RAM can be used for tasks such as running a web browser, among other things). My goal being to try to have a Debian that runs with as little ram as OpenBSD does, which is about 90-96mb at idle. For reference, sysvinit is the one that helps the most as far as init systems go (which is obviously just one piece of the puzzle), though OpenRC is pretty damn close as well, whereas I didn’t test Runit on my laptop (yet), so I can’t say if it’s even smaller.

There’s also the fact that I’m a tinkerer, so I have no problem with encountering errors while trying to see just how far I can go with an operating system, and will gladly accept the occasional issues that might come with running something in a way that deviates from it’s original intent.

For the sake of transparency, I do have some philosophical objections regarding systemd (and all its components), but it has never been a deal breaker. If I were to only use software built on a philosophy I 100% agree with, I wouldn’t be using much, and I’d be sticking to OpenBSD since it’s the one that gets as close as possible to my own ideals. But I love Linux just as much, so there you go.

If none of this describes you, and you’re just looking to experiment and have fun, then this is obviously still worth doing, even if only to learn a tad bit more about init systems (though for more in depth learning, going with LFS would probably give a more thorough experience).

# Video

If you want to see the process in action.