Wednesday, January 13, 2010

Linux Kernel Boot Process In Brief

A brief description of the internals of Linux kernel boot on a PC.

BIOS finds the boot device and loads the Master Boot Record (MBR). The first 512 bytes in MBR contains the "primary boot loader". Out of the 512 bytes, 446 bytes contains the "primary boot loader" proper, the next 64 bytes contains a partition table, and last two bytes will contain the magic number OxAA55 which acts as a simple validation check.

Stage 1 Boot Loader (Primary Boot Loader):-
Find active partition from the partition table (the 64 bytes in MBR)
Execute the active partition's boot record to load the secondary boot loader (LILO, GRUB, etc.)

Stage 2 Boot Loader (Secondary Boot Loader):-
Read secondary boot loader configuration file (for GRUB this is /etc/grub.conf)
Load default kernel image and initrd image into memory
Invoke the kernel image

Kernel Loading and Initialization:-
start() ./arch/{arch}/boot/head.S
startup_32() ./arch/{arch}/boot/compressed/head.S
decompress_kernel() ./arch/{arch}/boot/compressed/misc.c
startup_32() ./arch/{arch}/kernel/head.S
start_kernel() init/main.c
kernel_thread() arch/{arch}/kernel/process.c
rest_init() init/main.c This creates the first process (PID zero)

An excellent article that explains the process in more detail could be found here.

1 comment:

  1. thanks ,your explanation about boot loader helping in completing the task