Home     Blog     Rss     Contact     Donate

Debian Bookworm with Syvinit (Plus Bonus Init Script and Other Extras)


Almost a week after its release, I finally upgraded my daily driver to Bookworm. This is what I was waiting for in order to switch to sysvinit on my main machine. I'm already using it on all other Debian installs I have (laptop, multiple VMs), and for my daily driver, I just wanted to wait until I had to start over from scratch before switching.

I already made a post[1] about how to switch to other init systems on Debian Bullseye, and figured I should do a new one for Bookworm. This time, however, I will only focus on sysvinit. Why? It's the one I use on Debian, meaning it's the one I can offer actually useful support for, in case someone encounters an issue or has any questions related to it.

Now, by all means, if you still want to use either OpenRC or Runit, go for it (for OpenRC, just swap 'sysv-rc' with 'openrc').

Obligatory Disclaimers


Disclaimer #1: This isn't an anti-systemd post, so don't ask "what's wrong with systemd?". This is not a "systemd bad" post, but a "sysvinit good" one.

Disclaimer #2: Why not just use Devuan[2]? Answer: this is about switching the init system on Debian, plain and simple. It wouldn't be much of a post if I just said "use Devuan". Now, if you want a 100% hassle-free, 'Debian-without-systemd' experience, then most definitely go with Devuan.

Pre-Switching Notes


First, if you're going to do this, the only surefire way of doing it without encountering a problem is by installing Debian with debootstrap[3], using the 'minbase' variant. This works 100% of the time.

I do not recommend switching a system that was already set up with Xorg/Wayland and a desktop environment and all.

You can also do a netinstall, deselect everything at tasksel, and on first boot, do the switch. Do note, however, that this method is rather unpredictable. Sometimes it works, sometimes strange things happen, sometimes it just doesn't work at all.

This is the method I used on my daily driver, and on the first try it failed and the system didn't boot. On the second try, I encountered the same error as on the first try but the system booted for some reason. Hence the unpredictable factor.

Switching


Now the meat and potatoes.

If doing a deboostrap install, right before installing the kernel, simply do a:


# apt install sysvinit-core sysv-rc orphan-sysvinit-scripts elogind libpam-elogind

For a netinstall, the process is still simple, just split in stages:


# apt install sysvinit-core sysv-rc orphan-sysvinit-scripts
# reboot (and cross fingers)
# apt install elogind libpam-elogind
# reboot
# profit

As simple as that.

Some people don't want elogind, but you most definitely should install it. For one, it allows running X rootless with xinit/startx, and two, it'll actually prevent systemd and all from being reinstalled, since it satisfies the logind dependency.

Post Switch


This is not necessary, but highly recommended.

Because rsyslog is not installed by default on Bookworm, you should probably install it for system logging. If you want a proper unix-like system (and make sure to avoid installing a full fledged Mail Transfer Agent like exim4 if not needed) you should also install bsd-mailx and dma.

bsd-mailx will provide the classic mail(1) command, whereas dma (Dragonfly Mail Agent) will provide a minimal MTA which doesn't have a daemon (no services running) and doesn't listen on any port (nor localhost) by default, a big plus for security. They both also work perfectly without any configuration needed. Just set mailname to your hostname and leave everything else blank when prompted while installing dma.


# apt install rsyslog bsd-mailx dma

Bonus Init Script


If you want increased privacy, you can use Ragnarok's rm-machineid[4] init script. Details as to why you might want that are given in the link at the end.

The actual script: https://raw.githubusercontent.com/RagnarokOS/src/master/etc/init.d/rm-machineid


#!/bin/sh
### BEGIN INIT INFO
# Provides:             rm-machineid
# Required-Start:
# Required-Stop:    
# Default-Start:
# Default-stop:         0 6
# Short-Description:    execute the rm-machineid script
# Description:
### END INIT INFO

# /etc/machine-id and /var/lib/dbus/machine-id can be used to fingerprint a system.
# Removing it when powering off or rebooting a machine will cause dbus to regenerate
# it on boot, which at least provides some sort of mitigation.

do_stop() {
    echo "removing machine-id"

    # on non-systemd systems, this file doesn't exist (normally)
    if [ -f /etc/machine-id ]; then
        rm -f /etc/machine-id
    fi

    rm -f /var/lib/dbus/machine-id
}

case "$1" in
    start)  echo "invalid option" ;;
    stop)   do_stop ;;
    *)  do_stop ;;
esac

Either copy this in your favorite text editor, or download the script and put it in the /etc/init.d/ directory.

Afterwards, as root:


# chmod 755 /etc/init.d/rm-machineid
# update-rc.d rm-machineid defaults

...and that is all.

[1] https://lecorbeausvault.wordpress.com/2022/02/07/debian-switching-init-system-easily-openrc-sysvinit-runit/
[2] https://devuan.org
[3] https://manpages.debian.org/bookworm/debootstrap/debootstrap.8.en.html
[4] https://ragnarokos.github.io/docs/machine-id.html