Boot process of Linux in brief.

Today we will look at the Linux Boot process in brief.

A. Boot Process in Short

Hardware power ON --> BIOS --> POST --> Hard Drive First 512 Bytes --> MBR
GRUB --> Initramfs ---> Kernel --> Init/Systemd --> Runlevel/Targets

 

B. Boot Process in Brief: From GRUB Onwards

GRUB Stage 1: boot.img(512 bytes ==> 446 Bytes Boot Code, 64 Bytes Partition Table, and 2 Bytes Checksum) Sector 0

Stage 1.5: core.img(32,256 Bytes –> Contains FileSystem drivers to refer stage 2) Sector 1-62

Stage 2: /boot/grub –> Contains files to be loaded by GRUB for referencing and booting.

INITRAMFS or INITRD –> After stage 2 grub, initrd(or Initial RAM disk) is loaded in RAM/physical memory.

Kernel or vmlinuz file is loaded in Initrd.

Kernel loads the hardware devices and dracut transfers the control to init/systemd.

init/systemd runs the runlevel startup scripts or Milestone startup scripts.

Runlevel Loaded. (Appropriate services w.r.t particular runlevel is started)


 


Explanation
1. When we press the power button on our CPU or ATX board, the system first detects the BIOS(i.e. Basic Input Output system) which runs POST(Power On Self Test).
2. POST checks/scans all hardware attached to system and transfers the control to first boot device in its settings.
3. If hard drive is selected as First Boot Device, then system will look for its Sector 0 i.e. first sector.
4. Sector 0 contains MBR or Master Boot Record which contains stage 1 of GRUB i.e. Grand Unified Boot Loader.
5. Stage 1 has boot.img file of 512 bytes which is first loaded and stage 2 is loaded on 63 sectors(range 1-62) which is responsible to load stage 2 i.e. /boot/grub files.
6. Once GRUB is loaded, then INITRD or INITRAMFS is loaded on system memory which is responsible to load system kernel.
7. System kernel then loads on INITRD i.e. on initial RAM Disk and then detects the system hardware, and loads the OS services.
8. Once OS is loaded in system RAM, the filesystem is mounted on hard drive by dracut(also called switching root).
9. Once root is switched, kernel starts the first process of the system i.e. init or systemd.
10. Init or systemd is responsible to load runlevel scripts/milestone scripts to start system services in order.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments