Sitemap

General Boot process — explained

7 min readApr 19, 2024

--

In this post, I hope to discuss the general booting model procedure, which took me longer to comprehend after researching several websites and getting at least the essential details so you won’t have to go through it.

Note: The process explained here is the old school method using BIOS. And there is no strict standards that enforces all the devices to boot in the sameway. It differs with the implementation, technologies, the hardware architecture, etc..,

Tech Terms

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.

BIOS

BIOS stands for Basic Input/Output System, and is software that starts a computer’s system after it is turned on. It is stored on a small memory chip on the motherboard, and is the first software to run when a computer is started.

BIOS is a firmware.

UEFI

Unified Extensible Firmware Interface (UEFI) is a firmware interface that controls the booting process of a PC. It replaced the standard basic input/output system (BIOS) with new features like faster startup and improved security. UEFI is newer and offers more features and benefits than BIOS

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.

Device Drivers

A driver is a software component that lets the operating system and a device communicate. For example, when an app needs to read data from a device, it calls a function implemented by the operating system. The operating system then calls a function implemented by the driver. The driver, usually developed by the device’s manufacturer, knows how to communicate with the device hardware to get the data. Once the driver gets the data, it gives it back to the operating system, which then gives it back to the app.

src

Booting Process

Press enter or click to view image in full size
src

Step 1: Power ON

Step 2: BIOS/UEFI

It runs checks on all the hardware components and prepares them for use by the higher level software. These firmware 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.

Step 2.1

  • 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.

Step 2.2

  • 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”.

Step 3: MBR

Master Boot Record — 1st Stage bootloader

Get Logesh’s stories in your inbox

Join Medium for free to get updates from this writer.

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.

Step by step process

  • 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 the system programs or the operating system.

The conventional MBR code checks the MBR’s partition table for a partition set as bootable (the one with active flag set). If an active partition is found, the MBR code loads the boot sector code from that partition, known as Volume Boot Record (VBR), and executes it. The VBR is often operating system specific while the MBR code is not operating system specific.

In general terms, the MBR code is the first stage boot loader, while the VBR code is the Second-stage boot loader. Second-stage boot loaders, such as GNU GRUB, BOOTMGR, Syslinux, or NTLDR, are not themselves operating systems, but are able to load an operating system properly and transfer execution to it. This is why we said that these codes are operating system specific.

Parts of the MBR

  1. 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.
  2. 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.
  3. 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.
Press enter or click to view image in full size
src

Step 4: VBR

Volume Boot Record — 2nd stage bootloader

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.

Step 5: Kernel

After loading the kernel, bootloader turns over execution to it and the kernel initializes the rest of the operating systems.

Kernel image is also a bin file that gets executed by bootloader. Kernel image formats vary based on compression, architecture, and specific use cases.

In Ubuntu, the Linux kernel image is located in the folder /boot/. The file name is vmlinuz-5.15.0.76-generic

Step 6: init

Kernel then calls the init scripts like SysV or Upstart or Systemd (PID 1) to start all other services.

Hope this post is helpful and educative.

Happie learning

Cheers!

--

--