Booting process
Booting process - Medium article
Notes dump
Booting Process
-
Power on
-
BIOS / UEFI (these are firmwares stored in non-volatile hardware storage(ROM). Boot managers) BIOS (Basic Input Output System) - This software is said to be close to the metal or hardware (GPU, RAM, hard drive, etc…). It runs checks on all these components and prepares them for use by the higher level software. The BIOS is firmware which is to say that it typically resides in a computer chip and not on your hard drive. It is not part of the Operating System. It does not care if you are booting Linux, Windows, or mac OS.
-
POST (Power On Self Test) In order to check the operability of all the hardware connected to our computer system, BIOS carries out POST which will check the hardware components and if any problem is found user is alerted with POST beeps and POST screen messaged.
-
These firmware loads the MBR by checking the bootable devices. If a system is configured to support dual booting (the ability to choose from more than one OS), it is the boot managers that provides this capability to select particular OS(bootable device) and start booting by passing the control to MBR(specific to selected OS) from Boot manager(BIOS/UEFI)
With BIOS, it simply loads and executes the first sector off the disk it decides to boot from, which typically is the first hard disk detected. By convention the first sector of a hard disk, called the Master Boot Record
If MBR is not found in any of them, the system will halt by displaying “No Boot Device Found”.
-
-
MBR (Master Boot Record) - 1st Stage bootloader
Once the BIOS is done doing whatever initialization that it needs to do, it starts the loading process from the system boot device, usually your first hard disk. The first thing that loads is a tiny 512 bytes program called the Master Boot Record (MBR). This program lives in the first sector of your hard drive, and its only job is to determine the bootable partition, and load and execute the first sector of that partition(active partition) (the stage 1 bootloader). Simply, The program in the boot-sector is loaded in memory (1st stage). This tiny program has information which programs should it load into memory next and where that program is located in Disk or Boot device ---
- Read MBR: The BIOS or UEFI firmware reads the first sector (512 bytes) of the selected storage device(OS file) into memory. This sector contains the MBR.
- Boot Code Execution: The 512 bytes of the MBR include a small piece of executable code known as the boot code. This code is executed by the computer’s CPU.
- Partition Table Examination: The MBR contains a partition table that describes the layout of the disk. The boot code examines this table to identify the active (bootable) partition.
- Loading Boot Loader: The boot code then loads the boot loader from the active partition. The boot loader is responsible for loading (2nd stage) the system programs or the operating system.
- Parts of the MBR
-
Bootstrap Code: The Bootstrap Code, often referred to as the boot loader code, is the first part of the Master Boot Record (MBR). It occupies the initial 446 bytes of the MBR. This code is crucial in the boot process as it is executed by the computer’s BIOS or UEFI firmware. Its primary function is to locate and load the operating system’s boot loader, which then continues the booting process.
-
Partition Table: The Partition Table is a 64-byte section within the MBR. It follows the Bootstrap Code and precedes the Master Boot Record Signature. The partition table is divided into four 16-byte entries, each describing a specific partition on the storage device. Information includes the starting and ending addresses of the partition, partition type, and a flag indicating if the partition is bootable (active). The partition table is essential for the operating system to understand the layout of the disk and locate individual partitions.
-
Master Boot Record Signature: The Master Boot Record Signature is a 2-byte value located at the very end of the MBR, specifically at bytes 511 and 512. It consists of the hexadecimal values 0x55AA. This signature is a marker that indicates a valid and bootable MBR. During the boot process, the system checks for this signature to ensure the integrity of the MBR. If the signature is present, it signifies a proper MBR structure, and the system proceeds with the booting process. —
-
-
Boot loader (2nd stage boot loader)
such as GRUB (used by Linux), BOOTMGR (Windows), or BootX (macOS). —
- Once the MBR Boot code is loaded in the memory and executed the corresponding bootloaders(OS sepcific) will load the kernel image (system files)
- Operating System Initialization: The loaded boot loader initializes the kernel image, and control is transferred to the kernel of the operating system.
After loading the kernel, bootloader turns over execution to it and the kernel initializes the rest of the operating systems.
Booting
Booting refers to the process by which a computer initializes its hardware components and loads the operating system into its main memory, making the system ready for operations. It’s the vital transition from a powered-off state to a fully functional system.
Boot Devices
Boot devices are specific hardware components that contain the necessary software to initiate the booting process. These devices, such as hard drives, SSDs, optical drives, or USB drives, store the operating system or boot loader essential for system startup.
Firmware
Firmware is software that is written to a hardware device’s memory. It is used to run user programs on said devices. Firmware is a type of software that is embedded into hardware devices to control their functionality. Unlike traditional software, firmware is not designed to be modified or updated frequently, and it is typically stored in non-volatile memory. It serves as a bridge between the hardware and software layers of a system, allowing the hardware to interact with the operating system and applications.
The firmware’s purpose is to manage specific hardware components. As a result, these are single-purpose codes designed to control a single device. Furthermore, firmware can act as an operating system for simple and less sophisticated systems. Firmware can carry out simple operations and contains low-level programming algorithms. Additionally, it’s limited to controlling specific hardware parts. Every piece of hardware may have a unique set of unaltered codes.
The BIOS (Basic Input/Output System) program is firmware on the motherboard that is programmed to find the operating system (OS) on the boot device specified in the boot order settings
Drivers
links:
- https://people.cs.rutgers.edu/~pxk/416/notes/02-boot.html
- https://gyires.inf.unideb.hu/GyBITT/20/ch02s02.html
- https://www.scaler.com/topics/operating-system/what-is-booting/
- https://www.scaler.com/topics/operating-system/master-boot-record/
- https://www.scaler.com/topics/operating-system/what-is-bios/