Section 14.3. Starting Linux


[Page 578 (continued)]

14.3. Starting Linux

Like most computer systems, when you apply power to a Linux system, it boots. Booting is the process of "bootstrapping" a small program, then another, until the main operating system is loaded and running. If your system has installed a Linux boot loader (LILO or GRUB) into the Master Boot Record (MBR), this program will load Linux and boot it into multi-user mode. For information on boot loaders, see Chapter 2, "Installing Your Linux System."

When you start a Linux system, the following sequence of events occurs:

  1. The hardware performs diagnostic self-tests.

  2. The Linux kernel is loaded from the /boot directory on the root device.

  3. The kernel starts running and initializes itself.

  4. The kernel starts init, the first user-mode process.

14.3.1. The Linux Kernel

The Linux kernel is the core program that runs a Linux system. The kernel is simply a file in the /boot directory on the root drive (maybe in the root file system, or /boot is sometimes in its own partition; see Chapter 2, "Installing Your Linux System," for more information).

The kernel itself is named vmlinuz-version. The version number is generally in the form:

major.minor.build 


Some distributions add their own version information after that. This is not the version of the Linux distribution (which is unique to each vendor) but the version of the Linux kernel included with that distribution. This version is assigned by Linus and the others who produce the kernel itself.

14.3.2. Run Levels

Once booted, a Linux system can run in several different ways. Linux adopts the UNIX System V concept of run levels. Run levels define the desired state of the system. Linux allows 10 run levels (09), although not all of them are used. Each run level can have its own specific boot scripts and can be configured to suit your local needs. For example, you might configure run level 4 to be everything your system normally runs in operational mode except your company's production database application. This would allow you to do database maintenance on the database while allowing the rest of the system to be used normally.


[Page 579]

Run levels are defined in "/etc/inittab." The commonly predefined run levels are:

  • 0halt

  • 1single-user (i.e., maintenance)

  • 2multi-user without networking

  • 3server (full multi-user)

  • 5workstation (full multi-user, graphical login)

  • 6reboot

Depending on your Linux distribution, other run levels could have other meanings.

14.3.3. init

The first user-mode process started after the kernel is init, the parent of all other processes. init's job is to start other programs required on a running system.

init controls the run levels and the specific scripts associated with each run level. These scripts, usually referred to as boot scripts, check system integrity and start required services as appropriate for each run level.

init can be run by the super-user and provided a new run level for the system. init will then run the appropriate scripts to take the system to its new run level, including run level zero, which halts the system.

14.3.4. Boot Scripts

When init is started at boot or run by the super-user, its job is to take the system to a new run level. The normal default when the system boots is run level 5.

The scripts run by init are in the directory "/etc/rc.d" and are organized by run level. The regular files in /etc/rc.d are boot scripts run once at boot time. Names vary between different Linux distributions, but are usually one or more of:

  • rc.sysinit

  • rc.boot

  • rc.modules

  • rc.local (for local additions, runs after all other boot scripts)

Scripts specific to run levels (and symbolic links to scripts when shared by multiple run levels) are stored in subdirectories in /etc/rc.d, named with the number of the run level as rcN.d. In other words, all scripts specific to run level 6 can be found in the "/etc/rc.d/rc6.d" directory. In that directory, you will find scripts whose names begin with either "S" or "K." The "S" scripts are startup scripts, the "K" scripts are kill scripts, which are run when shutting the system down to kill the programs that were started by the "S" scripts.

The scripts for various run levels start (or stop) the appropriate services for each run level. For example, run level 3 startup scripts check the file system consistency using fsck (described later in this chapter) and mount file systems.




Linux for Programmers and Users
Linux for Programmers and Users
ISBN: 0131857487
EAN: 2147483647
Year: 2007
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net