Tuesday, 11 January 2000
James Andrews <email@example.com>
1/1 - [Std View]
How Linux Boots
When you turn on your computer, it will take a few seconds or even a few minutes to begin normal operations. The operating system loads up dozens of programs to check and setup before the user takes control. We will look at how this works under linux below.
The Boot Loader
The first event after the bios has checked the hardware in a basic way is the first real program loaded off the hard disk. If you are booting a linux based system, this is usually a boot loader like grub or lilo. We will just look at lilo in this article.
The Kernel and Kernel Devices
In the normal course of events, lilo just loads the kernel. The kernel is, in a real sense, linux itself. It provides all the core services to the rest of the system and it is always running. Next some speed tests are performed on the machine and the kernel starts to load up device drivers. Device drivers in linux are the way that the user interacts with any kind of hardware. An example is the Ethernet card driver that lets linux talk to your Ethernet hardware. There are usually device drivers available for all hardware. There are two main exceptions to this rule. First, new revisions of some cards or board use different chipsets then old ones. The new software to control them has still to be written and tested by the linux community. Secondly, there can be problems with device drivers when the manufacturers refuse to release details of how their hardware works. In the normal course of events the kernel will detect the hardware and load all appropriate device drivers.
inittab and Running Services at Startup
The Apple fans reading this are probably thinking, "Device drivers are like the stuff in the Systems Extension Folder, so next is something like running the System Startup programs" -- but Linux is a little more complex. There are in effect a series of startup folders. The basic idea is that the most basic services are setup first and then more complex ones follow. For instance, consider Internet services as an example. First the Ethernet is configured with the machine's address via the driver that was loaded earlier. Following this, the rest of the basic setup occurs. For an Ethernet card this will include setting the IP address via the ifconfig command. At the next stage of system startup, a WWW server that uses the Internet address set up in the previous stage will run. With complex software, the order is important. Linux makes it clear what system features are loaded first making it easier for the linux professional to solve problems in the system.
Tools for Configuring inittab
There is a master control file for the order in which the different system startup folders are executed. This is called /etc/inittab. We use tools like chkconfig for seeing what services are enabled at which level in the inittab file. You can simply look at it with an ordinary editor.
If you are running a window manager, there is a special run level for starting X windows which is used to run all the necessary programs to support this. Window managers have system wide, and per user, start up scripts that can be customized.
Login and Shells
Let's take stock: the system is up and running. All those services are ready. Can the user use all that power yet? No, you must login.
There are plenty of services ( like web access via a WWW client ) that work without login. But many services that linux offers are best accessed via the shell. To start a shell the user must type a user name and password. This is checked against the system password file and then a shell is started. A shell is similar to the MSDOS command prompt that you may have seen but it is more powerful as literally hundreds of commands available. The shell runs a number of startup files on login. These include system wide shell startup files and files that can be altered by the individual user with effecting everyone else.
Linux startup happens surprisingly quickly despite the apparent complexity. Also each stage of the startup is full documented and it is easy to trace things happening via the system logs. Most users need not worry about the system startup. Packages that need to run as the system powers up will have scripts provided by the package manager to install them correctly. The shell initialization files or window manager configuration files are usually the place for tweaking your system settings. If you have to alter some internals of the linux system, the whole system is easy to follow.
This article graciously provided by LinuxPlanet