I thought I could write a multi part blog series about init systems (with the obvious goal of convincing some more people we should properly support other init systems as well).

In the first step, I’ll have short look at our current init.

First of all, our init isn’t really /sbin/init from the sysvinit. The real work is done by /bin/sh, so usuall bash or dash. Using the latter can already cut down boot time for you by a few seconds, according to some people.

The init process is indeed used to kickoff the system, but it’s in fact not doing much. Pretty much all it does is described by /etc/inittab. If you havn’t ever had a look at this file, maybe you should now.

During a typical system boot, init is doing three things:

  1. Start /etc/init.d/rcS
  2. Start /etc/init.d/rc 2
  3. Start the gettys (console logins)

other tasks it handles is pretty much waiting for Ctrl+Alt+Del and if someone triggers a shutdown. The actual shutdown work is again done by a shell script

  • /etc/init.d/rc 6

So my claim that our init system actually is /bin/sh isn’t really far off, is it?

Some random notes:

  • Starting and stopping services is not handled by init, but these are just shell scripts invoked by the root user
  • The only services monitored (and restarted) by init are the gettys. You could add other services, but the inittab approach doesn’t scale very well with respect to automatic editing by package install script and such. That is strongly discouraged.
  • Some users/services add their own monitoring because of that. MySQL has a shell wrapper for this, and packages such as monit also take care of checking for crashed services and restarting them.
  • Debian has a script called invoke-rc.d, that should/must be used by package installation scripts instead of calling the init scripts directly.

Maybe tomorrow I’ll write a bit about features of other init systems, and what benefits they offer. Maybe also on why the SELinux strict policy doesn’t really like this way of starting and stopping services because of isolation issues. Or on that there are two types of things happening at init.

[Update: next post in this series.]