LINUX BOOT PROCESS
When a system is booted ,Processor executed a code from a well-known location known as BIOS(Basic Input Output System) which is stored in flash memory of motherboard. Its Job is to find the boot device.
When boot device is found ,FIRST stage boot loader is loaded into the RAM and executed. This Boot Loader is 512bytes in size. Its job is to find the SECOND order Boot Loader.
When the second-stage boot loader is in RAM and executing, upon this Linux and an optional initial RAM disk (temporary root file system) are loaded into memory. When the images are loaded, the second-stage boot loader passes control to the kernel image and the kernel is decompressed and initialized. At this stage, the second-stage boot loader checks the system hardware, enumerates the attached hardware devices, mounts the root device,and then loads the necessary kernel modules. When complete, the first user-space program (init)starts, and high-level system initialization is performed.
What BIOS do during startup?
In a PC, booting Linux begins in the BIOS at an specific address(like 0xFFFF0).
The first step of the BIOS is the power-on self test (POST). The job of the POST is to perform a check of the hardware. The second step of the BIOS is local device enumeration and initialization.
To boot an operating system, the BIOS runtime searches for devices that are both active and bootable . A boot device can be a floppy disk, a CD-ROM etc.
Commonly, Linux is booted from a hard disk, where the Master Boot Record (MBR) contains the primary boot loader.
What STAGE 1 boot loader do?
The primary boot loader that resides in the MBR is a 512-byte image containing both program code and a small partition table. The first 446 bytes are the primary boot loader,which contains both executable code and error message text. The next sixty-four bytes are the partition table, which contains a record for each of four partitions (sixteen bytes each). The MBR ends with two bytes that are defined as the magic number. This number serves as a validation check of the MBR.
What STAGE-2 boot loader do?
The secondary, or second-stage, boot loader could be more aptly called the kernel loader. The task at this stage is to load the Linux kernel and optional initial RAM disk.
The first- and second-stage boot loaders combined are called Linux Loader (LILO) or GRandUnified Bootloader (GRUB) in the x86 PC environment
After After the kernel is booted and initialized, the kernel starts the first user-space application that is init. This is the first program invoked that is compiled with the standard C library.