- Abbreviated Boot
- The Boot Process
- Startup and Run Levels
- Initialization Scripts
- Runlevel Scripts
- Login Process
- Bash Shell
- LILO, Kernel and Root Filesystem
- The Kernel
- Passwords, Users, Groups, and Quotas
- The Environment
- The /etc/sysconfig directory
- The /proc filesystem
- Process Control
- Daemons Services
- Inetd and Network Services
- Programs and Libraries
- Security and PAM
- The printer services
- Mouse support with gpm
- NFS and RPC
- Samba, NetBIOS, WINS, nmbd
- Identd (auth)
- Telnet and FTP
- Apache web server
- DNS and named
- How X Works
- X Scripts
- Support for Text
- Keymapping for Programs
- Keycode Table
- Example Keymap File
- Terminfo Commands
- VT100 ESC sequences
- Kernel Revisited
- Configuration Files
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:
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/mtab - The mount command records mounted filesystems in this file.
The rc.sysinit Program
This program performs many functions. Some of the most important functions are:
- Checking and mounting the filesystem(s).
- 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".
- It runs itself through the system logger "initlog" so any abnormal conditions will be reported in the log files.
- 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.
- Then a file "/etc/rc.d/init.d/functions" is loaded to provide functions to this script file for managing daemons and processes.
- 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.
- 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.
- 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".
- 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".
- 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.
- 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.
- 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".
- 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".
- 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.
- 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.
- If the file "/etc/HOSTNAME" exists, the hostname from the file "/etc/sysconfig/network" is echoed to it.
- The file "/etc/mtab" is cleared. Then the files sytems "/ " (root) and "/proc" are mounted into mtab. Type "man mount" for more information".
- The ability to use modules is disabled, if the file "/proc/cmdline" contains the text "nomodules".
- 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.
- 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".
- 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.
- File systems are checked again with minor differences between the filesystem check above.
- All other filesystems except for NFS and /proc are mounted (they are already mounted). nonfs, smbfs, ncpfs, and proc are mounted.
- If the executable file "/sbin/quotaon" exists it is run.
- Various files are deleted.
- 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".
- 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.
- Swap space is turned on. Type "man swapon" for more information.
- The serial ports are initialized. If the file "/etc/rc.d/rc.serial" it is loaded resident. It doesn't exist on my system.
- 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???
- If a SCSI tape is detected, load the st module unconditionally.
- 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.
- 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:
- It gets the previous and current system runlevels.
- If the word confirm is in the file "/proc/cmdline" if sets up to run the scripts below in user confirmation mode.
- 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.
- 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/issue.net" 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.