Previous Page | Next Page

  1. Introduction
  2. Boot Process
  3. Init and System Initialization
  4. rc.sysinit script
  5. rc script
  6. functions script
  7. Services
  8. apm daemon
  9. network startup
  10. The network script file
  11. The network-functions file
  12. Portmap startup
  13. Random initialization
  14. Syslog initialization
  15. Gated
  16. Atd
  17. cron initialization
  18. pcmcia
  19. inetd daemon
  20. named daemon
  21. lpd daemon
  22. mars-nwe
  23. netfs startup
  24. dhcpd daemon
  25. autofs daemon
  26. keytable daemon
  27. sendmail daemon
  28. gpm daemon
  29. httpd daemon
  30. xfs startup
  31. smb startup
  32. innd startup
  33. linuxconf startup
  34. rc.local script
  35. Init, Getty, Login
  36. The shell
  37. Shutting down
  38. X
  39. Conclusions
  40. App A. rc.sysinit listing
  41. App B. functions listing
  42. App C. rc listing
  43. Credits

Linux rc.sysinit script

In appendix A is a listing of the /etc/rc.d/rc.sysinit file. Line numbers have been added for the sake of this discussion.

  1. The first thing it does is run itself through the system logger "initlog"(lines 9-11). For more information you can type "man initlog".
  2. Then it sets a minimal path, "/bin:/sbin:/usr/bin:/usr/sbin", (lines 13-15) on my system.
  3. If the file "/etc/sysconfig/network" exists, it reads it in, but if it doesn't exist, it disables networking (lines 17-23). The "/etc/sysconfig/network" file defines your network parameters as follows:
    NETWORKING=yes
    FORWARD_IPV4=false
    HOSTNAME=mymachine.mycompany.com
    DOMAINNAME=mycompany.com
    GATEWAY=10.1.0.25
    GATEWAYDEV=eth0
    

    These parameters, above are used on many script files later.

  4. Then a file "/etc/rc.d/init.d/functions" is loaded (lines 25-26) to provide the following functions to this script file. It is also used later in many other files and is listed in appendix B. It will be discussed in detail later.
    • daemon - Start a program
    • killproc - Stop a program
    • pidofproc - Find the process ID of a program
    • status - Gets the status of a process (running, dead, locked)
    • echo_success - Echo OK to the screen in proper colors.
    • echo_failure - Echo FAILED to the screen in proper colors.
    • echo_passed - Echo PASSED to the screen in proper colors.
    • success - Log to the system logger that something succeeded and echo_success if bootup is verbose
    • failure - Log that something failed and echo_failure if verbose bootup.
    • passed - Log that something passed and echo_passed if verbose bootup.
    • action - Run some action, log output to the system logger.
    • confirm - Confirm whether we want to run this service.
  5. The program "/sbin/loglevel" is used to set the initial loglevel (lines 28-29) which is initially set to 1 in /etc/rc.d/init.d/functions". This controls the level of the messages printed to the console. Each message has a loglevel numeric value dependent on its importance to the system. This program sets the console loglevel. The kernel will print messages of a lower loglevel value than that set. The loglevels are as follows:
    • 0 - The system is unusable
    • 1 - Action must be taken immediately
    • 2 - Critical condition
    • 3 - Error condition
    • 4 - Warning condition
    • 5 - Normal but significant condition
    • 6 - Informational
    • 6 - Debug message

    For more information try typing "man syslog" or "man syslogd".

  6. It sets and loads the keymap for the console (lines 31-47). Line 36 gets the KEYTABLE variable value which is normally "us" in the United States. On lines 37 to 39, if the string KEYTABLE is not of length 0, and the directory /usr/lib/kbd/keymaps exists, the KEYMAP string is made equal to the string KEYTABLE which was retrieved from the file /etc/sysconfig/keyboard. The easy way to modify the key settings for the system is to modify the file /etc/sysconfig/keyboard to a new default value such as KEYTABLE="/etc/sysconfig/console/mykeymap". Type "man keymaps" or "man loadkeys" for more information.
  7. The system font is loaded by running a script program /sbin/setsysfont (lines 49-52). This program will load/run the program "/etc/sysconfig/i18n" which can set font variables including language and possibly a screen font map and a user defined application charset map. It will first try to set these fonts using the program "consolechars" and if it can't find it, will use the program "setfont".
  8. The swap device specified in the file "/etc/fstab" is enabled for file swapping (lines 54-55) which is basically the same as the operating system using hard drive space like system memory. For more information type "man swapon" or "man swapoff".
  9. The host name and NIS domain name are then set (lines 57-62). Type "man hostname", "man domainname", "man dnsdomainname", or "man nisdomainname" for more information. The NIS domain defines a group of computers that share configuration information. It consists of a host being the master server of the domain and all the other servers and clients rely on the master host for their configuration information. Normally most computers do not participate in an NIS domain. The program domainname can be used to set any of the domain name parameters.
  10. The options for the file system check are set up as "fsckoptions" (lines 67-75). If the file /fsckoptions exists, its contents are placed in the variable "fsckoptions" to be used later in this script file when the filesystem check is done.
  11. If the file "/fastboot" exists the system filechecking is skipped. The system file checking uses the programs fsck and initlog (lines 77-112). Type "man fsck", "man initlog" for more information. Depending on the error returned by fsck (file system check), if file system errors exist and were not corrected the system will attempt a super user login to allow the administrator to try to fix problems and then unmounts all file systems and performs a reboot. See "man sulogin", "man umount", and "man reboot".
  12. If the file "/proc/cmdline" contains the text "nopnp", then pnp ability is disabled. If PNP (plug and play) is enabled, and the file "/sbin/isapnp" is executable, and the file "/etc/isapnp.conf" exists, the executable file "/sbin/isapnp" is used with the "/etc/isapnp.conf" file to set up ISA PNP devices (lines 118-131). For more information, type "man isapnp", "man isapnp.conf", or "man true".
  13. Then the root filesystem is remounted in read-write mode( LINES 133-134). Type "man mount" for more information. Note: remount is an option of the program mount.
  14. If an error was corrected in the filesystem in step 11 above, a quota check is run (lines 136-143). This does a filesystems scan for usage of files and directories. Type "man quotacheck", "man quotaon", or "man quotaoff" for more information.
  15. The string "IN_INITLOG" is cleared (lines 145-147).
  16. If the file "/etc/HOSTNAME" does not exist, the hostname from the file "/etc/sysconfig/network" is echoed to it so programs that use this file will work.(lines 149-151).
  17. The file "/etc/mtab" is cleared (lines 153-154). Then the files sytems "/ " (root) and "/proc" are mounted into mtab (lines 156-158). Type "man mount" for more information".
  18. The ability to use modules is disabled, if the file "/proc/cmdline" contains the text "nomodules" (lines 160-164).
  19. Set up soft links for module-info and the System.map file. Uses the version of the kernel to determine required setup, then find module dependencies by running "depmod -a". Type "man depmod" for more information (lines 166-188).
  20. The sound modules are loaded (lines 190-206). If USEMODULES is not empty and the file "/etc/conf.modules" contains the text "alias sound" or "alias midi" then the object modules from the subdirectories "/etc/sound" or "/etc/midi" are loaded respectively. If the file "/proc/sys/kernel/modprobe" exists, and USEMODULES is enabled, the text"/sbin/modprobe" is written to the file "/proc/sys/kernel/modprobe".
  21. RAID devices are added (lines 208-236). If the normal file "proc/mdstat" and "etc/raidtab" and the executable file "/sbin/raidadd" exist then raid devices are started using the program "/sbin/raidadd". Reading the man page for raidadd tells us that this is an obsolete RAID command. If raidadd returns 0 another obsolete RAID command "raidrun" is attempted. If this returns an error, a superuser login (sulogin) is done, filesystems are unmounted and a reboot is done.
  22. File systems are checked again with minor differences between this step and step 11 (lines 238-272).
  23. All other filesystems except for NFS and /proc are mounted (they are already mounted). nonfs, smbfs, ncpfs, and proc are mounted (lines 274-277).
  24. If the executable file "/sbin/quotaon" exists it is run (lines 279-281).
  25. The following files are deleted: /etc/mtab~, /fastboot /fsckoptions /forcefsck (lines 283-307). The file /var/run/utmp is cleared. The time of file /var/run/wtmp is updated (See "man touch"). File permissions and groups are changed for "/var/run/utmp" and /var/run/wtmp". Other files deleted are: "/var/lock/console.lock", "/var/lock/console/*", "/var/lock/LCK*", "/var/lock/subsys/*", "/var/run/*.pid", "/tmp/.X*-lock", and "/tmp/.s.PGSQL.*".
  26. The system clock is set (lines 309-350). The file "/etc/sysconfig/clock" is loaded. The values ARC and UTC are set dependent on the values in "/etc/sysconfig/clock" and CLOCKMODE. In my systems case, these are both false. The string values "$CLOCK" and "$CLOCKFLAGS" are set up dependent on files and options as shown below. If the file "/sbin/hwclock" exists, it will be run with the option "hctos" to set the system time from the hardware clock. Also the option "—adjust" is added to adjust for clock drift. If the above file "/sbin/hwclock" doesn't exist the "/sbin/clock" program will be run. If the "UTC" option is enabled then the "-u" option is added to CLOCKFLAGS. This allows for the hardware clock to be set in Coordinated Universal Time rather than local time.
  27. Swap space is turned on (lines 352-354). Type "man swapon" for more information.
  28. The serial ports are initialized (lines 356-359). If the file "/etc/rc.d/rc.serial" it is loaded resident. It doesn't exist on my system.
  29. Load modules (for backward compatibility with VARs) (lines 361-364). If the file "/etc/rc.d/rc.modules" exists, it is loaded. The script does not indicate it is loaded resident, but I wonder if this is a typo???
  30. If a SCSI tape is detected, load the st module unconditionally (lines 366-375).
  31. Set the preferred X display manager link (lines 377-400). If the file "/etc/sysconfig/desktop" contains the text "GNOME" preferred is set to "gdm". If "KDE" it is set to kde. If "AnotherLevel" it is set to xdm. In the statement "if [-n "$preferred" ] && which $preferred >/dev/null 2>&1;" the condition is met if the string "$preferred" has length, and the program "which" has any error or standard output greater than null.
  32. Dump the syslog ring so we can find it later (lines 402-404). The program dmesg is used to output the kernel logging to the file "/var/log/dmesg". Type "man dmesg" for more information.

The update Daemon

The program "init" invokes the command "/sbin/update" which causes a daemon called bdflush to run. In fact if you type "man update" you will most likely get a man page about the daemon bdflush. This deamon starts the kernel daemon to flush dirty buffers back to disk. There is a kernel function that does most of the work and bdflush forks a new process which calls the kernel function that will never return. What is meant by dirty buffers, is memory pages, or virtual memory pages that have been changed, but not saved to the swap disk. I'm glad that's cleaned up!