old-www/LDP/www.debian.org/doc/manuals/debian-reference/ch03.en.html

1117 lines
69 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Chapter 3. The system initialization</title>
<link rel="stylesheet" href="debian-reference.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.en.html" title="Debian Reference">
<link rel="up" href="index.en.html" title="Debian Reference">
<link rel="prev" href="ch02.en.html" title="Chapter 2. Debian package management">
<link rel="next" href="ch04.en.html" title="Chapter 4. Authentication">
<link rel="preface" href="pr01.en.html" title="Preface">
<link rel="chapter" href="ch01.en.html" title="Chapter 1. GNU/Linux tutorials">
<link rel="chapter" href="ch02.en.html" title="Chapter 2. Debian package management">
<link rel="chapter" href="ch03.en.html" title="Chapter 3. The system initialization">
<link rel="chapter" href="ch04.en.html" title="Chapter 4. Authentication">
<link rel="chapter" href="ch05.en.html" title="Chapter 5. Network setup">
<link rel="chapter" href="ch06.en.html" title="Chapter 6. Network applications">
<link rel="chapter" href="ch07.en.html" title="Chapter 7. The X Window System">
<link rel="chapter" href="ch08.en.html" title="Chapter 8. I18N and L10N">
<link rel="chapter" href="ch09.en.html" title="Chapter 9. System tips">
<link rel="chapter" href="ch10.en.html" title="Chapter 10. Data management">
<link rel="chapter" href="ch11.en.html" title="Chapter 11. Data conversion">
<link rel="chapter" href="ch12.en.html" title="Chapter 12. Programming">
<link rel="appendix" href="apa.en.html" title="Appendix A. Appendix">
<link rel="section" href="ch03.en.html#_an_overview_of_the_boot_strap_process" title="3.1. An overview of the boot strap process">
<link rel="section" href="ch03.en.html#_stage_1_the_bios" title="3.2. Stage 1: the BIOS">
<link rel="section" href="ch03.en.html#_stage_2_the_boot_loader" title="3.3. Stage 2: the boot loader">
<link rel="section" href="ch03.en.html#_stage_3_the_mini_debian_system" title="3.4. Stage 3: the mini-Debian system">
<link rel="section" href="ch03.en.html#_stage_4_the_normal_debian_system" title="3.5. Stage 4: the normal Debian system">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">Chapter 3. The system initialization</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="ch02.en.html"><img src="images/prev.gif" alt="Prev"></a> </td>
<th width="60%" align="center"> </th>
<td width="20%" align="right"> <a accesskey="n" href="ch04.en.html"><img src="images/next.gif" alt="Next"></a>
</td>
</tr>
</table>
<hr>
</div>
<div class="chapter">
<div class="titlepage"><div><div><h2 class="title">
<a name="_the_system_initialization"></a>Chapter 3. The system initialization</h2></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt><span class="section"><a href="ch03.en.html#_an_overview_of_the_boot_strap_process">3.1. An overview of the boot strap process</a></span></dt>
<dt><span class="section"><a href="ch03.en.html#_stage_1_the_bios">3.2. Stage 1: the BIOS</a></span></dt>
<dt><span class="section"><a href="ch03.en.html#_stage_2_the_boot_loader">3.3. Stage 2: the boot loader</a></span></dt>
<dt><span class="section"><a href="ch03.en.html#_stage_3_the_mini_debian_system">3.4. Stage 3: the mini-Debian system</a></span></dt>
<dt><span class="section"><a href="ch03.en.html#_stage_4_the_normal_debian_system">3.5. Stage 4: the normal Debian system</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="ch03.en.html#_the_meaning_of_the_runlevel">3.5.1. The meaning of the runlevel</a></span></dt>
<dt><span class="section"><a href="ch03.en.html#_the_configuration_of_the_runlevel">3.5.2. The configuration of the runlevel</a></span></dt>
<dt><span class="section"><a href="ch03.en.html#_the_runlevel_management_example">3.5.3. The runlevel management example</a></span></dt>
<dt><span class="section"><a href="ch03.en.html#_the_default_parameter_for_each_init_script">3.5.4. The default parameter for each init script</a></span></dt>
<dt><span class="section"><a href="ch03.en.html#_the_hostname">3.5.5. The hostname</a></span></dt>
<dt><span class="section"><a href="ch03.en.html#_the_filesystem">3.5.6. The filesystem</a></span></dt>
<dt><span class="section"><a href="ch03.en.html#_network_interface_initialization">3.5.7. Network interface initialization</a></span></dt>
<dt><span class="section"><a href="ch03.en.html#_network_service_initialization">3.5.8. Network service initialization</a></span></dt>
<dt><span class="section"><a href="ch03.en.html#_the_system_message">3.5.9. The system message</a></span></dt>
<dt><span class="section"><a href="ch03.en.html#_the_kernel_message">3.5.10. The kernel message</a></span></dt>
<dt><span class="section"><a href="ch03.en.html#_the_udev_system">3.5.11. The udev system</a></span></dt>
<dt><span class="section"><a href="ch03.en.html#_the_kernel_module_initialization">3.5.12. The kernel module initialization</a></span></dt>
</dl></dd>
</dl>
</div>
<p>It is wise for you as the system administrator to know roughly how the Debian system is started and configured. Although the exact details are in the source files of the packages installed and their documentations, it is a bit overwhelming for most of us.</p>
<p>I did my best to provide a quick overview of the key points of the Debian system and their configuration for your reference, based on the current and previous knowledge of mine and others. Since the Debian system is a moving target, the situation over the system may have been changed. Before making any changes to the system, you should refer to the latest documentation for each package.</p>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_an_overview_of_the_boot_strap_process"></a>3.1. An overview of the boot strap process</h2></div></div></div>
<p>The computer system undergoes several phases of <a class="ulink" href="http://en.wikipedia.org/wiki/Booting" target="_top">boot strap processes</a> from the power-on event until it offers the fully functional operating system (OS) to the user.</p>
<p>For simplicity, I limit discussion to the typical PC platform with the default installation.</p>
<p>The typical boot strap process is like a four-stage rocket. Each stage rocket hands over the system control to the next stage one.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
<a class="xref" href="ch03.en.html#_stage_1_the_bios" title="3.2. Stage 1: the BIOS">Section 3.2, “Stage 1: the BIOS”</a>
</p></li>
<li class="listitem"><p>
<a class="xref" href="ch03.en.html#_stage_2_the_boot_loader" title="3.3. Stage 2: the boot loader">Section 3.3, “Stage 2: the boot loader”</a>
</p></li>
<li class="listitem"><p>
<a class="xref" href="ch03.en.html#_stage_3_the_mini_debian_system" title="3.4. Stage 3: the mini-Debian system">Section 3.4, “Stage 3: the mini-Debian system”</a>
</p></li>
<li class="listitem"><p>
<a class="xref" href="ch03.en.html#_stage_4_the_normal_debian_system" title="3.5. Stage 4: the normal Debian system">Section 3.5, “Stage 4: the normal Debian system”</a>
</p></li>
</ul></div>
<p>Of course, these can be configured differently. For example, if you compiled your own kernel, you may be skipping the step with the mini-Debian system. So please do not assume this is the case for your system until you check it yourself.</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>For non-legacy PC platform such as the SUN or the Macintosh system, the BIOS on ROM and the partition on the disk may be quite different (<a class="xref" href="ch09.en.html#_disk_partition_configuration" title="9.3.2. Disk partition configuration">Section 9.3.2, “Disk partition configuration”</a>). Please seek the platform specific documentations elsewhere for such a case.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_stage_1_the_bios"></a>3.2. Stage 1: the BIOS</h2></div></div></div>
<p>The <a class="ulink" href="http://en.wikipedia.org/wiki/BIOS" target="_top">BIOS</a> is the 1st stage of the boot process which is started by the power-on event. The <a class="ulink" href="http://en.wikipedia.org/wiki/BIOS" target="_top">BIOS</a> residing on the <a class="ulink" href="http://en.wikipedia.org/wiki/Read-only_memory" target="_top">read only memory (ROM)</a> is executed from the particular memory address to which the program counter of CPU is initialized by the power-on event.</p>
<p>This BIOS performs the basic initialization of the hardware (<a class="ulink" href="http://en.wikipedia.org/wiki/Power-on_self-test" target="_top">POST: power on self test</a>) and hands the system control to the next step which you provide. The BIOS is usually provided with the hardware.</p>
<p>The BIOS startup screen usually indicates what key(s) to press to enter the BIOS setup screen to configure the BIOS behavior. Popular keys used are F1, F2, F10, Esc, Ins, and Del. If your BIOS startup screen is hidden by a nice graphics screen, you may press some keys such as Esc to disable this. These keys are highly dependent on the hardware.</p>
<p>The hardware location and the priority of the code started by the BIOS can be selected from the BIOS setup screen. Typically, the first few sectors of the first found selected device (hard disk, floppy disk, CD-ROM, …) are loaded to the memory and this initial code is executed. This initial code can be any one of the following.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
The boot loader code
</p></li>
<li class="listitem"><p>
The kernel code of the stepping stone OS such as <a class="ulink" href="http://www.freedos.org/" target="_top">FreeDOS</a>
</p></li>
<li class="listitem"><p>
The kernel code of the target OS if it fits in this small space
</p></li>
</ul></div>
<p>Typically, the system is booted from the specified partition of the primary hard disk partition. First 2 sectors of the hard disk on legacy PC contain the <a class="ulink" href="http://en.wikipedia.org/wiki/Master_boot_record" target="_top">master boot record (MBR)</a>. The disk partition information including the boot selection is recorded at the end of this MBR. The first boot loader code executed from the BIOS occupies the rest of this MBR.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_stage_2_the_boot_loader"></a>3.3. Stage 2: the boot loader</h2></div></div></div>
<p>The <a class="ulink" href="http://en.wikipedia.org/wiki/Boot_loader" target="_top">boot loader</a> is the 2nd stage of the boot process which is started by the BIOS. It loads the system kernel image and the <a class="ulink" href="http://en.wikipedia.org/wiki/Initrd" target="_top">initrd</a> image to the memory and hands control over to them. This initrd image is the root filesystem image and its support depends on the bootloader used.</p>
<p>The Debian system normally uses the Linux kernel as the default system kernel. The initrd image for the current 2.6 Linux kernel is technically the initramfs (initial RAM filesystem) image. The initramfs image is a gzipped cpio archive of files in the root filesystem.</p>
<p>The default install of the Debian system places first-stage GRUB boot loader code into the <a class="ulink" href="http://en.wikipedia.org/wiki/Master_boot_record" target="_top">MBR</a> for the PC platform. There are many boot loaders and configuration options available.</p>
<div class="table">
<a name="listofbootloaders"></a><p class="title"><b>Table 3.1. List of boot loaders</b></p>
<div class="table-contents"><table summary="List of boot loaders" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
bootloader
</th>
<th align="left">
package
</th>
<th align="left">
popcon
</th>
<th align="left">
size
</th>
<th align="left">
initrd
</th>
<th align="left">
description
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/GNU_GRUB" target="_top">GRUB Legacy</a>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/grub-legacy" target="_top">
grub-legacy
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=grub-legacy" target="_top">http://qa.debian.org/popcon.php?package=grub-legacy</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/grub-legacy.html" target="_top">1741</a></td>
<td align="left">
Supported
</td>
<td align="left">
This is smart enough to understand disk partitions and filesystems such as vfat, ext3, …. (<code class="literal">lenny</code> default)
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/GNU_GRUB" target="_top">GRUB 2</a>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/grub-pc" target="_top">
grub-pc
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=grub-pc" target="_top">http://qa.debian.org/popcon.php?package=grub-pc</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/grub-pc.html" target="_top">461</a></td>
<td align="left">
Supported
</td>
<td align="left">
This is smart enough to understand disk partitions and filesystems such as vfat, ext3, ….
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/GNU_GRUB" target="_top">GRUB 2</a>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/grub-rescue-pc" target="_top">
grub-rescue-pc
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=grub-rescue-pc" target="_top">http://qa.debian.org/popcon.php?package=grub-rescue-pc</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/grub-rescue-pc.html" target="_top">3885</a></td>
<td align="left">
Supported
</td>
<td align="left">
This is GRUB 2 bootable rescue images (CD and floppy) (PC/BIOS version)
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/LILO_(boot_loader)" target="_top">Lilo</a>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/lilo" target="_top">
lilo
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=lilo" target="_top">http://qa.debian.org/popcon.php?package=lilo</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/l/lilo.html" target="_top">595</a></td>
<td align="left">
Supported
</td>
<td align="left">
This relies on the sector locations of data on the hard disk. (Old)
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/SYSLINUX" target="_top">Isolinux</a>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/syslinux" target="_top">
syslinux
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=syslinux" target="_top">http://qa.debian.org/popcon.php?package=syslinux</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/s/syslinux.html" target="_top">134</a></td>
<td align="left">
Supported
</td>
<td align="left">
This understands the ISO9660 filesystem. This is used by the boot CD.
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/SYSLINUX" target="_top">Syslinux</a>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/syslinux" target="_top">
syslinux
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=syslinux" target="_top">http://qa.debian.org/popcon.php?package=syslinux</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/s/syslinux.html" target="_top">134</a></td>
<td align="left">
Supported
</td>
<td align="left">
This understands the <a class="ulink" href="http://en.wikipedia.org/wiki/File_Allocation_Table" target="_top">MSDOS filesystem (FAT)</a>. This is used by the boot floppy.
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Loadlin" target="_top">Loadlin</a>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/loadlin" target="_top">
loadlin
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=loadlin" target="_top">http://qa.debian.org/popcon.php?package=loadlin</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/l/loadlin.html" target="_top">104</a></td>
<td align="left">
Supported
</td>
<td align="left">
New system is started from the FreeDOS/MSDOS system.
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://www.chiark.greenend.org.uk/~neilt/" target="_top">MBR by Neil Turton</a>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/mbr" target="_top">
mbr
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=mbr" target="_top">http://qa.debian.org/popcon.php?package=mbr</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/m/mbr.html" target="_top">71</a></td>
<td align="left">
Not supported
</td>
<td align="left">
This is free software which substitutes MSDOS <a class="ulink" href="http://en.wikipedia.org/wiki/Master_boot_record" target="_top">MBR</a>. This only understands disk partitions.
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></td>
<th align="left">Warning</th>
</tr>
<tr><td align="left" valign="top"><p>Do not play with boot loaders without having bootable rescue media (CD or floppy) created from images in the <code class="literal">grub-rescue-pc</code> package. It makes you boot your system even without functioning bootloader on the hard disk.</p></td></tr>
</table></div>
<p>For GRUB Legacy, the menu configuration file is located at "<code class="literal">/boot/grub/menu.lst</code>". For example, it has entries as the following.</p>
<pre class="screen">title Debian GNU/Linux
root (hd0,2)
kernel /vmlinuz root=/dev/hda3 ro
initrd /initrd.img</pre>
<p>For GRUB 2, the menu configuration file is located at "<code class="literal">/boot/grub/grub.cfg</code>". It is automatically generated by "<code class="literal">/usr/sbin/update-grub</code>" using templates from "<code class="literal">/etc/grub.d/*</code>" and settings from "<code class="literal">/etc/default/grub</code>". For example, it has entries as the following.</p>
<pre class="screen">menuentry "Debian GNU/Linux" {
set root=(hd0,3)
linux /vmlinuz root=/dev/hda3
initrd /initrd.img
}</pre>
<p>For these examples, these GRUB parameters mean the following.</p>
<div class="table">
<a name="themeaningofgrubparameters"></a><p class="title"><b>Table 3.2. The meaning of GRUB parameters</b></p>
<div class="table-contents"><table summary="The meaning of GRUB parameters" border="1">
<colgroup>
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
GRUB parameter
</th>
<th align="left">
meaning
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
<code class="literal">root</code>
</td>
<td align="left">
use 3rd partition on the primary disk by setting it as "<code class="literal">(hd0,2)</code>" in GRUB legacy or as "<code class="literal">(hd0,3)</code>" in GRUB 2
</td>
</tr>
<tr>
<td align="left">
<code class="literal">kernel</code>
</td>
<td align="left">
use kernel located at "<code class="literal">/vmlinuz</code>" with kernel parameter: "<code class="literal">root=/dev/hda3 ro</code>"
</td>
</tr>
<tr>
<td align="left">
<code class="literal">initrd</code>
</td>
<td align="left">
use <a class="ulink" href="http://en.wikipedia.org/wiki/Initrd" target="_top">initrd/initramfs</a> image located at "<code class="literal">/initrd.img</code>"
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>The value of the partition number used by GRUB legacy program is one less than normal one used by Linux kernel and utility tools. GRUB 2 program fixes this problem.</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p><a class="ulink" href="http://en.wikipedia.org/wiki/Universally_Unique_Identifier" target="_top">UUID</a> (see <a class="xref" href="ch09.en.html#_accessing_partition_using_uuid" title="9.3.3. Accessing partition using UUID">Section 9.3.3, “Accessing partition using UUID”</a>) may be used to identify a block special device instead of its file name such as "<code class="literal">/dev/hda3</code>", e.g."<code class="literal">root=UUID=81b289d5-4341-4003-9602-e254a17ac232 ro</code>".</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>You can start a boot loader from another boot loader using techniques called <a class="ulink" href="http://en.wikipedia.org/wiki/Chain_loading" target="_top">chain loading</a>.</p></td></tr>
</table></div>
<p>See "<code class="literal">info grub</code>" and <span class="citerefentry"><span class="refentrytitle">grub-install</span>(8)</span>.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_stage_3_the_mini_debian_system"></a>3.4. Stage 3: the mini-Debian system</h2></div></div></div>
<p>The mini-Debian system is the 3rd stage of the boot process which is started by the boot loader. It runs the system kernel with its root filesystem on the memory. This is an optional preparatory stage of the boot process.</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>The term "the mini-Debian system" is coined by the author to describe this 3rd stage boot process for this document. This system is commonly referred as the <a class="ulink" href="http://en.wikipedia.org/wiki/Initrd" target="_top">initrd</a> or initramfs system. Similar system on the memory is used by <a class="ulink" href="http://www.debian.org/devel/debian-installer/" target="_top">the Debian Installer</a>.</p></td></tr>
</table></div>
<p>The "<code class="literal">/init</code>" script is executed as the first program in this root filesystem on the memory. It is a shell script program which initializes the kernel in user space and hands control over to the next stage. This mini-Debian system offers flexibility to the boot process such as adding kernel modules before the main boot process or mounting the root filesystem as an encrypted one.</p>
<p>You can interrupt this part of the boot process to gain root shell by providing "<code class="literal">break=init</code>" etc. to the kernel boot parameter. See the "<code class="literal">/init</code>" script for more break conditions. This shell environment is sophisticated enough to make a good inspection of your machine's hardware.</p>
<p>Commands available in this mini-Debian system are stripped down ones and mainly provided by a GNU tool called <span class="citerefentry"><span class="refentrytitle">busybox</span>(1)</span>.</p>
<div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Caution">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="images/caution.png"></td>
<th align="left">Caution</th>
</tr>
<tr><td align="left" valign="top"><p>You need to use "<code class="literal">-n</code>" option for <code class="literal">mount</code> command when you are on the readonly root filesystem.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_stage_4_the_normal_debian_system"></a>3.5. Stage 4: the normal Debian system</h2></div></div></div>
<div class="table">
<a name="listofbootutilitrthedebiansystem"></a><p class="title"><b>Table 3.3. List of boot utilities for the Debian system</b></p>
<div class="table-contents"><table summary="List of boot utilities for the Debian system" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
package
</th>
<th align="left">
popcon
</th>
<th align="left">
size
</th>
<th align="left">
description
</th>
</tr></thead>
<tbody>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/initscripts" target="_top">
<code class="literal">initscripts</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=initscripts" target="_top">http://qa.debian.org/popcon.php?package=initscripts</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/i/initscripts.html" target="_top">268</a></td>
<td align="left">
scripts for initializing and shutting down the system
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/sysvinit" target="_top">
<code class="literal">sysvinit</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=sysvinit" target="_top">http://qa.debian.org/popcon.php?package=sysvinit</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/s/sysvinit.html" target="_top">236</a></td>
<td align="left">
System-V-like <span class="citerefentry"><span class="refentrytitle">init</span>(8)</span> utilities
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/sysv-rc" target="_top">
<code class="literal">sysv-rc</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=sysv-rc" target="_top">http://qa.debian.org/popcon.php?package=sysv-rc</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/s/sysv-rc.html" target="_top">237</a></td>
<td align="left">
System-V-like runlevel change mechanism
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/sysvinit-utils" target="_top">
<code class="literal">sysvinit-utils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=sysvinit-utils" target="_top">http://qa.debian.org/popcon.php?package=sysvinit-utils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/s/sysvinit-utils.html" target="_top">208</a></td>
<td align="left">
System-V-like utilities (<span class="citerefentry"><span class="refentrytitle">startpar</span>(8)</span>, <span class="citerefentry"><span class="refentrytitle">bootlogd</span>(8)</span>, …)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/lsb-base" target="_top">
<code class="literal">lsb-base</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=lsb-base" target="_top">http://qa.debian.org/popcon.php?package=lsb-base</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/l/lsb-base.html" target="_top">70</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Linux_Standard_Base" target="_top">Linux Standard Base</a> 3.2 init script functionality
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/insserv" target="_top">
<code class="literal">insserv</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=insserv" target="_top">http://qa.debian.org/popcon.php?package=insserv</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/i/insserv.html" target="_top">182</a></td>
<td align="left">
tool to organize boot sequence using LSB init.d script dependencies
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/upstart" target="_top">
<code class="literal">upstart</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=upstart" target="_top">http://qa.debian.org/popcon.php?package=upstart</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/u/upstart.html" target="_top">696</a></td>
<td align="left">
event-based <span class="citerefentry"><span class="refentrytitle">init</span>(8)</span> daemon for concurrency (alternative to <code class="literal">sysvinit</code>)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/readahead-fedora" target="_top">
<code class="literal">readahead-fedora</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=readahead-fedora" target="_top">http://qa.debian.org/popcon.php?package=readahead-fedora</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/r/readahead-fedora.html" target="_top">87</a></td>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">readahead</span>(8)</span> to preload boot process files
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/uswsusp" target="_top">
<code class="literal">uswsusp</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=uswsusp" target="_top">http://qa.debian.org/popcon.php?package=uswsusp</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/u/uswsusp.html" target="_top">514</a></td>
<td align="left">
tools to use userspace software suspend provided by Linux
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/kexec-tools" target="_top">
<code class="literal">kexec-tools</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=kexec-tools" target="_top">http://qa.debian.org/popcon.php?package=kexec-tools</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/k/kexec-tools.html" target="_top">279</a></td>
<td align="left">
kexec tool for <span class="citerefentry"><span class="refentrytitle">kexec</span>(8)</span> reboots (warm reboot)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/bootchart" target="_top">
<code class="literal">bootchart</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=bootchart" target="_top">http://qa.debian.org/popcon.php?package=bootchart</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/b/bootchart.html" target="_top">132</a></td>
<td align="left">
boot process performance analyser
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/bootchart-view" target="_top">
<code class="literal">bootchart-view</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=bootchart-view" target="_top">http://qa.debian.org/popcon.php?package=bootchart-view</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/b/bootchart-view.html" target="_top">280</a></td>
<td align="left">
boot process performance analyser (visualisation)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/mingetty" target="_top">
<code class="literal">mingetty</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=mingetty" target="_top">http://qa.debian.org/popcon.php?package=mingetty</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/m/mingetty.html" target="_top">24</a></td>
<td align="left">
console-only <span class="citerefentry"><span class="refentrytitle">getty</span>(8)</span>
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/mgetty" target="_top">
<code class="literal">mgetty</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=mgetty" target="_top">http://qa.debian.org/popcon.php?package=mgetty</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/m/mgetty.html" target="_top">416</a></td>
<td align="left">
smart modem <span class="citerefentry"><span class="refentrytitle">getty</span>(8)</span> replacement
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>All boot mechanisms are compatible through "<code class="literal">/etc/init.d/rc</code>", "<code class="literal">/etc/init.d/rcS</code>", "<code class="literal">/usr/sbin/update-rc.d</code>", and "<code class="literal">/usr/sbin/invoke-rc.d</code>" scripts.</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>The <code class="literal">readahead-fedora</code> package can speed up starting of a system with decent amount of DRAM.</p></td></tr>
</table></div>
<p>The normal Debian system is the 4th stage of the boot process which is started by the mini-Debian system. The system kernel for the mini-Debian system continues to run in this environment. The root filesystem is switched from the one on the memory to the one on the real hard disk filesystem.</p>
<p>The "<code class="literal">/sbin/init</code>" program is executed as the first program and performs the main boot process. The Debian normally uses the traditional sysvinit scheme with the <code class="literal">sysv-rc</code> package. See <span class="citerefentry"><span class="refentrytitle">init</span>(8)</span>, <span class="citerefentry"><span class="refentrytitle">inittab</span>(5)</span>, and "<code class="literal">/usr/share/doc/sysv-rc/README.runlevels.gz</code>" for the exact explanation. This main boot process essentially goes through the following.</p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem"><p>
The Debian system goes into <span class="strong"><strong>runlevel N</strong></span> (none) to initialize the system by following the "<code class="literal">/etc/inittab</code>" description.
</p></li>
<li class="listitem"><p>
The Debian system goes into <span class="strong"><strong>runlevel S</strong></span> to initialize the system under the single-user mode to complete hardware initialization etc.
</p></li>
<li class="listitem"><p>
The Debian system goes into one of the specified <span class="strong"><strong>multi-user runlevels (2 to 5)</strong></span> to start the system services.
</p></li>
</ol></div>
<p>The initial runlevel used for multi-user mode is specified with the "<code class="literal">init=</code>" kernel boot parameter or in the "initdefault" line of the "<code class="literal">/etc/inittab</code>". The Debian system as installed starts at the <span class="strong"><strong>runlevel 2</strong></span>.</p>
<p>All actual script files executed by the init system are located in the directory "<code class="literal">/etc/init.d/</code>".</p>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_the_meaning_of_the_runlevel"></a>3.5.1. The meaning of the runlevel</h3></div></div></div>
<p>Each <a class="ulink" href="http://en.wikipedia.org/wiki/Runlevel" target="_top">runlevel</a> uses a directory for its configuration and has specific meaning as the following.</p>
<div class="table">
<a name="listofrunlevelsationoftheirusage"></a><p class="title"><b>Table 3.4. List of runlevels and description of their usage</b></p>
<div class="table-contents"><table summary="List of runlevels and description of their usage" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
runlevel
</th>
<th align="left">
directory
</th>
<th align="left">
description of runlevel usage
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
<code class="literal">N</code>
</td>
<td align="left">
none
</td>
<td align="left">
system bootup (NONE) level (no "<code class="literal">/etc/rcN.d/</code>" directory)
</td>
</tr>
<tr>
<td align="left">
<code class="literal">0</code>
</td>
<td align="left">
<code class="literal">/etc/rc0.d/</code>
</td>
<td align="left">
halt the system
</td>
</tr>
<tr>
<td align="left">
<code class="literal">S</code>
</td>
<td align="left">
<code class="literal">/etc/rcS.d/</code>
</td>
<td align="left">
single-user mode on boot (alias: "<code class="literal">s</code>")
</td>
</tr>
<tr>
<td align="left">
<code class="literal">1</code>
</td>
<td align="left">
<code class="literal">/etc/rc1.d/</code>
</td>
<td align="left">
single-user mode switched from multi-user mode
</td>
</tr>
<tr>
<td align="left">
<code class="literal">2</code>
</td>
<td align="left">
<code class="literal">/etc/rc2.d/</code>
</td>
<td align="left">
multi-user mode
</td>
</tr>
<tr>
<td align="left">
<code class="literal">3</code>
</td>
<td align="left">
<code class="literal">/etc/rc3.d/</code>
</td>
<td align="left">
,,
</td>
</tr>
<tr>
<td align="left">
<code class="literal">4</code>
</td>
<td align="left">
<code class="literal">/etc/rc4.d/</code>
</td>
<td align="left">
,,
</td>
</tr>
<tr>
<td align="left">
<code class="literal">5</code>
</td>
<td align="left">
<code class="literal">/etc/rc5.d/</code>
</td>
<td align="left">
,,
</td>
</tr>
<tr>
<td align="left">
<code class="literal">6</code>
</td>
<td align="left">
<code class="literal">/etc/rc6.d/</code>
</td>
<td align="left">
reboot the system
</td>
</tr>
<tr>
<td align="left">
<code class="literal">7</code>
</td>
<td align="left">
<code class="literal">/etc/rc7.d/</code>
</td>
<td align="left">
valid multi-user mode but not normally used
</td>
</tr>
<tr>
<td align="left">
<code class="literal">8</code>
</td>
<td align="left">
<code class="literal">/etc/rc8.d/</code>
</td>
<td align="left">
,,
</td>
</tr>
<tr>
<td align="left">
<code class="literal">9</code>
</td>
<td align="left">
<code class="literal">/etc/rc9.d/</code>
</td>
<td align="left">
,,
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>You can change the runlevel from the console to, e.g., 4 by the following.</p>
<pre class="screen">$ sudo telinit 4</pre>
<div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Caution">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="images/caution.png"></td>
<th align="left">Caution</th>
</tr>
<tr><td align="left" valign="top"><p><span class="strong"><strong>The Debian system does not pre-assign any special meaning differences among the <a class="ulink" href="http://en.wikipedia.org/wiki/Runlevel" target="_top">runlevels</a> between 2 and 5.</strong></span> The system administrator on the Debian system may change this. (I.e., Debian is not <a class="ulink" href="http://en.wikipedia.org/wiki/Red_Hat_Linux" target="_top">Red Hat Linux</a> nor <a class="ulink" href="http://en.wikipedia.org/wiki/Solaris_(operating_system)" target="_top">Solaris by Sun Microsystems</a> nor <a class="ulink" href="http://en.wikipedia.org/wiki/HP-UX" target="_top">HP-UX by Hewlett Packard</a> nor <a class="ulink" href="http://en.wikipedia.org/wiki/IBM_AIX" target="_top">AIX by IBM</a> nor …)</p></td></tr>
</table></div>
<div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Caution">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="images/caution.png"></td>
<th align="left">Caution</th>
</tr>
<tr><td align="left" valign="top"><p>The Debian system does not populate directories for the <a class="ulink" href="http://en.wikipedia.org/wiki/Runlevel" target="_top">runlevels</a> between 7 and 9 when the package is installed. Traditional <a class="ulink" href="http://en.wikipedia.org/wiki/Unix-like" target="_top">Unix variants</a> don't use these <a class="ulink" href="http://en.wikipedia.org/wiki/Runlevel" target="_top">runlevels</a>.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_the_configuration_of_the_runlevel"></a>3.5.2. The configuration of the runlevel</h3></div></div></div>
<p>When <span class="citerefentry"><span class="refentrytitle">init</span>(8)</span> or <span class="citerefentry"><span class="refentrytitle">telinit</span>(8)</span> commands goes into the runlevel to "&lt;n&gt;", the system basically executes the initialization scripts as follows.</p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem"><p>
The script names starting with a "<code class="literal">K</code>" in "<code class="literal">/etc/rc&lt;n&gt;.d/</code>" are executed in alphabetical order with the single argument "<code class="literal">stop</code>". (killing services)
</p></li>
<li class="listitem"><p>
The script names starting with an "<code class="literal">S</code>" in "<code class="literal">/etc/rc&lt;n&gt;.d/</code>" are executed in alphabetical order with the single argument "<code class="literal">start</code>". (starting services)
</p></li>
</ol></div>
<p>For example, if you had the links "<code class="literal">S10sysklogd</code>" and "<code class="literal">S20exim4</code>" in a runlevel directory, "<code class="literal">S10sysklogd</code>" which is symlinked to "<code class="literal">../init.d/sysklogd</code>" would run before "<code class="literal">S20exim4</code>" which is symlinked to "<code class="literal">../init.d/exim4</code>".</p>
<p>This simple sequential initialization system is the classical <a class="ulink" href="http://en.wikipedia.org/wiki/UNIX_System_V" target="_top">System V</a> style boot system and was used up to the Debian <code class="literal">lenny</code> system.</p>
<p>The recent Debian system is optimized to execute the initialization scripts concurrently, instead.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
<p>
The <span class="citerefentry"><span class="refentrytitle">insserv</span>(8)</span> command uses the LSB package dependency information and calculates the dependencies between all scripts.
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem"><p>
See "<code class="literal">/usr/share/doc/insserv/README.Debian</code>".
</p></li></ul></div>
</li>
<li class="listitem">
<p>
The LSB package dependency information defined in the header of init scripts ensures availabilities of required resources.
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem"><p>
See <a class="ulink" href="http://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/tocsysinit.html" target="_top">Linux Standard Base Core Specification 3.1, VII. System Initialization</a>.
</p></li></ul></div>
</li>
<li class="listitem"><p>
<a class="ulink" href="http://lists.debian.org/debian-devel-announce/2010/05/msg00009.html" target="_top">Announcement of "Parallel booting enabled by default"</a>
</p></li>
</ul></div>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></td>
<th align="left">Warning</th>
</tr>
<tr><td align="left" valign="top"><p>It is not advisable to make any changes to symlinks in "<code class="literal">/etc/rcS.d/</code>" unless you know better than the maintainer.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_the_runlevel_management_example"></a>3.5.3. The runlevel management example</h3></div></div></div>
<p>For example, let's set up runlevel system somewhat like <a class="ulink" href="http://en.wikipedia.org/wiki/Red_Hat_Linux" target="_top">Red Hat Linux</a> as the following.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p><code class="literal">init</code> starts the system in runlevel=3 as the default.
</p></li>
<li class="listitem"><p><code class="literal">init</code> does not start <span class="citerefentry"><span class="refentrytitle">gdm3</span>(1)</span> in runlevel=(0,1,2,6).
</p></li>
<li class="listitem"><p><code class="literal">init</code> starts <span class="citerefentry"><span class="refentrytitle">gdm3</span>(1)</span> in runlevel=(3,4,5).
</p></li>
</ul></div>
<p>This can be done by using editor on the "<code class="literal">/etc/inittab</code>" file to change starting runlevel and using user friendly runlevel management tools such as <code class="literal">sysv-rc-conf</code> or <code class="literal">bum</code> to edit the runlevel. If you are to use command line only instead, here is how you do it (after the default installation of the <code class="literal">gdm3</code> package and selecting it to be the choice of display manager).</p>
<pre class="screen"># cd /etc/rc2.d ; mv S21gdm3 K21gdm3
# cd /etc ; perl -i -p -e 's/^id:.:/id:3:/' inittab</pre>
<p>Please note the "<code class="literal">/etc/X11/default-display-manager</code>" file is checked when starting the display manager daemons: <code class="literal">xdm</code>, <code class="literal">gdm3</code>, <code class="literal">kdm</code>, and <code class="literal">wdm</code>.</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>You can still start X from any console shell with the <span class="citerefentry"><span class="refentrytitle">startx</span>(1)</span> command.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_the_default_parameter_for_each_init_script"></a>3.5.4. The default parameter for each init script</h3></div></div></div>
<p>The default parameter for each init script in "<code class="literal">/etc/init.d/</code>" is given by the corresponding file in "<code class="literal">/etc/default/</code>" which contains environment variable assignments <span class="strong"><strong>only</strong></span>. This choice of directory name is specific to the Debian system. It is roughly the equivalent of the "<code class="literal">/etc/sysconfig</code>" directory found in <a class="ulink" href="http://en.wikipedia.org/wiki/Red_Hat_Linux" target="_top">Red Hat Linux</a> and other distributions. For example, "<code class="literal">/etc/default/cron</code>" can be used to control how "<code class="literal">/etc/init.d/cron</code>" works.</p>
<p>The "<code class="literal">/etc/default/rcS</code>" file can be used to customize boot-time defaults for <span class="citerefentry"><span class="refentrytitle">motd</span>(5)</span>, <span class="citerefentry"><span class="refentrytitle">sulogin</span>(8)</span>, etc.</p>
<p>If you cannot get the behavior you want by changing such variables then you may <a class="ulink" href="http://www.debian.org/doc/debian-policy/ch-opersys#s9.3.2" target="_top">modify the init scripts</a> themselves. These are configuration files editable by system administrators.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_the_hostname"></a>3.5.5. The hostname</h3></div></div></div>
<p>The kernel maintains the system <span class="strong"><strong>hostname</strong></span>. The init script in runlevel S which is symlinked to "<code class="literal">/etc/init.d/hostname.sh</code>" sets the system hostname at boot time (using the <code class="literal">hostname</code> command) to the name stored in "<code class="literal">/etc/hostname</code>". This file should contain <span class="strong"><strong>only</strong></span> the system hostname, not a fully qualified domain name.</p>
<p>To print out the current hostname run <span class="citerefentry"><span class="refentrytitle">hostname</span>(1)</span> without an argument.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_the_filesystem"></a>3.5.6. The filesystem</h3></div></div></div>
<p>Although the root filesystem is mounted by the kernel when it is started, other filesystems are mounted in the runlevel S by the following init scripts.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
"<code class="literal">`/etc/init.d/mountkernfs.sh</code>" for kernel filesystems in "<code class="literal">/proc</code>", "<code class="literal">/sys</code>", etc.
</p></li>
<li class="listitem"><p>
"<code class="literal">`/etc/init.d/mountdevsubfs.sh</code>" for virtual filesystems in "<code class="literal">/dev</code>"
</p></li>
<li class="listitem"><p>
"<code class="literal">`/etc/init.d/mountall.sh</code>" for normal filesystems using "<code class="literal">/etc/fstab</code>"
</p></li>
<li class="listitem"><p>
"<code class="literal">`/etc/init.d/mountnfs.sh</code>" for network filesystems using"<code class="literal">/etc/fstab</code>"
</p></li>
</ul></div>
<p>The mount options of kernel filesystems are set in "<code class="literal">/etc/default/rcS</code>". See <span class="citerefentry"><span class="refentrytitle">rcS</span>(5)</span>.</p>
<p>The mount options of the filesystem are set in "<code class="literal">/etc/fstab</code>". See <a class="xref" href="ch09.en.html#_optimization_of_filesystem_by_mount_options" title="9.3.6. Optimization of filesystem by mount options">Section 9.3.6, “Optimization of filesystem by mount options”</a>.</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>The actual mounting of network filesystems waits for the start of the network interface.</p></td></tr>
</table></div>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></td>
<th align="left">Warning</th>
</tr>
<tr><td align="left" valign="top"><p>After mounting all the filesystems, temporary files in "<code class="literal">/tmp</code>", "<code class="literal">/var/lock</code>", and "<code class="literal">/var/run</code>" are cleaned for each boot up.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_network_interface_initialization"></a>3.5.7. Network interface initialization</h3></div></div></div>
<p>Network interfaces are initialized in runlevel S by the init script symlinked to "<code class="literal">/etc/init.d/ifupdown-clean</code>" and "<code class="literal">/etc/init.d/ifupdown</code>". See <a class="xref" href="ch05.en.html" title="Chapter 5. Network setup">Chapter 5, <i>Network setup</i></a> for how to configure them.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_network_service_initialization"></a>3.5.8. Network service initialization</h3></div></div></div>
<p>Many network services (see <a class="xref" href="ch06.en.html" title="Chapter 6. Network applications">Chapter 6, <i>Network applications</i></a>) are started under multi-user mode directly as daemon processes at boot time by the init script, e.g., "<code class="literal">/etc/rc2.d/S20exim4</code>" (for RUNLEVEL=2) which is a symlink to "<code class="literal">/etc/init.d/exim4</code>".</p>
<p>Some network services can be started on demand using the <a class="ulink" href="http://en.wikipedia.org/wiki/Super-server" target="_top">super-server</a> <code class="literal">inetd</code> (or its equivalents). The <code class="literal">inetd</code> is started at boot time by "<code class="literal">/etc/rc2.d/S20inetd</code>" (for RUNLEVEL=2) which is a symlink to "<code class="literal">/etc/init.d/inetd</code>". Essentially, <code class="literal">inetd</code> allows one running daemon to invoke several others, reducing load on the system.</p>
<p>Whenever a request for service arrives at <a class="ulink" href="http://en.wikipedia.org/wiki/Super-server" target="_top">super-server</a> <code class="literal">inetd</code> , its protocol and service are identified by looking them up in the databases in "<code class="literal">/etc/protocols</code>" and "<code class="literal">/etc/services</code>". <code class="literal">inetd</code> then looks up a normal Internet service in the "<code class="literal">/etc/inetd.conf</code>" database, or a <a class="ulink" href="http://en.wikipedia.org/wiki/Open_Network_Computing_Remote_Procedure_Call" target="_top">Open Network Computing Remote Procedure Call (ONC RPC)/Sun RPC</a> based service in "<code class="literal">/etc/rpc.conf</code>".</p>
<p>Sometimes, <code class="literal">inetd</code> does not start the intended server directly but starts the <a class="ulink" href="http://en.wikipedia.org/wiki/TCP_Wrapper" target="_top">TCP wrapper</a> program, <span class="citerefentry"><span class="refentrytitle">tcpd</span>(8)</span>, with the intended server name as its argument in "<code class="literal">/etc/inetd.conf</code>". In this case, <code class="literal">tcpd</code> runs the appropriate server program after logging the request and doing some additional checks using "<code class="literal">/etc/hosts.deny</code>" and "<code class="literal">/etc/hosts.allow</code>".</p>
<p>For system security, disable as much network service programs as possible. See <a class="xref" href="ch04.en.html#_restricting_access_to_some_server_services" title="4.6.4. Restricting access to some server services">Section 4.6.4, “Restricting access to some server services”</a>.</p>
<p>See <span class="citerefentry"><span class="refentrytitle">inetd</span>(8)</span>, <span class="citerefentry"><span class="refentrytitle">inetd.conf</span>(5)</span>, <span class="citerefentry"><span class="refentrytitle">protocols</span>(5)</span>, <span class="citerefentry"><span class="refentrytitle">services</span>(5)</span>, <span class="citerefentry"><span class="refentrytitle">tcpd</span>(8)</span>, <span class="citerefentry"><span class="refentrytitle">hosts_access</span>(5)</span>, <span class="citerefentry"><span class="refentrytitle">hosts_options</span>(5)</span>, <span class="citerefentry"><span class="refentrytitle">rpcinfo</span>(8)</span>, <span class="citerefentry"><span class="refentrytitle">portmap</span>(8)</span>, and "<code class="literal">/usr/share/doc/portmap/portmapper.txt.gz</code>".</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_the_system_message"></a>3.5.9. The system message</h3></div></div></div>
<p>The system message can be customized by "<code class="literal">/etc/default/rsyslog</code>" and "<code class="literal">/etc/rsyslog.conf</code>" for both the log file and on-screen display. See <span class="citerefentry"><span class="refentrytitle">rsyslogd</span>(8)</span> and <span class="citerefentry"><span class="refentrytitle">rsyslog.conf</span>(5)</span>. See also <a class="xref" href="ch09.en.html#_log_analyzer" title="9.2.2. Log analyzer">Section 9.2.2, “Log analyzer”</a>.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_the_kernel_message"></a>3.5.10. The kernel message</h3></div></div></div>
<p>The kernel message can be customized by "<code class="literal">/etc/default/klogd</code>" for both the log file and on-screen display. Set "<code class="literal">KLOGD='-c 3'</code>" in this file and run "<code class="literal">/etc/init.d/klogd restart</code>". See <span class="citerefentry"><span class="refentrytitle">klogd</span>(8)</span>.</p>
<p>You may directly change the error message level by the following.</p>
<pre class="screen"># dmesg -n3</pre>
<div class="table">
<a name="listofkernelerrorlevels"></a><p class="title"><b>Table 3.5. List of kernel error levels</b></p>
<div class="table-contents"><table summary="List of kernel error levels" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
error level value
</th>
<th align="left">
error level name
</th>
<th align="left">
meaning
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
0
</td>
<td align="left">
KERN_EMERG
</td>
<td align="left">
system is unusable
</td>
</tr>
<tr>
<td align="left">
1
</td>
<td align="left">
KERN_ALERT
</td>
<td align="left">
action must be taken immediately
</td>
</tr>
<tr>
<td align="left">
2
</td>
<td align="left">
KERN_CRIT
</td>
<td align="left">
critical conditions
</td>
</tr>
<tr>
<td align="left">
3
</td>
<td align="left">
KERN_ERR
</td>
<td align="left">
error conditions
</td>
</tr>
<tr>
<td align="left">
4
</td>
<td align="left">
KERN_WARNING
</td>
<td align="left">
warning conditions
</td>
</tr>
<tr>
<td align="left">
5
</td>
<td align="left">
KERN_NOTICE
</td>
<td align="left">
normal but significant condition
</td>
</tr>
<tr>
<td align="left">
6
</td>
<td align="left">
KERN_INFO
</td>
<td align="left">
informational
</td>
</tr>
<tr>
<td align="left">
7
</td>
<td align="left">
KERN_DEBUG
</td>
<td align="left">
debug-level messages
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break">
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_the_udev_system"></a>3.5.11. The udev system</h3></div></div></div>
<p>For Linux kernel 2.6, <a class="ulink" href="http://en.wikipedia.org/wiki/Udev" target="_top">the udev system</a> provides mechanism for the automatic hardware discovery and initialization (see <span class="citerefentry"><span class="refentrytitle">udev</span>(7)</span>). Upon discovery of each device by the kernel, the udev system starts a user process which uses information from the <a class="ulink" href="http://en.wikipedia.org/wiki/Sysfs" target="_top">sysfs</a> filesystem (see <a class="xref" href="ch01.en.html#_procfs_and_sysfs" title="1.2.12. procfs and sysfs">Section 1.2.12, “procfs and sysfs”</a>), loads required kernel modules supporting it using the <span class="citerefentry"><span class="refentrytitle">modprobe</span>(8)</span> program (see <a class="xref" href="ch03.en.html#_the_kernel_module_initialization" title="3.5.12. The kernel module initialization">Section 3.5.12, “The kernel module initialization”</a>), and creates corresponding device nodes.</p>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>If "<code class="literal">/lib/modules/&lt;kernel-version&gt;/modules.dep</code>" was not generated properly by <span class="citerefentry"><span class="refentrytitle">depmod</span>(8)</span> for some reason, modules may not be loaded as expected by the udev system. Execute "<code class="literal">depmod -a</code>" to fix it.</p></td></tr>
</table></div>
<p>The name of device nodes can be configured by udev rule files in "<code class="literal">/etc/udev/rules.d/</code>". Current default rules tend to create dynamically generated names resulting non-static device names except for cd and network devices. By adding your custom rules similar to what cd and network devices do, you can generate static device names for other devices such as USB memory sticks, too. See "<a class="ulink" href="http://www.reactivated.net/writing_udev_rules.html" target="_top">Writing udev rules</a>" or "<code class="literal">/usr/share/doc/udev/writing_udev_rules/index.html</code>".</p>
<p>Since the udev system is somewhat a moving target, I leave details to other documentations and describe the minimum information here.</p>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>For mounting rules in "<code class="literal">/etc/fstab</code>", device nodes do not need to be static ones. You can use <a class="ulink" href="http://en.wikipedia.org/wiki/Universally_Unique_Identifier" target="_top">UUID</a> to mount devices instead of device names such as "<code class="literal">/dev/sda</code>". See <a class="xref" href="ch09.en.html#_accessing_partition_using_uuid" title="9.3.3. Accessing partition using UUID">Section 9.3.3, “Accessing partition using UUID”</a>.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_the_kernel_module_initialization"></a>3.5.12. The kernel module initialization</h3></div></div></div>
<p>The <span class="citerefentry"><span class="refentrytitle">modprobe</span>(8)</span> program enables us to configure running Linux kernel from user process by adding and removing kernel modules. The udev system (see <a class="xref" href="ch03.en.html#_the_udev_system" title="3.5.11. The udev system">Section 3.5.11, “The udev system”</a>) automates its invocation to help the kernel module initialization.</p>
<p>There are non-hardware modules and special hardware driver modules as the following which need to be pre-loaded by listing them in the "<code class="literal">/etc/modules</code>" file (see <span class="citerefentry"><span class="refentrytitle">modules</span>(5)</span>).</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p><a class="ulink" href="http://en.wikipedia.org/wiki/TUN/TAP" target="_top">TUN/TAP</a> modules providing virtual Point-to-Point network device (TUN) and virtual Ethernet network device (TAP),
</p></li>
<li class="listitem"><p><a class="ulink" href="http://en.wikipedia.org/wiki/Netfilter" target="_top">netfilter</a> modules providing netfilter firewall capabilities (<span class="citerefentry"><span class="refentrytitle">iptables</span>(8)</span>, <a class="xref" href="ch05.en.html#_netfilter_infrastructure" title="5.9. Netfilter infrastructure">Section 5.9, “Netfilter infrastructure”</a>), and
</p></li>
<li class="listitem"><p><a class="ulink" href="http://en.wikipedia.org/wiki/Watchdog_timer" target="_top">watchdog timer</a> driver modules.
</p></li>
</ul></div>
<p>The configuration files for the <span class="citerefentry"><span class="refentrytitle">modprobe</span>(8)</span> program are located under the "<code class="literal">/etc/modprobes.d/</code>" directory as explained in <span class="citerefentry"><span class="refentrytitle">modprobe.conf</span>(5)</span>. (If you want to avoid some kernel modules to be auto-loaded, consider to blacklist them in the "<code class="literal">/etc/modprobes.d/blacklist</code>" file.)</p>
<p>The "<code class="literal">/lib/modules/&lt;version&gt;/modules.dep</code>" file generated by the <span class="citerefentry"><span class="refentrytitle">depmod</span>(8)</span> program describes module dependencies used by the <span class="citerefentry"><span class="refentrytitle">modprobe</span>(8)</span> program.</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>If you experience module loading issues with boot time module loading or with <span class="citerefentry"><span class="refentrytitle">modprobe</span>(8)</span>, "<code class="literal">depmod -a</code>" may resolve these issues by reconstructing "<code class="literal">modules.dep</code>".</p></td></tr>
</table></div>
<p>The <span class="citerefentry"><span class="refentrytitle">modinfo</span>(8)</span> program shows information about a Linux kernel module.</p>
<p>The <span class="citerefentry"><span class="refentrytitle">lsmod</span>(8)</span> program nicely formats the contents of the "<code class="literal">/proc/modules</code>", showing what kernel modules are currently loaded.</p>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>You can identify exact hardware on your system. See <a class="xref" href="ch09.en.html#_hardware_identification" title="9.6.3. Hardware identification">Section 9.6.3, “Hardware identification”</a>.</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>You may configure hardware at boot time to activate expected hardware features. See <a class="xref" href="ch09.en.html#_hardware_configuration" title="9.6.4. Hardware configuration">Section 9.6.4, “Hardware configuration”</a>.</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>You can add support for your device by recompiling kernel. See <a class="xref" href="ch09.en.html#_the_kernel" title="9.7. The kernel">Section 9.7, “The kernel”</a>.</p></td></tr>
</table></div>
</div>
</div>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="ch02.en.html"><img src="images/prev.gif" alt="Prev"></a> </td>
<td width="20%" align="center"> </td>
<td width="40%" align="right"> <a accesskey="n" href="ch04.en.html"><img src="images/next.gif" alt="Next"></a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Chapter 2. Debian package management </td>
<td width="20%" align="center"><a accesskey="h" href="index.en.html"><img src="images/home.gif" alt="Home"></a></td>
<td width="40%" align="right" valign="top"> Chapter 4. Authentication</td>
</tr>
</table>
</div>
</body>
</html>