Understanding Complete Boot Process In Linux

Ever wondered, what happens behind the scenes to boot Linux? Knowing about what happens from the time you press the power button to the time when you get the login screen on Linux, i.e. boot process in Linux is very important. It can come very handy when you’re debugging why isn’t a system booting properly or even when it refuses to boot completely.

Boot Process in Linux

So, let’s start to understand the boot process in Linux in a step-by-step manner.

1) POST (POWER ON SELF TEST)

When you press the Power Button, the POST operation (Power on Self Test) occurs when BIOS (Basic Input / Output System) initializes the hardware, testing the main memory of your system and looking for all other hardware device including keyboard, screen, mouse etc. The BIOS is actually stored on the ROM ( Read Only Memory) on the Motherboard and after BIOS, all the operation is controlled by the Operating System itself.

2) Boot Loader – First & Second stage Boot Loader

The control from BIOS is then passed to the Boot Loader once the POST operation is completed as explained above. The Boot Loader is actually stored in the boot sector, often the first sector of your disk for BIOS or MBR (Master Boot Records) System . The boot loader then searches for a bootable partition, and once it finds the bootable partition, it transfers control to (second stage) boot loader like GRUB and then loads it into the memory. This process can be carried out by EFI partition for Unified Extensible Firmware Interface (UEFI) systems. These systems reads the Boot Manager data to determine which UEFI application to load and from which partition on the disk. And then it launches the UEFI application like GRUB. This method is complicated yet versatile than the previous MBR method.

The second stage boot loader is found in /boot directory and it presents a UI (splash screen) to the user where they can choose which OS to boot, in case of Multi-Boot system. The main aim of the boot loader is to lead kernel image along with initializing the RAM to load all the device drivers needed to start the system. There are many boot loaders available for Linux. However the most important one include GRUB (Grand Unified Boot Loader) & ISOLINUX.

3) CMOS comes into play

Then the most crucial information about peripherals and current date and time are then loaded form CMOS, which is actually a battery-powered small store capable of storing and keeping track of date and time of the system even when it is turned off.

4) initramfs & Kernel loaded

The boot loader loads the initramfs (initial RAM-based file system) and kernel into the main memory. Once the kernel is loaded into the memory, it configures the hardware that is attached to the system and loads important applications for users.

The initramfs filesystem consists of Program and binary files which is essential for mounting proper root filesystem, providing kernel functionality, locating of devices, locating of drivers for devices and loading them and checking of errors in the root filesystem.

The mount system actually instructs if the filesystem is ready to be used and then associates it with particular point in the overall hierarchy of the filesystem or the mount point. If this step is successfully carried out, then the initramfs would be cleared out from the RAM and then the init program from /sbin/init is executed. The init actually handles the mounting and pivoting of the final root system. This is the initial process of the system which then helps in starting other processes to get system running. If there are special device drivers needed to be accessed, then they must be included in the initramfs image.


 

When you trace the path of origin for the processes, you’ll find all of them originated from init itself expect the kernel process which are started by kernel itself for managing of internal operating system details.


5) Runlevels in Linux

In the traditional System V Unix, there was a sequence of runlevels containing different scripts to start and stop services. There are a total of 6 runlevels:

Runlevel 0

Runlevel 1

Runlevel 2

Runlevel 3

Runlevel 4

Runlevel 5

Within each runlevel, user can set each individual services to run or to shut down (We would understand about RunLevels in detail in the next post). Most distributions are now moving away from this standard of System V standard. init is responsible for system running and shutting it down for cleaning up the non-kernel processes whenever necessary. It also restarts the login services for users as needed when users login and logout.

6) Text-Mode Login

Next, there is a text-mode login prompt started by init (done by program getty). After entering the username and password, user is offered with a command shell which is often (Bourne After Shell) BASH, in most of the linux distros which is ready to take in commands and then execute the operation associated with each command.

7) X Window System

At the end of the boot process, the X Windows system is loaded which starts a display manager, loads x server for the x clients and manage graphical logins by starting with a desktop environment like Gnome, KDE etc. depending on the system.


And Linux is now up and running for use. I hope this would be bit informative for you and would help you. Please let us know your thoughts through comments below.

http://SanyamKhurana.com

1 Comment

  1. how do I install Linux on my windows computer?Please help step by step instructions or any website that shows?

Leave a Reply

Your email address will not be published. Required fields are marked *