--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+ <head>
+ <link rel="stylesheet" href="../mrtg-td/slides.css" type="text/css">
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Language" content="en">
+ <meta name="Author" content="Petter Reinholdtsen">
+<style type="text/css">
+PRE {
+ font-size: smaller
+}
+</style>
+
+ </head>
+ <body>
+
+<h1>Dependency based boot sequence</h1>
+
+<p>Reordering the boot sequence for correctness and speed</p>
+
+<p>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.</p>
+
+<div class="presenter">Petter Reinholdtsen
+ <br>pere@hungry.com
+ <br>Debconf 2007 Edinburgh, 2007-06-17</div>
+
+<h2>About the speaker</h2>
+
+<ul>
+
+ <li>Using Linux since 1993
+ <li>Debian Developer since 2002
+
+ <li>Educated at University of Tromsø, Western Australia and Oslo
+
+ <li>Employed at University of Oslo to develop system administration tools
+ <li>Leader of the Norwegian Unix User Group
+
+ <li>Co-maintaining sysvinit, maintaining insserv
+ <li>and a few other (Debian Edu, Debian GIS, Debian
+ Java, Debian Boot, etc)
+
+</ul>
+
+<h2>Summary of this talk</h2>
+
+<ul>
+ <li>Quick overview of the boot system alternatives in Debian
+ <li>Some problems with the current system
+ <li>How to improve the boot sequence ordering
+ <li>how to prepare packages for this
+</ul>
+
+<p>Based on work done by Carlos Villegas during Google Summer of Code
+2006, available from
+<a href="http://initscripts-ng.alioth.debian.org/soc2006-bootsystem/">http://initscripts-ng.alioth.debian.org/soc2006-bootsystem/</a>.</p>
+
+<h2>Debian include several boot system options</h2>
+
+<p>SysV init is only the most used boot system in Debian, not the only
+ one.</p>
+
+<ul>
+
+ <li>file-rc
+ <li>upstart
+ <li>init-ng
+ <li>minit
+ <li>runit
+ <li>metainit initiative for init.d scripts
+
+</ul>
+
+<h2>The SysV boot system</h2>
+
+<ul>
+
+<li>Start first all scripts in /etc/rcS.d/
+
+<li>For the runlevel 2, first all K##scripts in /etc/rc2.d/, next all
+ S##script.
+
+<li>All .sh scripts are sourced, the rest are exec-ed
+
+</ul>
+
+<a href="bootchart-sid.png"><img src="bootchart-sid.png" width="100%"></a>
+
+<h2>Current sid boot sequence (base install)</h2>
+
+<pre>
+/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
+</pre>
+
+<h2>Current sid shutdown sequence (base install)</h2>
+<pre>
+/etc/rc6.d:
+K11cron S30urandom
+K20makedev S31umountnfs.sh
+K20openbsd-inetd S35networking
+K25hwclock.sh S36ifupdown
+K89klogd S40umountfs
+K90sysklogd S60umountroot
+README S90reboot
+S20sendsigs
+</pre>
+
+<p>But is it correct?
+
+<h2>Problems with the current boot system</h2>
+
+<ul>
+ <li>Slightly incorrect ordering during startup and shutdown
+ <li>Hard to pick correct sequence number
+ <li>The halt/reboot runlevels are inconsistent/confusing (or wrong,
+ depending on your view)
+
+ <li>Impossible to parallelise
+</ul>
+
+<h2>How can we verify the boot sequence correctness?</h2>
+
+<p><a href="depgraph-base.png"><img align="right" src="depgraph-base.png" width="100%"></a>
+
+<ul>
+ <li>Document the dependencies of each script
+ <li>Verify the scripts are started in dependency order
+
+</ul></p>
+
+<p>Example header:</p>
+
+<pre>
+#!/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
+</pre>
+
+<h2>Verifying the current sequence</h2>
+
+<p>Using these headers and a script from the insserv package, we can
+verify the boot order:
+
+<pre>
+# /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
+#
+</pre>
+
+<p>For the packages without dependency information, override files can be
+read from <tt>/usr/share/insserv/overrides/</tt> and
+<tt>/etc/insserv/overrides/</tt>.
+
+<h2>Verifying the current sequence II</h2>
+<p>Current status (base task install), with override files.</p>
+<pre>
+# /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
+#
+</pre>
+
+<h2>Verifying the current sequence III</h2>
+<p>Current status (desktop task install)</p>
+<pre>
+# /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
+#
+</pre>
+
+<h2>Reordering based on dependency information</h2>
+
+<p>Advantages:
+
+<ul>
+
+<li>No need to replace existing init.d scripts
+<li>Activated by adding headers to the scripts or use override files
+<li>Experimental code to enable it is in the insserv package
+
+</ul>
+
+<p>How to enable this by default
+
+<ul>
+
+<li>Install the insserv package
+<li>Make all start-symlinks in rc0 and rc6 to stop symlinks
+<li>Replace update-rc.d
+<li>Reorder rc*.d/*
+</ul>
+
+<h2>Status of dependency based sysv boot sequence</h2>
+
+<p><a href="insserv-enable.png"><img align="right" src="insserv-enable.png" width="100%"></a>
+<ul>
+ <li>Majority of common packages provides dependency information
+ <li>Correct startup sequence for base and desktop tasks when enabled.
+ <li>Fairly correct shutdown sequence.
+ <li>Some packages fail to install because of incorrect init.d script
+ registration order
+
+</ul>
+
+<p>
+To enable: <tt>BAD_INSSERV_HACKER=true dpkg-reconfigure insserv</tt>
+<p>Testrun:
+<pre>
+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'
+#
+</pre>
+
+<h2>Similar boot graph</h2>
+
+<a href="bootchart-reordered.png"><img src="bootchart-reordered.png" width="100%"></a>
+
+<h2>Reordered sid boot sequence (base install)</h2>
+<pre>
+/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
+</pre>
+
+<h2>Reordered sid shutdown sequence (base install)</h2>
+
+<pre>
+/etc/rc6.d:
+K03openbsd-inetd K31umountnfs.sh
+K06cron K35networking
+K06klogd K36ifupdown
+K07sysklogd K40umountfs
+K20makedev K60umountroot
+K20sendsigs K90reboot
+K25hwclock.sh README
+</pre>
+
+<h2>I'm not brave enough, get me out of here</h2>
+
+<p>It is possible to automatically undo the reordering, <em>once</em>,
+by reconfiguring insserv and disabling the dependency based boot.</p>
+
+<pre>
+# 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
+#
+</pre>
+
+<h2>How can package maintainers assist</h2>
+
+<ul>
+
+<li>Update their init.d scripts to include correct dependency
+ information using the LSB headers defined for this purpose,
+ <a href="http://wiki.debian.org/LSBInitScripts">http://wiki.debian.org/LSBInitScripts</a>
+<li>Make sure their init.d scripts are registered in dependency order
+<li>Start using insserv to detect bugs in the packages
+</ul>
+
+<h2>Even running boot scripts in parallel is possible</h2>
+
+<pre>echo CONCURRENCY=shell >> /etc/default/rcS</pre>
+<a href="bootchart-reord-concur.png"><img src="bootchart-reord-concur.png" width="100%"></a>
+
+
+<h2>Thank you very much</h2>
+
+<h3>Questions?</h3>
+
+<p><a href="http://www.hungry.com/~pere/mypapers/200706-bootseq/">http://www.hungry.com/~pere/mypapers/200706-bootseq/</a></p>
+
+ </body>
+</html>