Dependency based boot sequence

Before Debian 8.0, Debian used init to boot-up the system. This page provide information of the details to resolve the dependency issues. Since Debian 8.0, Systemd replaced init and the dependency was relied on its target files. The information described here no longer applies to Debian's default in Jessie.

Debian was converted to order the boot sequence using the LSB fields in the header of each init.d script. This has removed several bugs in the former boot sequence, and now makes it easier to keep the sequence correct.

Advantages

Did you ever need to insert a init.d scripts Y before init.d scripts Z and after init.d script X, where both Z and X is started using boot sequence number 20 (as in 20X and 20Z)? Adding your script as 20Y would not cut it, because you need Z to start before X. To do this, in Debian you currently need to talk to the maintainer of packages with scripts Z and X, asking one of them (or both) to move their script into a different number. Dependency based boot sequencing make it possible for each package maintainer to specify the dependencies of its scripts, and leave the number allocation to the dependency resolver.

Status

This page was created to keep track of the state of this feature, to make it easier to coordinate an effort to implement it in Debian. It was proposed as a release goal for Lenny. It will be the default boot ordering method for Squeeze. During Debconf in 2009, the default in Sid was changed to use dependency based boot sequencing by default.

Plan of migration

This is a proposal for a plan to migrate all of Debian over to dependency based boot sequencing.

Change the debconf default in insserv to enable dependency based boot sequencing when the package is installed, if it is safe to do so. Show the question again on upgrades if the conversion isn’t done yet. Remove/disable the option to disable insserv after it is enabled.

Change sysv-rc to depend on insserv, to pull it in on all (non-file-rc) installations.

Wait 6 months, while rewriting policy text to document the new way update-rc.d is going to work.

Drop support for specifying sequence numbers in update-rc.d.

This will enable dependency based boot sequencing for all in Debian from Squeeze and onwards.

How to solve migration problems

package X removed but not purged

If a script in /etc/init.d/ belongs to a package that is removed but not purged, the field is probably missing or is outdated. Purging the package will solve the issue.

package X left obsolete init.d script behind

The script was probably dropped from its package, but the package maintainer forgot to add code in the postinst to remove the obsolete script during upgrades. Removing the script is probably the correct solution. We have seen one report where dpkg would claim that a script was obsolete one time and not obsolete one upgrade later, so this should probably be checked a bit before the script is removed.

To verify that a package really left behind obsolete conffiles, one can run

dpkg-query -W -f='${Conffiles}\n' packagename | grep obsolete

There are several reasons why these scripts are not removed automatically during upgrades. First of all, reporting these issues exposes bugs that should be fixed in the individual packages. Second, it is hard to know if the script reported was left behind for a strange and particular reason, or just forgotten. And last, there is the one report that a non-obsolete script was reported as obsolete. Still not sure if that was for real or not, but until we know the reason, it seemed risky to just remove scripts in other packages during upgrades. Besides doing so from the sysv-rc postinst would be a policy violation.

insserv: warning: script 'X' missing LSB tags and overrides

The /etc/init.d/X script is lacking the LSB fields. Adding them to the script header or as a override file in /etc/insserv/overrides/X would solve it.

insserv: script X: service Y already provided!

Bug in the package with script X: The facility provided in script /etc/init.d/X uses a non-unique value. Changing it to a unique value (for example the script name without .sh ending), solves the issue.

Common problems with init.d script header LSB fields

Here are some problems I have seen with the LSB fields in init.d scripts during the last three years. I provide it here for those of you wondering if your package’s init.d scripts are correct.

Non-unique Provides field

When two packages have scripts with the same Provides field, it will only be able to install these packages if the init.d script of the other is not present in /etc/init.d/. Packages sharing a common service with other packages could use virtual facilities instead of conflicting provides, or normal dependencies if few packages are involved.

Incorrect runlevel list

If the Default-Start and Default-Stop fields do not list the runlevels where a script should be stopped or started, the wrong set of start and stop symlinks will be created when the script is installed, and the boot and shutdown sequence will most likely be incorrect. Fixing it require both updates to the fields, and code in the postinst script to add or remove symlinks that where missing.

Missing dependency on $syslog when logging to syslog

Without it, services might be started too early during boot and some syslog messages might be lost.

Missing dependency on $remote_fs when needing files in /usr/.

Scripts starting from rcS.d/ will start too early when /usr/ is on NFS, and will probably fail to work because some of its expected files and programs are missing when the script starts.

Depending on incorrect or non-existing provides

The intended relationship with another script does not take effect, making the script run too early or too late during boot and shutdown.

To enable dependency based boot, insserv can be used. At debconf7 and FOSDEM 2008 (video), Petter Reinholdtsen gave a talk about the dependency based boot system. To enable it in older versions of Debian, install insserv and activate it like this: