1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757
|
<?xml version='1.0'?>
<!-- -*- DocBook -*- -->
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"/usr/share/sgml/docbook/dtd/xml/4.2/docbookx.dtd" [
<!ENTITY % sgml.features "IGNORE">
<!ENTITY % xml.features "INCLUDE">
<!ENTITY % dbcent PUBLIC
"-//OASIS//ENTITIES DocBook Character Entities V4.2//EN"
"/usr/share/sgml/docbook/dtd/xml/4.2/dbcentx.mod"> %dbcent;
<!ENTITY % commondata SYSTEM "../common.ent" > %commondata;
<!ENTITY % popcon SYSTEM "../popcon.ent" > %popcon;
<!ENTITY % pkgsize SYSTEM "../pkgsize.ent" > %pkgsize;
<!ENTITY % urlsdata SYSTEM "../urls.ent" > %urlsdata;
]>
<chapter id="thesysteminitialization">
<title>The system initialization</title>
<para>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. </para>
<para>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. </para>
<para/>
<section id="anoverviewofthebootstrapprocess">
<title>An overview of the boot strap process</title>
<para>The computer system undergoes several phases of <ulink url="&bootstrapprocesses;">boot strap processes</ulink> from the power-on event until it offers the fully functional operating system (OS) to the user. </para>
<para>For simplicity, I will limit discussion to the typical PC platform with the default installation. </para>
<para>The typical boot strap process is like a four-stage rocket. Each stage rocket hands over the system control to the next stage one. Here each stage corresponds to: </para>
<itemizedlist>
<listitem><para>Stage 1: the BIOS </para></listitem>
<listitem><para>Stage 2: the boot loader </para></listitem>
<listitem><para>Stage 3, the mini-Debian system </para></listitem>
<listitem><para>Stage 4: the normal Debian system </para></listitem>
</itemizedlist>
<para>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. </para>
<note><para> 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 (<xref linkend="partitionconfiguration"/>). Please seek the platform specific documentations elsewhere for such a case. </para></note>
<para/>
</section>
<section id="stagebthebios">
<title>Stage 1: the BIOS</title>
<para>The <ulink url="&bios;">BIOS</ulink> is the 1st stage of the boot process which is started by the power-on event. The <ulink url="&bios;">BIOS</ulink> resides on the <ulink url="&readonlymemoryrom;">read only memory (ROM)</ulink> from the particular memory address to which the program counter of CPU is initialized by the power-on event. </para>
<para>This BIOS performs the basic initialization of the hardware (<ulink url="&postpoweronselftest;">POST: power on self test</ulink>) and hands the system control to the next step which you provide. The BIOS is usually provided with the hardware. </para>
<para>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. </para>
<para>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: </para>
<itemizedlist>
<listitem><para>the boot loader code, </para></listitem>
<listitem>
<para>the kernel code of the stepping stone OS such as <ulink url="&freedos;">FreeDOS</ulink>, or </para>
</listitem>
<listitem><para>the kernel code of the target OS if it fits in this small space. </para></listitem>
</itemizedlist>
<para>Typically, the system is booted from the specified partition of the primary hard disk partition. The first sector of the hard disk contain the <ulink url="&masterbootrecordmbr;">master boot record (MBR)</ulink>. 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 for the hard disk occupies the rest of this MBR. </para>
<para/>
</section>
<section id="stagecthebootloader">
<title>Stage 2: the boot loader</title>
<para>The <ulink url="&bootloader;">boot loader</ulink> is the 2nd stage of the boot process which is started by the BIOS. It loads the system kernel image and the <ulink url="&initrd;">initrd</ulink> 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. </para>
<para>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. </para>
<para/>
<para/>
<para>The default install of the Debian system places first-stage GRUB boot loader code into the <ulink url="&mbr;">MBR</ulink> for the PC platform. There are many boot loaders and configuration options available. </para>
<table id="listofbootloaders">
<title> List of boot loaders. </title><tgroup x-pkgname=" 2 " x-popcon=" 3 " x-pkgsize=" 4 " cols="6">
<colspec colname="xxx1"/>
<colspec colname="xxx2"/>
<colspec colname="xxx3"/>
<colspec colname="xxx4"/>
<colspec colname="xxx5"/>
<colspec colname="xxx6"/>
<thead><row>
<entry>
<para>
<emphasis role="strong">bootloader</emphasis>
</para>
</entry>
<entry>
<para>
<emphasis role="strong">package</emphasis>
</para>
</entry>
<entry>
<para>
<emphasis role="strong">popcon</emphasis>
</para>
</entry>
<entry>
<para>
<emphasis role="strong">size</emphasis>
</para>
</entry>
<entry>
<para>
<emphasis role="strong">initrd</emphasis>
</para>
</entry>
<entry>
<para>
<emphasis role="strong">description</emphasis>
</para>
</entry>
</row></thead><tbody><row>
<entry>
<para>
<ulink url="&grublegacy;">GRUB Legacy</ulink>
</para>
</entry>
<entry>
<para> grub </para>
</entry>
<entry><para>&pop-grub;</para></entry>
<entry><para>&size-grub;</para></entry>
<entry>
<para> Supported </para>
</entry>
<entry>
<para> This is smart enough to understand disk partitions and file systems such as vfat, ext3, .... (etch default) </para>
</entry>
</row><row>
<entry>
<para>
<ulink url="&grubc;">GRUB 2</ulink>
</para>
</entry>
<entry>
<para> grub-pc </para>
</entry>
<entry><para>&pop-grubpc;</para></entry>
<entry><para>&size-grubpc;</para></entry>
<entry>
<para> Supported </para>
</entry>
<entry>
<para> This is smart enough to understand disk partitions and file systems such as vfat, ext3, .... (new for lenny) </para>
</entry>
</row><row>
<entry>
<para>
<ulink url="&grubc;">GRUB 2</ulink>
</para>
</entry>
<entry>
<para> grub-rescue-pc </para>
</entry>
<entry><para>&pop-grubrescuepc;</para></entry>
<entry><para>&size-grubrescuepc;</para></entry>
<entry>
<para> Supported </para>
</entry>
<entry>
<para> This is GRUB 2 bootable rescue images (CD and floppy) (PC/BIOS version) </para>
</entry>
</row><row>
<entry>
<para>
<ulink url="&lilo;">Lilo</ulink>
</para>
</entry>
<entry>
<para> lilo </para>
</entry>
<entry><para>&pop-lilo;</para></entry>
<entry><para>&size-lilo;</para></entry>
<entry>
<para> Supported </para>
</entry>
<entry>
<para> This relies on the sector locations of data on the hard disk. (Old) </para>
</entry>
</row><row>
<entry>
<para>
<ulink url="&isolinux;">Isolinux</ulink>
</para>
</entry>
<entry>
<para> syslinux </para>
</entry>
<entry><para>&pop-syslinux;</para></entry>
<entry><para>&size-syslinux;</para></entry>
<entry>
<para> Supported </para>
</entry>
<entry>
<para> This understands the ISO9660 file system. This is used by the boot CD. </para>
</entry>
</row><row>
<entry>
<para>
<ulink url="&syslinux;">Syslinux</ulink>
</para>
</entry>
<entry>
<para> syslinux </para>
</entry>
<entry><para>&pop-syslinux;</para></entry>
<entry><para>&size-syslinux;</para></entry>
<entry>
<para> Supported </para>
</entry>
<entry>
<para> This understands the <ulink url="&msdosfilesystemfat;">MSDOS file system (FAT)</ulink>. This is used by the boot floppy. </para>
</entry>
</row><row>
<entry>
<para>
<ulink url="&loadlin;">Loadlin</ulink>
</para>
</entry>
<entry>
<para> loadlin </para>
</entry>
<entry><para>&pop-loadlin;</para></entry>
<entry><para>&size-loadlin;</para></entry>
<entry>
<para> Supported </para>
</entry>
<entry>
<para> New system is started from the FreeDOS/MSDOS system. </para>
</entry>
</row><row>
<entry>
<para>
<ulink url="&neilturtonsmbr;">Neil Turton's MBR</ulink>
</para>
</entry>
<entry>
<para> mbr </para>
</entry>
<entry><para>&pop-mbr;</para></entry>
<entry><para>&size-mbr;</para></entry>
<entry>
<para> Not supported </para>
</entry>
<entry>
<para> This is free software which substitutes MSDOS <ulink url="&mbr;">MBR</ulink>. This only understands disk partitions. </para>
</entry>
</row></tbody>
</tgroup>
</table>
<para>For GRUB Legacy, the menu configuration file is located at <code>/boot/grub/menu.lst</code> . For example, it has entries like: </para>
<screen>title Debian GNU/Linux
root (hd0,2)
kernel /vmlinuz root=/dev/hda3 ro
initrd /initrd.img
</screen>
<para>For GRUB 2, the menu configuration file is located at <code>/boot/grub/grub.cfg</code>. It is automatically generated by <code>/usr/sbin/update-grub</code> using templates from <code>/etc/grub.d/*</code> and settings from <code>/etc/default/grub</code>. For example, it has entries like: </para>
<para/>
<screen>menuentry "Debian GNU/Linux" {
set root=(hd0,3)
linux /vmlinuz root=/dev/hda3
initrd /initrd.img
}
</screen>
<para>For these examples, these GRUB parameters mean: </para>
<table id="themeaningofgrubparameters">
<title> The meaning of GRUB parameters. </title><tgroup x-pkgname=" " x-popcon="" x-pkgsize="" cols="2">
<colspec colname="xxx1"/>
<colspec colname="xxx2"/>
<thead><row>
<entry>
<para>
<emphasis role="strong">GRUB parameter</emphasis>
</para>
</entry>
<entry>
<para>
<emphasis role="strong">meaning</emphasis>
</para>
</entry>
</row></thead><tbody><row>
<entry>
<para>
<code>root</code>
</para>
</entry>
<entry>
<para> Use 3rd partition on boot disk by setting it as <code>(hd0,2)</code> in GRUB legacy or as <code>(hd0,3)</code> in GRUB 2. </para>
</entry>
</row><row>
<entry>
<para>
<code>kernel</code>
</para>
</entry>
<entry>
<para> Use kernel located at <code>/vmlinuz</code> with kernel parameter: "<code>root=/dev/hda3 ro</code>". </para>
</entry>
</row><row>
<entry>
<para>
<code>initrd</code>
</para>
</entry>
<entry>
<para> Use <ulink url="&initrdinitramfs;">initrd/initramfs</ulink> image located at "<code>/initrd.img</code>". </para>
</entry>
</row></tbody>
</tgroup>
</table>
<note><para> 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. </para></note>
<tip><para><ulink url="&uuid;">UUID</ulink> (see <xref linkend="accessingpartitionusinguuid"/>) may be used to identify a block special device instead of its file name such as "<code>/dev/hda3</code>", e.g."<code>root=UUID=81b289d5-4341-4003-9602-e254a17ac232 ro</code>". </para></tip>
<tip><para> You can start a boot loader from another boot loader using techniques called <ulink url="&chainloading;">chain loading</ulink>. </para></tip>
<note><para> Having bootable rescue media (CD or floppy) created from images in the <code>grub-rescue-pc</code> package let you boot your system without functioning bootloader on the harddisk. </para></note>
<para>See "<code>info grub</code>" and <code>grub-install</code>(8). </para>
<para/>
</section>
<section id="stagedtheminidebiansystem">
<title>Stage 3: the mini-Debian system</title>
<para/>
<para/>
<para/>
<para/>
<para/>
<para>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. It is an optional preparatory stage of the boot process. </para>
<note><para> 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 <ulink url="&initrd;">initrd</ulink> or initramfs system. Similar system on the memory is used by <ulink url="&thedebianinstaller;">the Debian Installer</ulink>. </para></note>
<para>The <code>/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 file system as an encrypted one. </para>
<para>You can interrupt this part of the boot process to gain root shell by providing "<code>break=init</code>" etc. to the kernel boot parameter. See the <code>/init</code> script for more break conditions. This shell environment is sophisticated enough to make a good inspection of your machine's hardware. </para>
<para>Commands available in this mini-Debian system are stripped down ones and mainly provided by a GNU tool called <code>busybox</code>. </para>
<caution><para> You need to use "<code>-n</code>" option for <code>mount</code> command when you are on the readonly root file system. </para></caution>
<para/>
</section>
<section id="stageethenormaldebiansystem">
<title>Stage 4: the normal Debian system</title>
<para>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 harddisk filesystem. </para>
<para>The <code>/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>sysv-rc</code> package. See <code>man 8 init</code>, <code>man 5 inittab</code>, and <code>/usr/share/doc/sysv-rc/README.runlevels.gz</code> for the exact explanation. Following is a simplified overview of this main boot process: </para>
<orderedlist numeration="arabic">
<listitem>
<para>The Debian system goes into <emphasis role="strong">runlevel N</emphasis> (none) to initialize the system by following the <code>/etc/inittab</code> description. </para>
</listitem>
<listitem>
<para>The Debian system goes into <emphasis role="strong">runlevel S</emphasis> to initialize the system under the single-user mode to complete hardware initialization etc. </para>
</listitem>
<listitem>
<para>The Debian system switches itself to one of the specified <emphasis role="strong">multi-user runlevels (2 to 5)</emphasis> to start the system services. </para>
</listitem>
</orderedlist>
<para>The initial runlevel used for multi-user mode is specified with the "<code>init=</code>" kernel boot parameter or in the "initdefault" line of this <code>/etc/inittab</code>. The Debian system as installed starts at the <emphasis role="strong">runlevel 2</emphasis>. </para>
<para>All scripts executed by the init system are located in the directory <code>/etc/init.d/</code>. </para>
<tip><para> For alternative boot mechanism to the <code>sysv-rc</code> package using a single configuration file, see the <code>file-rc</code> package. Both mechanisms are compatible through <code>/etc/init.d/rc</code>, <code>/etc/init.d/rcS</code>, <code>/usr/sbin/update-rc.d</code>, and <code>/usr/sbin/invoke-rc.d</code> scripts. </para></tip>
<para/>
<section id="themeaningoftherunlevel">
<title>The meaning of the runlevel</title>
<para>Each runlevel uses a directory for its configuration and has specific meaning: </para>
<table id="listofrunlevelsandmeanings">
<title> List of runlevels and meanings. </title><tgroup x-pkgname=" " x-popcon=" " x-pkgsize="" cols="3">
<colspec colname="xxx1"/>
<colspec colname="xxx2"/>
<colspec colname="xxx3"/>
<thead><row>
<entry>
<para>
<emphasis role="strong">runlevel</emphasis>
</para>
</entry>
<entry>
<para>
<emphasis role="strong">directory</emphasis>
</para>
</entry>
<entry>
<para>
<emphasis role="strong">meaning</emphasis>
</para>
</entry>
</row></thead><tbody><row>
<entry>
<para>
<code>N</code>
</para>
</entry>
<entry>
<para> none </para>
</entry>
<entry>
<para> System bootup (NONE). There is no <code>/etc/rcN.d/</code> directory.</para>
</entry>
</row><row>
<entry>
<para>
<code>0</code>
</para>
</entry>
<entry>
<para>
<code>/etc/rc0.d/</code>
</para>
</entry>
<entry>
<para> Halt the system. </para>
</entry>
</row><row>
<entry>
<para>
<code>S</code>
</para>
</entry>
<entry>
<para>
<code>/etc/rcS.d/</code>
</para>
</entry>
<entry>
<para> Single-user mode on boot. The lower case <code>s</code> can be used as alias. </para>
</entry>
</row><row>
<entry>
<para>
<code>1</code>
</para>
</entry>
<entry>
<para>
<code>/etc/rc1.d/</code>
</para>
</entry>
<entry>
<para> Single-user mode switched from multi-user mode. </para>
</entry>
</row><row>
<entry>
<para>
<code>2</code>
</para>
</entry>
<entry>
<para>
<code>/etc/rc2.d/</code>
</para>
</entry>
<entry>
<para> Multi-user mode. </para>
</entry>
</row><row>
<entry>
<para>
<code>3</code>
</para>
</entry>
<entry>
<para>
<code>/etc/rc3.d/</code>
</para>
</entry>
<entry>
<para> ,, </para>
</entry>
</row><row>
<entry>
<para>
<code>4</code>
</para>
</entry>
<entry>
<para>
<code>/etc/rc4.d/</code>
</para>
</entry>
<entry>
<para> ,, </para>
</entry>
</row><row>
<entry>
<para>
<code>5</code>
</para>
</entry>
<entry>
<para>
<code>/etc/rc5.d/</code>
</para>
</entry>
<entry>
<para> ,, </para>
</entry>
</row><row>
<entry>
<para>
<code>6</code>
</para>
</entry>
<entry>
<para>
<code>/etc/rc6.d/</code>
</para>
</entry>
<entry>
<para> Reboot the system. </para>
</entry>
</row><row>
<entry>
<para>
<code>7</code>
</para>
</entry>
<entry>
<para>
<code>/etc/rc7.d/</code>
</para>
</entry>
<entry>
<para> Valid multi-user mode but not normally used. </para>
</entry>
</row><row>
<entry>
<para>
<code>8</code>
</para>
</entry>
<entry>
<para>
<code>/etc/rc8.d/</code>
</para>
</entry>
<entry>
<para> ,, </para>
</entry>
</row><row>
<entry>
<para>
<code>9</code>
</para>
</entry>
<entry>
<para>
<code>/etc/rc9.d/</code>
</para>
</entry>
<entry>
<para> ,, </para>
</entry>
</row></tbody>
</tgroup>
</table>
<para>You can change the runlevel from the console to, e.g., 4 by: </para>
<screen>$ sudo telinit 4
</screen>
<caution><para><emphasis role="strong">The Debian system does not pre-assign any special meaning differences among the runlevels between 2 and 5.</emphasis> The system administrator on the Debian system may change this. (I.e., Debian is not RedHat nor SOLARIS nor HP-UX nor ...) </para></caution>
<caution><para> The Debian system does not populate directories for the runlevels between 7 and 9 when the package is installed. Traditional Unix variants don’t use these runlevels. </para></caution>
<para/>
</section>
<section id="theconfigurationoftherunlevel">
<title>The configuration of the runlevel</title>
<para>The names of the symlinks in the runlevel directories have the form <code>S<2-digit-number><original-name></code> or <code>K<2-digit-number><original-name></code>. The 2-digit-number is used to determine the order in which to run the scripts. 'S' is for 'Start' and 'K' is for 'Kill'. </para>
<para>When <code>init</code> or <code>telinit</code> commands change the runlevel to <n>: </para>
<orderedlist numeration="arabic">
<listitem>
<para>the script names starting with a <code>K</code> in <code>/etc/rc<n>.d/</code> are executed in alphabetical order with the single argument <code>stop</code> . (killing services) </para>
</listitem>
<listitem>
<para>the script names starting with an <code>S</code> in <code>/etc/rc<n>.d/</code> are executed in alphabetical order with the single argument <code>start</code> . (starting services) </para>
</listitem>
</orderedlist>
<para>For example, if you had the links <code>S10sysklogd</code> and <code>S20exim4</code> in a runlevel directory, <code>S10sysklogd</code> would run before <code>S20exim4</code>. </para>
<warning><para> It is not advisable to make any changes to symlinks in <code>/etc/rcS.d/</code> unless you know better than the maintainer. </para></warning>
<para/>
</section>
<section id="therunlevelmanagementexample">
<title>The runlevel management example</title>
<para>For example, let's set up runlevel system somewhat like Redhat system, i.e.: </para>
<itemizedlist>
<listitem><para>to start the system in runlevel=3 as the default, </para></listitem>
<listitem>
<para>not to start <code>gdm</code> in runlevel=(0,1,2,6), and </para>
</listitem>
<listitem>
<para>to start <code>gdm</code> in runlevel=(3,4,5). </para>
</listitem>
</itemizedlist>
<para>The easy way is to use editor on the <code>/etc/inittab</code> file to change starting runlevel and use user friendly runlevel management tools such as <emphasis role="strong"><code>sysv-rc-conf</code></emphasis> or <emphasis role="strong"><code>bum</code></emphasis> to edit the runlevel. If you are to use command line only, here is how you do it (after the default installation of <code>gdm</code> package and selecting it to be the choice of display manager): </para>
<screen># cd /etc/rc2.d ; mv S21gdm K21gdm
# cd /etc ; perl -i -p -e 's/^id:.:/id:3:/' inittab
</screen>
<para>Please note the <code>/etc/X11/default-display-manager</code> file is checked when starting the display manager daemons: <code>xdm</code>, <code>gdm</code>, <code>kdm</code>, and <code>wdm</code>. </para>
<note><para> You can still start X from any console shell with the <code>startx</code> command. </para></note>
<para/>
</section>
<section id="thedefaultparameoreachinitscript">
<title>The default parameter for each init script</title>
<para>The default parameter for each init script in <code>/etc/init.d/</code> is given by the corresponding file in <code>/etc/default/</code> which contains environment variable assignments <emphasis role="strong">only</emphasis>. The choice of directory name is specific to the Debian system. It is roughly the equivalent of the <code>/etc/sysconfig</code> directory found in Red Hat and other distributions. </para>
<para>For example, <code>/etc/default/hotplug</code> can be used to control how <code>/etc/init.d/hotplug</code> works. The <code>/etc/default/rcS</code> file can be used to customize boot-time defaults for <code>motd</code>, <code>sulogin</code>, etc. </para>
<para>If you cannot get the behavior you want by changing such variables then you may <ulink url="&modifytheinitscripts;">modify the init scripts</ulink> themselves: they are all configuration files. </para>
<para/>
</section>
<section id="thehostname">
<title>The hostname</title>
<para>The kernel maintains the system <emphasis role="strong">hostname</emphasis>. The initscript <code>/etc/init.d/hostname.sh</code> sets the system hostname at boot time (using the <code>hostname</code> command) to the name stored in <code>/etc/hostname</code>. This file should contain <emphasis role="strong">only</emphasis> the system hostname, not a fully qualified domain name. </para>
<para>To print out the current hostname run <code>hostname</code> without an argument. </para>
<para/>
</section>
<section id="networkinterfaceinitialization">
<title>Network interface initialization</title>
<para>Network interfaces are initialized under single-user mode on boot by the initscript <code>/etc/init.d/ifupdown-clean</code> and <code>/etc/init.d/ifupdown</code>. See <xref linkend="networksetup"/> for how to configure them. </para>
<para/>
</section>
<section id="networkserviceinitialization">
<title>Network service initialization</title>
<para>Many network services (see <xref linkend="networkapplications"/>) are started directly as daemon processes at boot time, e.g., <code>/etc/rc2.d/S20exim4</code> (for RUNLEVEL=2) which is a symlink to <code>/etc/init.d/exim4</code>. </para>
<para>Some network services can be started on demand using the <ulink url="&superserver;">super-server</ulink>, <code>inetd</code> (or its equivalents). The <code>inetd</code> is started at boot time by <code>/etc/rc2.d/S20inetd</code> (for RUNLEVEL=2) which is a symlink to <code>/etc/init.d/inetd</code>. Essentially, <code>inetd</code> allows one running daemon to invoke several others, reducing load on the system. </para>
<para>Whenever a request for service arrives, its protocol and service are identified by looking them up in the databases in <code>/etc/protocols</code> and <code>/etc/services</code>. <code>inetd</code> then looks up a normal Internet service in the <code>/etc/inetd.conf</code> database, or a Sun-RPC based service in <code>/etc/rpc.conf</code>. </para>
<para>For system security, make sure to disable unused services in <code>/etc/inetd.conf</code>. Sun-RPC services need to be active for NFS and other RPC-based programs. </para>
<para>Sometimes, <code>inetd</code> does not start the intended server directly but starts the <ulink url="&tcpwrapper;">TCP wrapper</ulink>, <code>tcpd</code>, with the intended server name as its argument in <code>/etc/inetd.conf</code>. In this case, <code>tcpd</code> runs the appropriate server program after logging the request and doing some additional checks using <code>/etc/hosts.deny</code> and <code>/etc/hosts.allow</code>. </para>
<para>If you have problems with remote access in a recent Debian system, comment out "ALL: PARANOID" in <code>/etc/hosts.deny</code> if it exists. (But you must be careful on security risks involved with this kind of action.) </para>
<para>For details, see <code>inetd</code>(8), <code>inetd.conf</code>(5), <code>protocols</code>(5), <code>services</code>(5), <code>tcpd</code>(8), <code>hosts_access</code>(5), and <code>hosts_options</code>(5). </para>
<para>For more information on Sun-RPC, see <code>rpcinfo</code>(8), <code>portmap</code>(8), and <code>/usr/share/doc/portmap/portmapper.txt.gz</code>. </para>
<para/>
</section>
<section id="thesystemmessage">
<title>The system message</title>
<para>The system message can be customized by <code>/etc/syslog.conf</code> for both the log file and on-screen display. See <code>syslogd</code>(8) and <code>syslog.conf</code>(5). See also <xref linkend="loganalyzer"/>. </para>
<para/>
</section>
<section id="thekernelmessage">
<title>The kernel message</title>
<para>The kernel message can be customized by <code>/etc/init.d/klogd</code> for both the log file and on-screen display. Set <code>KLOGD="-c 3"</code> in this script and run <code>/etc/init.d/klogd restart</code>. See <code>klogd</code>(8). </para>
<para>You may directly change the error message level by: </para>
<screen># dmesg -n3
</screen>
<para>Here: </para>
<table id="listofkernelerrorlevels">
<title> List of kernel error levels. </title><tgroup x-pkgname=" " x-popcon=" " x-pkgsize="" cols="3">
<colspec colname="xxx1"/>
<colspec colname="xxx2"/>
<colspec colname="xxx3"/>
<thead><row>
<entry>
<para>
<emphasis role="strong">error level value</emphasis>
</para>
</entry>
<entry>
<para>
<emphasis role="strong">error level name</emphasis>
</para>
</entry>
<entry>
<para>
<emphasis role="strong">meaning</emphasis>
</para>
</entry>
</row></thead><tbody><row>
<entry>
<para> 0 </para>
</entry>
<entry>
<para> KERN_EMERG </para>
</entry>
<entry>
<para> system is unusable </para>
</entry>
</row><row>
<entry>
<para> 1 </para>
</entry>
<entry>
<para> KERN_ALERT </para>
</entry>
<entry>
<para> action must be taken immediately </para>
</entry>
</row><row>
<entry>
<para> 2 </para>
</entry>
<entry>
<para> KERN_CRIT </para>
</entry>
<entry>
<para> critical conditions </para>
</entry>
</row><row>
<entry>
<para> 3 </para>
</entry>
<entry>
<para> KERN_ERR </para>
</entry>
<entry>
<para> error conditions </para>
</entry>
</row><row>
<entry>
<para> 4 </para>
</entry>
<entry>
<para> KERN_WARNING </para>
</entry>
<entry>
<para> warning conditions </para>
</entry>
</row><row>
<entry>
<para> 5 </para>
</entry>
<entry>
<para> KERN_NOTICE </para>
</entry>
<entry>
<para> normal but significant condition </para>
</entry>
</row><row>
<entry>
<para> 6 </para>
</entry>
<entry>
<para> KERN_INFO </para>
</entry>
<entry>
<para> informational </para>
</entry>
</row><row>
<entry>
<para> 7 </para>
</entry>
<entry>
<para> KERN_DEBUG </para>
</entry>
<entry>
<para> debug-level messages </para>
</entry>
</row></tbody>
</tgroup>
</table>
<para/>
</section>
<section id="theudevsystem">
<title>The udev system</title>
<para>For Linux kernel 2.6, <ulink url="&theudevsystem;">the udev system</ulink> provides mechanism for the automatic hardware discovery and initialization (see <code>udev</code>(7)). Upon discovery of each device by the kernel, the udev system starts a user process which uses information from the <ulink url="&sysfs;">sysfs</ulink> filesystem (see <xref linkend="procfsandsysfs"/>), loads required kernel modules supporting it using the <code>modprobe</code>(8) program (see <xref linkend="thekernelmoduleinitialization"/>), and creates corresponding device nodes. </para>
<para>The name of device nodes can be configured by files in <code>/etc/udev/rules.d/</code> (see <code>/usr/share/doc/udev/writing_udev_rules/index.html</code>). </para>
<para>Since the udev system is somewhat a moving target, I leave details to other documentations and describe the minimum information here. </para>
<para/>
</section>
<section id="thekernelmoduleinitialization">
<title>The kernel module initialization</title>
<para>The <code>modprobe</code>(8) program enables us to configure running Linux kernel from user process by adding and removing kernel modules. The udev system (see <xref linkend="theudevsystem"/>) automates its invocation to help the kernel module initialization. </para>
<para>Non-hardware modules and special hardware driver modules, such as: </para>
<itemizedlist>
<listitem>
<para><ulink url="&tuntap;">TUN/TAP</ulink> modules providing virtual Point-to-Point network device (TUN) and virtual Ethernet network device (TAP), </para>
</listitem>
<listitem>
<para><ulink url="&netfilter;">netfilter</ulink> modules providing netfilter firewall capabilities (<code>iptables</code>(8), <xref linkend="netfilter"/>), </para>
</listitem>
<listitem>
<para><ulink url="&watchdogtimer;">watchdog timer</ulink> driver modules </para>
</listitem>
</itemizedlist>
<para>need to be pre-loaded by listing them in the <code>/etc/modules</code> file (see <code>modules</code>(5)). </para>
<para>The configuration files for the <code>modprobe</code>(8) program are located under the <code>/etc/modprobes.d/</code> directory as explained in <code>modprobe.conf</code>(5). (If you want to avoid some kernel modules to be auto-loaded, consider to blacklist them in the <code>/etc/modprobes.d/blacklist</code> file.) </para>
<para>The <code>/lib/modules/<version>/modules.dep</code> file generated by the <code>depmod</code>(8) program describes module dependencies used by the <code>modprobe</code>(8) program. </para>
<para>The <code>modinfo</code>(8) program shows information about a Linux Kernel module. </para>
<para>The <code>lsmod</code>(8) program nicely formats the contents of the <code>/proc/modules</code>, showing what kernel modules are currently loaded. </para>
<tip><para> You can identify exact hardware on your system. See <xref linkend="thehardwareidentification"/>. </para></tip>
<tip><para> You may configure hardware at boot time to activate expected hardware features. See <xref linkend="thehardwareconfiguration"/>. </para></tip>
<tip><para> You can add support for your device by recompiling kernel. See <xref linkend="thekernel"/>. </para></tip>
</section>
</section>
</chapter>
|