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.”
What is Booting?
Booting means starting up a computer. It is a short form of bootstrapping. Bootstrapping usually refers to a self-starting process that is supposed to proceed without external input that is when the power button is pressed CPU starts its own process without any human interference.
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.
What is System Firmware?
System firmware typically knows about all devices that lives on motherboard.
What is BIOS?
BIOS (basic input/output system) is the program that computer’s microprocessor uses to start the computer system after it is powered on. It performs POST (Power on self test) that checks whether all the hardware and connected devices are working well or not. If yes, the process goes on else a beep sound comes during the test. The process can continue after the failure if the device which causes the beep sound is note important for booting. For example Pen drive, micro SD.
To start the operating system, CPU has to read the file where operating system is loaded(usually in Local disk C). But How?
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.
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?
Unified Extensible Firmware Interface (UEFI) includes a modern disk partitioning scheme known as GPT (GUID Partition Table, where GUID stands for “globally unique identifier”). It also understand the File allocation table, these feature combine to define the concept of ESP.
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.
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?
ESP is an O.S. independent partition that act as the storage place for the EF boot loader, application and driver to be launched by the UEFI firmware. It is mandatory for UEFI boot.
What is Boot Loader?
Boot loader main job is to identify and load the kernel of operating system. Kernel is the core of O.S. Windows kernel- Windows NT , Linux kernel- GRUB.
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.
Operating system/ Computer is now on.
If something is wrong please let me know in the comment section.
Thank You for reading!