Translation(s): English - Français - Italiano - Русский
BootProcess > init
Init is the first program to run after your system is booted. It runs as PID 1, and continues to run until your system halts. Init's job is to start all other programs that run on your system. All other processes are descended from init.
Overview
The system initialization process is handled by the init system.
The default init system in Debian has been systemd since DebianJessie. Before then it was sysvinit. Other init systems are provided, but are less actively supported.
History of init systems in Debian
In squeeze and earlier releases, sysvinit was the only supported init system.
In wheezy, the default init daemon was still sysvinit, but a "technology preview" of systemd was available.
In jessie and stretch, the default init system was systemd, but switching to sysvinit was supported.
- Since jessie, only systemd is fully supported. While sysvinit is mostly supported, Debian packages are not required to support it
In buster, OpenRC was also included: it provides an alternative to the service handling and sysvinit runlevel mechanisms of sysvinit while maintaining compabibility.
Support for init systems other than systemd was significantly improved in Bullseye. runit was also provided, but so far it has not received the same level of testing and support as the others. Support for running runit as PID 1 is still considered experimental.
Since bullseye, some sysvinit start scripts that are no longer shipped by their original packages is provided in the orphan-sysvinit-scripts package.
Determining the init system
The main way to detect whether you are running systemd is to look for the presence of the /run/systemd/system directory.
For other init systems, you can examine /sbin/init which is a symlink to the main daemon used. Under systemd you will see:
$ ls -ld /sbin/init lrwxrwxrwx 1 root root 20 Mar 6 14:56 /sbin/init -> /lib/systemd/systemd
under runit:
$ ls -ld /sbin/init lrwxrwxrwx 1 root root 21 Feb 9 2023 /sbin/init -> /lib/runit/runit-init
You can also use readlink /proc/1/comm.
These methods only detect which init system is running, not what is installed or even what the default is: the user may be about to reboot into a new default they just installed.
Once you have determined the executable running as init, you can use dpkg -S to determine the package providing it (e.g.:
$ dpkg -S /lib/systemd/systemd systemd: /lib/systemd/systemd
For Debian systems other than GNU/Linux (e.g. Debian GNU/Hurd, Debian GNU/kFreeBSD), check the installed and/or running init. Something similar to the above may apply, however the kernel's location for init may be different.
Switching the init system
Changing the init system - at installation time
The easiest time to choose an init other than systemd is at installation time (since systemd's packages will refuse to be removed if systemd is running).
The best time to perform the switch is after the "Selecting and installing software" stage. Note that the default GNOME desktop is harder to get to work without systemd in Bullseye (because its usual display manager gdm3 declares a dependency on libpam-systemd - see 991880), so if you want a desktop environment it will be easier to deselect GNOME and select another (Xfce, KDE Plasma, LXDE, Cinnamon, MATE, and LXQt have all been tested without systemd).
Debian Bookworm and higher can install gdm3 without issues, so if you want to run GNOME just install gnome-core after switching the init. Note that it is affected by 1033897 currently.
Once that stage is complete, launch a shell, and chroot into the installed system by typing chroot /target. You then need to tell apt to install your preferred init system and, unless you are not using a desktop environment at all, libpam-elogind to provide the necessary elogind session management facilities (which are provided by libpam-systemd and systemd in a default installation). Often (including in trixie as of 2024-09-13) you will also need to install dbus-x11. And, the default install pulls in systemd-timesyncd which you will want to replace (probably with ntp).
For example, for System-V-like init, type apt install sysvinit-core libpam-elogind dbus-x11 ntp. This will install your new init system and elogind, and remove systemd, libpam-systemd and other components that can only work with systemd. If apt is proposing to remove a very large number of packages, then you probably selected a desktop environment that depends on systemd; it will be best to stop at this point and go back to the task selector to choose another instead. Or it might mean that some other dependency has crept in that apt mishandles (for example, if you omit dbus-x11 apt will often want to deinstall the desktop environment).
In Debian Trixie, trying to install sysvinit with the command above will fail with the error:
Removing essential system-critical packages is not permitted. This might break the system.
To go around this, type apt --purge --allow-remove-essential install sysvinit-core libpam-elogind dbus-x11 systemd-sysv- (Add a minus after systemd-sysv)
To sync the time on Trixie you can either use ntpsec or chrony.
Once that is done, exit the chroot by typing exit, then switch back to the installer (if you were using a different virtual console by switching back; if you had selected the "Execute a shell" menu option, then by typing exit once more), and resume the installation by moving to the boot loader installation stage, which is typically installing GRUB. You can now complete the installation process as normal.
After the installation is complete, you will probably want to create overriding apt configuration, something like this:
cat <<'END' >/etc/apt/preferences.d/local-pin-init Package: systemd-sysv Pin: release o=Debian Pin-Priority: -1 Package: systemd Pin: origin "" Pin-Priority: -1 Package: cgmanager Pin: origin "" Pin-Priority: -1 END
Otherwise apt sometimes tries to change the init system when installing other packages, even when they're installable just fine on non-systemd systems. (Probably, related to 940965.)
Other ways to prevent systemd from being installed when installing other packages is to install packages with the command --no-install-recommends or to put systemd packages on hold with apt using
apt-mark hold systemd systemd-sysv
Changing the init system - on a running system
In Bullseye, a number of alternative init systems are supported (such as System-V-style init and OpenRC). Generally, to switch between init systems, you install the new init system and reboot. The exception is switching away from systemd - systemd's packages will refuse to be removed if systemd is running; so the process is a little more involved.
In outline, you need to install new init system. Reboot and remove systemd. Now keep in mind that removing systemd might also require uninstallation of some packages (i.e. php-fpm) but reinstalling them should work.
Now install desired init system (apt-get install sysv-rc sysvinit-core ifupdown) and Once this has completed, reboot your system.
If you're using Trixie installing sysv will display
Removing essential system-critical packages is not permitted. This might break the system.
- as systemd-sysv is a protected package. Use
apt-get --allow-remove-essential --no-install-recommends --purge install sysv-rc sysvinit-core systemd-sysv-`
to remove systemd and install sysv. Afterwards proceed as described above.
Network config before reboot
AddInterfaces(5) man page (from ifupdown) file before reboot, otherwise network configuration will not be available. Also remove the symlink for /etc/resolv.conf and add nameservers. Not doing so wouldn't probably prevent loss of incoming connections but it's recommended for proper operation.
Sysvinit configuration
The inittab configuration tells init what to do. Especially it contains the lines:
Which causes the files /etc/init.d/rcS to run initialization scripts (in /etc/rcS.d/*), then scripts for requested runlevel (in /etc/rcS.[0-9]/*).
Getting help
If you encounter any issues specifically associated with using an alternative init system, there is a Debian init system diversity list that may be able to help.
See also
CategoryBootProcess | CategoryPermalink: mentioned in the Release notes for trixie