Since this article was written, many distros have moved away from inittab. See Unix and Linux startup scripts, Part 1.
"Booting the computer", this is a common word associated with starting the computer.
Though we use it casually in our daily life, have you ever thought of
what exactly it is ? or how the system brings itself to a workable
environment ? Well, my attempt in this article is to explain all the stages involved in booting your linux machine. In simple words, "bootstrapping" means starting up your computer. It involves all those stages, from the moment you power on your machine
till the system is ready to log you in.
The Boot process involves several different stages that the system undergoes while it is being booted. If any of these stages fail, then the system cannot start
* The BIOS
* Kernel Initialization
* Hardware Configuration
* System Processes
* Startup Scripts
* Multiuser Mode
Lets look at each of the above stages in detail.
This is the initial stage of the boot process. The moment you power your system, the microprocesser is not aware of your computer environment or even your operating system. It is the BIOS, that provides the necessary instructions to microprocessor and helps to initialize the computer environment. That is why it is called Basic Input/Output System.
These are the main tasks of BIOS.
* POST (Power On Self Test): The BIOS performs a power
on self test on all hardware components attached to the computer
during booting. You might have noticed the LEDs on your keyboard flashing
during booting. That is an example of POST. If anything fails, it will be
reported to you on your screen.
* The BIOS provides a set of low level routines for the
hardware components to interface with the Operating System.
These routines act like drivers for your Screen, Keyboard, Ports etc.
* The BIOS helps to manage the settings of hard disks,
your first boot device, system time and more.
The BIOS also initiates the bootstrapping sequence by loading the Initial
Program Loader (The boot loader program) into the computer memory. The
software is usually stored in the ROM. This stage is actually outside
of the domain of the Operating System and it is more vendor specific.
Linux actually implements a two stage boot process. In the first stage, the BIOS loads the boot program (Initial Program Loader) from the hard disk to the memory. In the second stage, the boot program loads the Operating System kernel vmlinuz into memory. Though we can name the kernel anything of your like, we'll call it vmlinuz. Well, it's just a tradition, where 'vm' stands for the Virtual Memory support and last 'z' denotes that it is a compressed image, ie vmlinux.z => vmlinuz.
When the kernel loads into memory, it performs a memory test.
Most of the kernel data structures are initialized statically. So it
sets aside a part of memory for kernel use. This part of the memory cannot be used by any other processes. It also reports the total amount of physical memory
available and sets aside those for the user processes.
Before explaining how startup scripts work, let's have a look at the
tasks performed by them. The following are the important tasks
performed by startup scripts.
* Set the name of the computer
* Set the time zone
* Check the hard disk with fsck
* Mount system disk
* Remove old files from /tmp partition
* Configure network interfaces with correct IP address
* Startup deamons and other network services
The startup scripts are found in /etc/rc.d/init.d folder in your
You can boot your linux machine to different runlevels. A
runlevel is a software defined configuration of your system where the
system behaviour will vary in different runlevels. Though, linux can
have 10 different runlevels, only 7 of them are used. I have
mentioned them below.
| 1 or S
||single user mode
|2||multiuser mode without nfs
||full multiuser mode
You can specify the runlevel in the init configuration file /etc/inittab.
You may see folders (rc[0-7].d) corresponding to each runlevel in
the /etc folder. These folders contain files symbolically linked (in
linux everything is a file) to the startup scripts in folder
/etc/rc.d/init.d. If you look at these folders, you may see that the
name of the symbolic links starts with the letter "S" or "K" followed by a
number and the name of the startup script /service to which it is linked
For example, the following are the files in runlevel 2 and 3.
/etc/rc2.d/K20nfs -> ../init.d/nfs
/etc/rc2.d/S55named -> ../init.d/named
* switching to higher runlevels - init will run
scripts that start with letter S, in ascending order of the number with
* switching to lower runlevels - init will run scripts that start with letter K, in decending order of the number with argument 'stop'
The commands that deal with runlevels are:
/sbin/runlevel - shows the previous and current
/sbin/init and /sbin/telinit - to switch between runlevels
/sbin/chkconfig - to enable/disable services in runlevels
This runlevel is used by sysadmins to perform routine maintenance.
Its most commonly used for checking errors in file system with command 'fsck'. Only the root file system will be mounted in this
runlevel and the system administrator is provided with a shell. If
necessary, other partitions needs to be mounted manually. Also none
of the deamons will be running in this runlevel. Only the system
administrator can use the system in this mode. You can simply exit
from the shell to boot it to the multiuser mode.
Though the system has been booted to a particular runlevel, none of
the users can login to the system until init spawns getty processes on
terminals. If the system is booted to runlevel 5, init needs to spawn
the graphical login system 'gdm'.
If the system has gone through the above mentioned stages without
any failures, you may say that your system is booted and is ready to
perform the tasks :)
We have discussed about the boot procedure so far. It is also important to shutdown the system properly. Otherwise you may end up with loss of data or serious damage to the file system.
You can safely use the commands /sbin/shutdown,
/usr/bin/halt or /usr/bin/reboot to halt or reboot the computer. For
more details of the commands, refer to the manual pages.
Got something to add? Send me email.
More Articles by Prasad P M © 2015-04-15 Prasad P M