Previous Page | Next Page

  1. Introduction
  2. Abbreviated Boot
  3. The Boot Process
  4. Startup and Run Levels
  5. Initialization Scripts
  6. Runlevel Scripts
  7. Login Process
  8. Bash Shell
  9. Filesystems
  10. LILO, Kernel and Root Filesystem
  11. The Kernel
  12. Passwords, Users, Groups, and Quotas
  13. The Environment
  14. The /etc/sysconfig directory
  15. The /proc filesystem
  16. Process Control
  17. Devices
  18. Daemons Services
  19. Inetd and Network Services
  20. Programs and Libraries
  21. Security and PAM
  22. The printer services
  23. Mouse support with gpm
  24. Mail
  25. News
  26. UUCP
  27. LDAP
  28. NFS and RPC
  29. Samba, NetBIOS, WINS, nmbd
  30. Identd (auth)
  31. Telnet and FTP
  32. Apache web server
  33. DNS and named
  34. How X Works
  35. X Scripts
  36. Support for Text
  37. Keymapping for Programs
  38. Keycode Table
  39. Example Keymap File
  40. Terminfo Commands
  41. VT100 ESC sequences
  42. Kernel Revisited
  43. Configuration Files
  44. Credits

Linux Initialization Scripts

Initialization scripts run at startup include "/etc/rc.d/rc.sysinit, and /etc/rc.d/rc. The rc.sysinit script is affected by many system configuration files, some of which are listed below. The rc script file runs many other scripts that brings up many system services such as gdm and cron along with bringing up the network interfaces and other important networking functions.

rc.sysinit System Configuration Files

There are many files which affect the operation of the rc.sysinit script which are system configuration files. Some of them are listed below:

  • /etc/sysconfig/network - Controls the initial network configuration. An example file:
  • /etc/sysconfig/keyboard - The variable KEYTABLE is defined with a line like:


The name "us" may be replaced with a keymap file name such as "/etc/sysconfig/console/mykeymap".

  • /etc/sysconfig/i18n - Controls system fonts
  • /etc/sysconfig/clock - Defines if the clock is UTC or not.
  • /etc/fstab - Controls filesystems mounted at startup.
  • /etc/HOSTNAME
  • /etc/mtab - The mount command records mounted filesystems in this file.
  • /etc/conf.modules -

    The rc.sysinit Program

    This program performs many functions. Some of the most important functions are:

    1. Checking and mounting the filesystem(s).
    2. Loading the keymap.

    A summation to the majority of functions performed by this script are listed below. For more details read the "Linux Startup Reference Manual".

    1. It runs itself through the system logger "initlog" so any abnormal conditions will be reported in the log files.
    2. If the file "/etc/sysconfig/network" exists, it reads it in, but if it doesn't exist, it disables networking . The "/etc/sysconfig/network" file defines your network parameters including HOSTNAME, GATEWAY, DOMAINNAME, and GATEWAYDEV.
    3. Then a file "/etc/rc.d/init.d/functions" is loaded to provide functions to this script file for managing daemons and processes.
    4. The program "/sbin/loglevel" is used to set the initial loglevel which is initially set to 1 in "/etc/rc.d/init.d/functions". I think this has to do with how the kernel handles system logging for each terminal. For more information try typing "man syslogd" and start there.
    5. It sets and loads the keymap for the console. 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.
    6. The system font is loaded by running a script program /sbin/setsysfont. 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".
    7. The swap device specified in the file "/etc/fstab" is enabled for file swapping 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".
    8. The host name and NIS domain name are then set. 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.
    9. The options for the file system check are set up as "fsckoptions". They are set dependant upon whether the files "/fsckoptions" or "/forcefsck" exist. These options are used later in this script file.
    10. If the file "/fastboot" exists, the system filechecking is skipped. The system file checking uses the programs fsck and initlog. 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".
    11. 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. For more information, type "man isapnp", "man isapnp.conf", or "man true".
    12. Then the root filesystem is remounted in read-write mode. Type "man mount" for more information. Note: remount is an option of the program mount.
    13. If an error was corrected in the filesystem above, a quota check is run. This does a filesystems scan for usage of files and directories. Type "man quotacheck", "man quotaon", or "man quotaoff" for more information.
    14. If the file "/etc/HOSTNAME" exists, the hostname from the file "/etc/sysconfig/network" is echoed to it.
    15. The file "/etc/mtab" is cleared. Then the files sytems "/ " (root) and "/proc" are mounted into mtab. Type "man mount" for more information".
    16. The ability to use modules is disabled, if the file "/proc/cmdline" contains the text "nomodules".
    17. Set up soft links for module-info and the 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.
    18. The sound modules are loaded. 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".
    19. RAID devices are added. 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.
    20. File systems are checked again with minor differences between the filesystem check above.
    21. All other filesystems except for NFS and /proc are mounted (they are already mounted). nonfs, smbfs, ncpfs, and proc are mounted.
    22. If the executable file "/sbin/quotaon" exists it is run.
    23. Various files are deleted.
    24. The time of file /var/run/wtmp is updated (See "man touch").
    25. File permissions and groups are changed for "/var/run/utmp" and /var/run/wtmp".
    26. The system clock is set. 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. Type "man swapon" for more information.
    28. The serial ports are initialized. 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). 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.
    31. Set the preferred X display manager link. 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. 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 causes the kernel 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!

    The rc script Program

    The script file /etc/rc.d/rc is run for the appropriate runlevel (typically 3 or 5) This file does the following:

    1. It gets the previous and current system runlevels.
    2. If the word confirm is in the file "/proc/cmdline" if sets up to run the scripts below in user confirmation mode.
    3. All kill files (files whose first letter is 'K') in the subdirectory "/etc/rc.d/rc3.d" (assuming the previous runlevel was 3) are run. The parameter stop is usually passed on the command line to the kill script.
    4. All startup files (files whose first letter is 'S") in the subdirectory "/etc/rc.d/rc5.d" (assuming the current runlevel is 5) are run. The parameter start is usually passed on the command line to the kill script.

    Subsystem Script Programs

    The subsystem script program is usually a softlink to a corresponding program in the "/etc/rc.d/init.d" directory. At the start of a typical subsystem script, checks are done to be sure the service can be run, then depending on whether start, stop, restart, or status was passed on the command line a case statement will take the appropriate action. More is said about these scripts in a later section.

    The rc.local Script Program

    The file "/etc/rc.d/rc3.d/S99.local" is a link file to the file "/etc/rc.d/rc.local". This file doesn't do much except for setting up the "/etc/issue" and "/etc/" files to reflect the system version when a user begins a terminal or telnet session. This is where most administrators will put any system customizations they want to make.