Dependency based boot sequence

Reordering the boot sequence for correctness and speed

There are several boot options available in Debian, and the default SysV-derived one can be tuned and corrected. The talk will present the available options, and go into details on some of the pitfalls and advantages of the default boot system. It will present some results based on the Google summer of code project working on the boot system.

Petter Reinholdtsen
pere@hungry.com
Debconf 2007 Edinburgh, 2007-06-17

About the speaker

Summary of this talk

Based on work done by Carlos Villegas during Google Summer of Code 2006, available from http://initscripts-ng.alioth.debian.org/soc2006-bootsystem/.

Debian include several boot system options

SysV init is only the most used boot system in Debian, not the only one.

The SysV boot system

Current sid boot sequence (base install)

/etc/rcS.d:
README                  S30checkfs.sh
S01glibc.sh             S30procps.sh
S02hostname.sh          S35mountall.sh
S02mountkernfs.sh       S36mountall-bootclean.sh
S04mountdevsubfs.sh     S39ifupdown
S05bootlogd             S40networking
S10checkroot.sh         S45mountnfs.sh
S11hwclock.sh           S46mountnfs-bootclean.sh
S12mtab.sh              S55bootmisc.sh
S18ifupdown-clean       S55urandom
S20module-init-tools    S99stop-bootlogd-single
S25libdevmapper1.02.1

/etc/rc2.d:
README                  S89cron
S10sysklogd             S99rc.local
S11klogd                S99rmnologin
S20makedev              S99stop-bootlogd
S20openbsd-inetd

Current sid shutdown sequence (base install)

/etc/rc6.d:
K11cron                 S30urandom
K20makedev              S31umountnfs.sh
K20openbsd-inetd        S35networking
K25hwclock.sh           S36ifupdown
K89klogd                S40umountfs
K90sysklogd             S60umountroot
README                  S90reboot
S20sendsigs

But is it correct?

Problems with the current boot system

How can we verify the boot sequence correctness?

Example header:

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          networking
# Required-Start:    mountkernfs ifupdown $local_fs
# Required-Stop:     ifupdown $local_fs
# X-Start-Before:    nis
# X-Stop-After:      nis
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: Raise network interfaces.
### END INIT INFO

Verifying the current sequence

Using these headers and a script from the insserv package, we can verify the boot order:

# /usr/share/insserv/check-initd-order   -o
LSB header missing in /etc/rcS.d/S11hwclock.sh
LSB header missing in /etc/rcS.d/S25libdevmapper1.02.1
Incorrect order modutils@? > checkfs.sh@30
Incorrect order $all@? > stop-bootlogd-single@99
Incorrect order $time@? > sysklogd@10
Incorrect order $time@? > cron@89
Incorrect order $all@? > rmnologin@99
#  

For the packages without dependency information, override files can be read from /usr/share/insserv/overrides/ and /etc/insserv/overrides/.

Verifying the current sequence II

Current status (base task install), with override files.

# /usr/share/insserv/check-initd-order
Incorrect order $local_fs@? > hwclock.sh@11
Incorrect order $remote_fs@? > hwclock.sh@11
Incorrect order modutils@? > libdevmapper1.02.1@25
Incorrect order modutils@? > checkfs.sh@30
Incorrect order $all@? > stop-bootlogd-single@99
Incorrect order $all@? > rmnologin@99
#

Verifying the current sequence III

Current status (desktop task install)

# /usr/share/insserv/check-initd-order -o
LSB header missing in /etc/rcS.d/S11hwclock.sh
LSB header missing in /etc/rcS.d/S25libdevmapper1.02.1
Incorrect order modutils@? > checkfs.sh@30
Incorrect order $all@? > stop-bootlogd-single@99
Incorrect order $time@? > sysklogd@10
LSB header missing in /etc/rc2.d/S19hplip
LSB header missing in /etc/rc2.d/S20cupsys
LSB header missing in /etc/rc2.d/S20hotkey-setup
LSB header missing in /etc/rc2.d/S89anacron
Incorrect order $time@? > cron@89
Incorrect order $all@? > rmnologin@99
#        

Reordering based on dependency information

Advantages:

How to enable this by default

Status of dependency based sysv boot sequence

To enable: BAD_INSSERV_HACKER=true dpkg-reconfigure insserv

Testrun:

insserv:/var/tmp/chroot-sid-base-reorder# BAD_INSSERV_HACKER=true dpkg-reconfigure i
info: Backing up existing boot scripts in /var/lib/insserv/bootscripts-20070615T1617.tar.gz
info: Reordering boot system, log to /var/lib/insserv/run-20070615T1617.log
info: Recording new boot sequence in /var/lib/insserv/bootscripts-20070615T1617-after.list
info: Use '/usr/sbin/update-bootsystem-insserv restore' to restore the old boot sequence.
success: Boot system successfully converted
Adding `diversion of /usr/sbin/update-rc.d to /usr/sbin/update-rc.d.distrib by insserv'
#

Similar boot graph

Reordered sid boot sequence (base install)

/etc/rcS.d:
README                  S05mtab.sh
S01glibc.sh             S06mountall.sh
S01libdevmapper1.02.1   S07ifupdown
S02hostname.sh          S07mountall-bootclean.sh
S02mountkernfs.sh       S07urandom
S03mountdevsubfs.sh     S08networking
S03procps.sh            S09mountnfs.sh
S04bootlogd             S10mountnfs-bootclean.sh
S04checkroot.sh         S11bootmisc.sh
S05checkfs.sh           S11hwclock.sh
S05ifupdown-clean       S11stop-bootlogd-single
S05module-init-tools
/etc/rc2.d:
README                  S11openbsd-inetd
S07makedev              S11rc.local
S07sysklogd             S12stop-bootlogd
S08cron                 S13rmnologin
S08klogd

Reordered sid shutdown sequence (base install)

/etc/rc6.d:
K03openbsd-inetd        K31umountnfs.sh
K06cron                 K35networking
K06klogd                K36ifupdown
K07sysklogd             K40umountfs
K20makedev              K60umountroot
K20sendsigs             K90reboot
K25hwclock.sh           README

I'm not brave enough, get me out of here

It is possible to automatically undo the reordering, once, by reconfiguring insserv and disabling the dependency based boot.

# BAD_INSSERV_HACKER=true dpkg-reconfigure i
info: Disabling dependency based boot system
Removing `diversion of /usr/sbin/update-rc.d to /usr/sbin/update-rc.d.distrib by insserv'
info: Restoring using backed up copy of init.d/ and rc*.d/.
info: successfully restored backup of init.d scripts
#

How can package maintainers assist

Even running boot scripts in parallel is possible

echo CONCURRENCY=shell >> /etc/default/rcS

Thank you very much

Questions?

http://www.hungry.com/~pere/mypapers/200706-bootseq/