Linux

The boot sequence under Linux is very different from the boot sequence under Windows. Besides, under Linux there are two boot loaders – GRUB (GNU GRand Unified Bootloader) and LILO (LInux LOader). LILO is the older boot loader but it is still used by some distros, while GRUB is newer and more and more distros use it. There are some slight differences in the boot procedure between the two boot loaders and also among distros but the major steps, which are described next, are the same for all Linux distros.

Basically, the procedure involves starting the OS loader, which locates the kernel image on disk. Then the boot loader loads the kernel into memory and starts it. After that the kernel initializes the devices and their drivers, mounts the file system and starts the init program. The init program, in turn, starts the rest of the processes, including the process that allows the user to login. In many distros on screen messages inform you what is going on at any moment of the boot sequence. In more details, here is what happens:

OS Loader. As already mentioned, the MBR is responsible to tell the BIOS which operating system to load. But the tiny size of the MBR (512 bytes) does not allow the OS loader itself to reside there. Instead, the primary loader is in the MBR but its function is only to provide information about the location of the secondary loader, which is located on the specified disk partition. Thus, LILO and GRUB can be installed on the primary (DOS) loader, which will be pointing to them and everything works just fine – when you select them from the boot screen, they start, locate the kernel and load it. Very often it is possible to configure the boot loader to load an alternative kernel or to pass additional parameters to it.

Kernel startup. After the OS loader has loaded the kernel in memory, the kernel initializes the devices (i.e. loads their drivers) and you will see the messages about that on screen. Then the kernel starts the swapper and mounts the root file system. It is possible to pass parameters that override the default file system and mount another one. Right after the root file system has been mounted, the kernel starts the init process and then it starts the system services.

init and inittab. The init process is the first process that the kernel starts and because of this it always had PID=1. After the init process is started, it reads /etc/inittab for ruther instructions what to load. inittab defines what should be run in different runlevels. Runlevel is a key concept in the Linux boot process because each of the 7 runlevels (from 0 to 6) define a different set of services that need to be started. Each runlevel has a separate directory (under the /etc/rc.d/ directory) with many boot scripts that are to be executed, when the particular runlevel is selected.

Boot scripts. The location of the boot scripts directory and their structure differs between the distros, so you’d better consult the documentation of your distro, if you can’t find the scripts directory right away. Runlevels and boot scripts provide incredible flexibility in customizing the Linux boot process. Boot scripts define at least the start and stop options for a particular service, though very often it is possible to pass the service additional commands and parameters and to define the sequence in which services will be started. The last service that is started is the login process, which presents the user with a login screen (or prompt, if you are using a non-graphical environment).

Describing the Linux boot sequence is more details is outside the scope of this article, so if you need more information about the process in general or about the process for a particular distro, see the Linux Documentation Project or the documentation of your distro. There you can read how to configure GRUB and LILO, what options are available for passing, what is the meaning of each of the runlevels and how to configure them, what kinds of modifications are possible for the boot scripts, etc.