When you, as a user, initiate the system by pressing the power button, the sequence of events that transpires between that act and the emergence of the login screen on your monitor is a fascinating journey worth exploring.

Have you ever pondered the intricate orchestration occurring behind the scenes from the moment your finger engages the power button until the login screen graces your display?

This intricate dance is none other than the booting process, a meticulously orchestrated sequence of operations that unfolds methodically, ultimately culminating in the presentation of your operating system’s login screen.

In the following discourse, we shall embark on a comprehensive exploration of the Linux boot process. This journey will unveil the intricate steps that transpire from the initial power button press to the gratifying sight of the login screen, providing you with a profound understanding of the Linux booting sequence.

Stage 1: BIOS – The Foundation of Linux Boot Process

BIOS, the Crucial Kickstart

At the very heart of the Linux boot process stands BIOS, or the Basic Input/Output System. BIOS is more than just a mere acronym; it’s the foundational element responsible for initializing your computer’s hardware and setting the stage for Linux to come to life. Here’s a comprehensive breakdown of this crucial first step:

Key Responsibilities of BIOS:

  • Hardware Initialization: BIOS is the first point of contact between your hardware components and the software world. It initializes and conducts checks on essential hardware like the CPU, RAM, and motherboard;
  • Boot Loader Quest: BIOS has a mission – to hunt down the elusive boot loader program (GRUB, LILO) and hand over control to it. But where does it search?;
  • Boot Device Hierarchy: BIOS isn’t content with a single route. It scours multiple locations, including floppy disks, CD-ROMs, and hard drives, to locate the boot loader program;
  • Tailored Startup Sequence: Empowering users with the ability to modify the startup sequence via the BIOS setup at the commencement of the system. This remarkable adaptability bestows upon you the capability to designate the primary bootable device to be scanned first, thereby facilitating effortless transitions between diverse operating systems or diagnostic utilities.

After the discovery and loading of the boot loader program into memory, the BIOS elegantly transitions control to the booting loader residing in the Master Boot Record (MBR).

Stage 2: MBR – The Gatekeeper of the Boot Process

Master Boot Record: Where Booting Magic Begins

MBR, or Master Boot Record, takes center stage in the Linux boot process after BIOS has laid the groundwork. This is where the real booting magic begins. Here’s a detailed look at MBR:

MBR’s Residence: You’ll find MBR residing in the first sector of your bootable drive, typically /dev/had or /dev/sda. It’s a tiny but mighty piece of software, consuming a mere 512 bytes.

Anatomy of MBR:

  • Primary Boot Loader: The first 446 bytes of MBR are dedicated to storing essential information about the primary boot loader;
  • Partition Table: Following this, the next 64 bytes are reserved for partition table information;
  • MBR Validation: The final 2 bytes are allocated for MBR validation checks, ensuring its integrity;
  • Gatekeeper of Boot Loaders: MBR doesn’t discriminate; it can hold information about various boot loaders. In our Linux scenario, it houses critical details about the GRUB boot loader.

In essence, MBR’s primary role is to load and execute the GRUB loader, marking the transition to the next stage of the boot process.

Stage 3: GRUB – The Versatile Grand Unified Bootloader

GRUB – The Maestro of Boot Options

GRUB, which stands for Grand Unified Bootloader, takes the helm after BIOS and MBR, orchestrating the booting process with finesse. It’s much more than a mere loader; it’s a versatile tool for managing your operating system choices. Dive into the world of GRUB:

  • Keeper of OS Knowledge: GRUB holds a repository of information about your operating system images, making it your go-to guide for booting choices;
  • Multi-OS Management: If you’re running more than one operating system on your computer, GRUB plays traffic cop, listing all the available entries. It even lets you set a default OS for those times when you don’t make a choice;
  • User Interaction: GRUB welcomes you with a splash screen during system boot, patiently waiting for a few seconds to see if you have a preference. If you don’t make a selection, it obediently loads the default kernel image, as configured in the grub configuration file;
  • Proficient in File Systems: GRUB exhibits a profound familiarity with your operating system’s file structure. It deftly navigates through it, guaranteeing a seamless transition to the kernel and initrd;
  • Exploring the GRUB Configuration: As we delve further into the realm of GRUB, we unveil its configuration file snugly situated at “/boot/grub/grub.conf.” 

Now, let’s embark on an analysis of a representative segment within this file:

#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (7.2.18-324.el5PAE)
          root (hd0,0)
          kernel /boot/vmlinuz-7.2.18-324.el5PAE ro root=LABEL=/
          initrd /boot/initrd-7.2.18-324.el5PAE.img

Key Elements in the Configuration File:

  • Default Selection: You can set the default operating system to boot into;
  • Timeout: Configure the time GRUB waits for user input before proceeding with the default;
  • Splash Screen: Customize the splash screen displayed during boot;
  • Hidden Menu: Hide the GRUB menu by default (useful for advanced users);
  • Kernel and Initrd: These lines contain vital information about the kernel and initrd images.

In essence, GRUB’s primary role is to load and execute these kernel and initrd images, paving the way for your Linux operating system to spring to life.

Stage 4: The Kernel Phase

At the core of the Linux operating system lies the kernel. Once it gets loaded, it takes charge of several crucial tasks. One of its main responsibilities is to mount the root file system, which is essential for the system’s operation. Immediately after this, the kernel seeks and initiates the execution of the /sbin/init program. This program holds a special distinction in the Linux world; it’s the very first program that the Linux kernel runs post its bootup. Consequently, this program has a unique process id (PID) of ‘1’. A user can verify this PID by executing the command:

# ps –ef | grep init

Also, it’s worth noting that the term “initrd” is an abbreviation for “Initial RAM Disk”.

Stage 5: The Init Phase

The next phase is the Init phase, which involves Linux determining its operational status or run level. It does this by referencing the /etc/inittab file. Inside this file, there are several potential run levels defined:

  1. System halt;
  2. Single-user mode, usually for administrative tasks;
  3. Multiuser mode, but without Network File System (NFS) services;
  4. Full multiuser mode with most services running;
  5. This level is unused and is reserved for special purposes or future uses;
  6. Graphical mode with X11, often used for desktop environments;
  7. System reboot.

Based on the configuration, Init identifies the default run level from the /etc/inittab file and subsequently triggers the programs associated with that specific level. If a user wishes to identify their system’s default run level, they can do so using:

$ grep initdefault /etc/inittab

Stage 6: Runlevel Execution

Upon determining the default run level, the system then commences the appropriate services and applications for that particular level. Depending on the identified run level, the system refers to specific directories:

Level 0: /etc/rc.d/rc0.d/
Level 1: /etc/rc.d/rc1.d/
... and so forth up to Level 6.

Interestingly, within the /etc directory, symbolic links exist that redirect from, for example, /etc/rc0.d to /etc/rc.d/rc0.d.

Process of linux boot

Each directory associated with a run level contains programs prefixed by either ‘S’ or ‘K’. ‘S’ indicates a program utilized during the system’s startup, with ‘S’ representing “startup”. On the other hand, ‘K’ marks programs used during the system shutdown, where ‘K’ signifies “kill”. Notably, numbers follow these prefixes, denoting the sequence in which these programs activate or terminate.

The intricate combination of these six stages seamlessly comes into play each time a system powers on, painting a comprehensive picture of the meticulous process underlying a system’s boot.

FAQ

What exactly is BIOS (Basic Input/Output System)?

BIOS is the inaugural software that runs when a computer is powered on. It is responsible for managing and coordinating vital hardware components like memory, graphics cards, storage devices, and more. Furthermore, it offers foundational I/O functionalities, including reading data from storage mediums, rendering text on the display, and overseeing keyboard operations.

Can you explain how BIOS operates?

Upon powering up a computer, the initial code that springs into action is the Basic Input/Output System, often abbreviated as BIOS. This indispensable piece of software serves the crucial role of orchestrating the seamless loading of the operating system into the computer’s memory, subsequently kickstarting the boot-up process from the hard disk. Once the operating system is operational, the BIOS embarks on a comprehensive examination of the hardware, diligently searching for any potential irregularities or malfunctions. It scrutinizes elements such as RAM modules and power components, evaluating their reliability and functionality. Should any issues or discrepancies arise during this meticulous inspection, the BIOS promptly communicates them by displaying error notifications on the screen, patiently awaiting resolution.

What precisely are the four pivotal roles carried out by the BIOS?

The BIOS plays a multifaceted role in the computer’s operation, encompassing the initiationof the system, the orchestration of the operating system’s initiation, the discernment of hardware components, and the establishment of configuration settings. Should any of these essential functions falter, the computer’s functionality as a whole will come to an abrupt halt. Exploring the BIOS interface involves a couple of methods:
One option is to press the F2 key as your computer starts up. Alternatively, you can gain entry to the BIOS by maintaining pressure on the Delete key as you power on the computer.

What exactly constitutes the MBR, or Master Boot Record?

The MBR, or Master Boot Record, constitutes the inaugural sector within a computer’s hard drive master boot record. Within this sector resides vital information pertaining to the subsequent operating system that requires loading. Should any anomalies arise during the process of software loading from the MBR, the computer runs the risk of experiencing a system crash.

What Exactly is Grub?

Grub, a command-line tool, serves as a valuable aid in simplifying the startup procedure for multiple operating systems present on a computer. Beyond just streamlining the booting sequence, it grants users the authority to customize the default choice of the operating system that loads. The origins of Grub can be pinpointed to the 1980s era.

Grub vs. Grub2: What Sets Them Apart?

While the distinction between Grub and Grub2 might appear subtle at first, there are notable differences. Foremost, Grub2 has undergone a comprehensive overhaul, implying that it wasn’t merely an upgrade to Grub1 but rather a reimagining. This overhaul paved the way for innovative features exclusive to Grub2. Furthermore, unlike its predecessor, Grub2 incorporates the systemd framework to initiate and oversee Linux-based systems.

What exactly constitutes the Linux kernel?

The Linux Kernel stands as the fundamental heart of the operating system for any computer that runs on the Linux OS. It is the bedrock upon which the entire system is built, responsible for an array of critical functionalities encompassing memory administration, task scheduling, input/output procedures, file system management, network connectivity, and the orchestration of device drivers, among its manifold responsibilities.

What does “init” mean in the context of Linux?

In the realm of Linux, “init” stands as a critical process that springs to life during the boot-up phase. Its primary role encompasses a multitude of crucial system initialization duties. These encompass tasks such as the loading of essential modules indispensable for rudimentary system functions, the commencement of daemons and sundry other processes, as well as the execution of any necessary, one-off inaugural procedures.

Conclusion

In this informative piece, you’ve been taken on a comprehensive journey through the intricate stages of the Linux boot process. Along this enlightening path, you’ve gained insights into various pivotal booting components such as BIOS, MBR, GRUB, Kernel, INIT, and Runlevels.

Furthermore, you’ve been presented with a meticulously laid-out depiction of the Linux Operating System’s boot process. You now possess a deep understanding of the seamless orchestration that allows your Linux system to spring to life, ultimately leading you to the welcoming login screen.

Should any lingering questions about the Linux boot process linger in your mind, rest assured that our FAQ section is at your disposal. Feel free to engage with us in the comment section, where your inquiries are always welcomed and promptly addressed.