Debian/systemd

From Segfault
Jump to: navigation, search

To get rid of systemd entirely, the following procedure[1] can be used.

SysV init

To replace with SysV init:

sudo apt-get install sysvinit-core sysvinit-utils
sudo cp /usr/share/sysvinit/inittab /etc/inittab

OpenRC

For OpenRC:

TBD

runit

For runit

mkdir /etc/runit /etc/service
ln -s /etc/service /service                                     # Standard runit is expecting this.
cp -p /usr/share/doc/runit/debian/* /etc/runit/
ln -s /etc/sv/getty-5 /etc/service/
chmod 0755 /etc/runit/*

Create an SSH service[2] too:

mkdir -p /etc/sv/sshd/log/

We'll need a log service[3] too:

$ cat /etc/sv/sshd/log/run 
#!/bin/sh
exec chpst -ulog svlogd -tt ./main

Now the actual ssh service:

$ cat /etc/sv/sshd/run 
#!/bin/sh
exec 2>&1
mkdir /var/run/sshd
exec /usr/sbin/sshd -D -e

Note: without /var/run/sshd, the ssh server would not start:

$ sudo /usr/sbin/sshd
Missing privilege separation directory: /var/run/sshd

Activate the service:

ln -s /etc/sv/sshd /etc/service/

TODO: Reboot is not working yet:

$ reboot
Failed to talk to init daemon.

TODO: Although the ssh service gets started, the login screen console gets stuck:[4]

[...]
[ ok ] Starting rpcbind daemon....
[ ok ] Starting NFS common utilities: statd idmapd.
[ ok ] Cleaning up temporary files....
[info] Setting console screen modes.
[ ok ] Setting up console font and keymap...done.
[ ok ] Setting up X socket directories... /tmp/.X11-unix /tmp/.ICE-unix.
Usage: /etc/init.d/rmnologin start|stop
- runit: leave stage: /etc/runit/1
- runit: enter stage: /etc/runit/2

Cleanup

Reboot, and if all goes well - remove systemd leftovers:

apt-get remove --purge --auto-remove systemd

Prevent systemd to get installed in the future:

echo -e 'Package: systemd\nPin: origin ""\nPin-Priority: -1' > /etc/apt/preferences.d/systemd
echo -e '\n\nPackage: *systemd*\nPin: origin ""\nPin-Priority: -1' >> /etc/apt/preferences.d/systemd

References

  1. How to remove systemd from a Debian jessie/sid installation
  2. A sshd run script
  3. How do I create a new service directory with an appendant log service
  4. LFS with Runit (without SysV)