BOOT PROCESS: The most underrated process.

Whenever I meet an IT/ CS guy they usually ask besides coding/ language is do you know AWS, OpenShift, DevOps? I answer ‘a little bit’. But whenever I ask them “can you please tell me about the Booting Process of operating System”?

The Answer from other side: “he he you are a funny guy. Just power on the computer that's it.”

credit:- giphy.com

What is Booting?

When power button is pressed CPU executes boot code loaded in ROM(read only memory) that is in windows all of you have seen after power on some logo appear or sometimes a loading sign appears. This code to generate these are loaded in ROM.

booting process of LINUX/ UBUNTU

What is System Firmware?

What is BIOS?

To start the operating system, CPU has to read the file where operating system is loaded(usually in Local disk C). But How?

This is how BIOS looks like

BIOS assume that the boot device(hard disk/ SSD) start with the record called Master Boot Record(MBR).

MBR includes first stage boot loader also known as boot block and disk partitioning table.

The space available for boot block is less then 512 bytes(that is less then one sector of hard disk) and it is not enough to perform any task other than the load and run the second stage boot loader. Neither BIOS nor boot block can read any type of file system, it is done by the second stage boot loader.

How you see the hard disk
How BIOS see the the hard disk

Boot block read the partitioning information from the MBR and identifies the disk partition marked as active and then executes the second stage boot loader.

Between MBR and beginning of first partition there is a dead zone where second stage boot loader lies. It is generally knowledgeable about O.S. and File system.

But BIOS is kind of old now and called as legacy BIOS. It is replaced by UEFI.

What is UEFI?

let’s first talk about Legacy BIOS vs UEFI:

BIOS: It supports hard disk up to 2.2 terabytes(due to MBR limitation), uses MBR, needs 16 bit processor and don’t have mouse cursor supports.

UEFI: uses GPT, theoretically supports up to 9.4 zettabytes, can run in 32 bit or 64 bit mode hence allow faster boot process, have secure Boot feature and have mouse cursor support.

Secondly MBR vs GPT?

MBR: It supports hard disk up to 2.2 terabytes, maximum 4 partition of a hard disk is allowed and if want more then have to make a extended partition, can not repair itself because the partitioning and boot data is stored in one place. If this data is overwritten or corrupted, you’re in trouble.

GPT: Supports up to 9.4 zettabytes, maximum partition capacity depends on the operating system(maximum 128 partition for Windows) and stores multiple copies of this data across the disk, so it’s much more robust, can recover if the data is corrupted and also stores cyclic redundancy check (CRC) values to check that its data is intact. If the data is corrupted, GPT can notice the problem and attempt to recover the damaged data from another location on the disk.

What is ESP?

What is Boot Loader?

When kernel’s process is loaded called systemd in Linux with process id(pid) 1 and system in windows with process id 4. Windows doesn’t have pid 1 because in windows process id is always the multiple of 4.

MIcrosoft Windows

Operating system/ Computer is now on.

If something is wrong please let me know in the comment section.

Thank You for reading!

Linux Guy