linux operating system boot process
Posted in Linux By Techy On September 12, 2014Boot process of an operating system such as Linux consists of steps that starts from pressing the switch on button to see a fully functional and operational.
1. BIOS
When an x86 based Linux system is switched on a number of step are performed. BIOS initializes the hardware and checks keyboard, mouse and main memory, this process is called POST (Power On Self Test) .
On mother board of system their is a ROM (Read Only Memory) chip that stores BIOS program. After this process all boot process is handled by O.S.
Master Boot Records (MBR) / Boot Loader
After POST process is completed control is handed over to Boot Loader. Boot loader is usually stored in one of the hard disks in boot sector of MBR or BIOS or EFI / UEFI (Unified Extensible Firmware Interface) partition.
system do not have access to mass storage media till this stage. So from CMOS values system loads date, time and important peripherals information.
The most common Boot Loader for Linux is Grand Unified Boot loader or GRUB, For bootable media ISOLINUX is used. Boot loader is responsible for loading Kernel Image and initial RAM disk that contains critical files and device drivers needed for system start into memory.
Boot Loader Stages
Boot loader has two stages
1. Kernal
2. Initial RAM Disk
First Stage:
In first stage for the systems using BIOS method, Boot Loader resides at Master Boot Record that is first sector of Hard disk whose size is 512 bytes. So boot loader will examine the partition table and finds boot able partition. Now its time to load second stage boot loader that GRUB. GRUB is loaded into RAM.
Systems with UEFI/EFI method, UEFI firmware reads its boot manager data to find which UEFI application is to be launch.
Then it will launch UEFI application such as GRUB. It is a complex but versatile process then traditional MBR processes.
Second Stage:
Second stage boot loader resides in /boot.A Splash Screen is displayed, which allows to choose operating system to boot. When OS is chosen Boot loader will load Kernel of the selected O.S into RAM and control is passed to it.
Kernel are almost always in compressed state so first it will uncomress itself. After this it will analyze the hardware and initialize any device drivers built into kernel.
——–
Boot loader will load both kernel and initial ram based file system (initramfs) into memory so system can use it.
When kernel is loaded to RAM immediately initializes and configure the memory, hardware attached to system. All processors, I/O, storage devices etc.
Initramfs
Initfsram contains the programs and binary files require for mounting of proper root file system. It provides the kernel functionality for the required filesystem and loads the device drivers for mass storage controller with udev (it is required to check whether all devices are present and drivers required for their proper operation. As root file system is found it is checked for errors and is mounted.
After file system is mounted the mount program will instruct the O.S that file system is ready for use and it will be associated to a particular point in file system hierarchy . If this is successful then initramfs is cleared from RAM and init program on /sbin/init is executed.
if kernel has set up all hardware successfully and root filesystem is also mounted, then the kernel executes the /sbininit program. This will become initial process, which then starts other processes to get the system running.
After the boot process almost completes, init process will start a program named getty, that is responsible for login prompt.
Default command shell is bash (Bourne Again Shell).
X-Windows System
Linux desktop system is the x-windows system that is loaded as a final step to boot process. This GUI consists of a session manager, windows manager and set to utilities. If display manager is not started in default runlevel then it can be run by logging int o text mode console and running startx from command line.