Table of contents
1.
Introduction
2.
What is Booting Process in Linux?
3.
Stages of Linux Boot Process
3.1.
BIOS: The Starting Point
3.2.
MBR (Master Boot Record)
3.3.
Boot Loader: GRUB
3.4.
Kernel Initialization
3.5.
Init System
3.6.
Runlevel Programs
4.
Frequently Asked Questions
4.1.
What is the first program that runs when a Linux system boots up?
4.2.
What is the role of GRUB in the Linux boot process?
4.3.
What does the init process do in the Linux boot process?
5.
Conclusion
Last Updated: Mar 27, 2024
Easy

Booting Process in Linux

Author Gunjan Batra
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Understanding the Linux boot process can be crucial for troubleshooting and system administration tasks. Each step in this process is vital, working in harmony to transform a system from powered-off to operational.

Booting process in linux

 This article provides an in-depth view of the Linux booting process, breaking down each component for a more comprehensive understanding.

What is Booting Process in Linux?

The Linux booting process begins with the initiation of the BIOS or UEFI, conducting a Power-On Self-Test (POST). The boot loader, such as GRUB or LILO, is then loaded, locating and initiating the Linux kernel. The kernel initializes system components, managing hardware interactions. The init process, or systemd, takes over, launching system services and establishing a functional state. The system enters a specified runlevel or target, defining its operational state. User space is initialized, allowing user applications and services to run, leading to the presentation of a login prompt or graphical interface for user interaction. Understanding this sequence is vital for system administrators and developers.

Also read, Features of linux operating system, Touch command in linux

Stages of Linux Boot Process

BIOS: The Starting Point

BIOS (Basic Input/Output System) is the program a personal computer's microprocessor uses to get the computer system started after you turn it on. It's the first software that runs when a computer is started. It initializes hardware and checks the system integrity using POST (Power-On Self Test).

MBR (Master Boot Record)

The Master Boot Record (MBR) is the initial 512-byte sector on storage devices, facilitating the boot process. It includes the partition table and a boot loader, crucial for locating and loading the operating system. MBR has limitations like supporting a maximum of four partitions. Modern systems often use the GUID Partition Table (GPT) for improved reliability and larger storage support.

Boot Loader: GRUB

After BIOS, the next step is the boot loader. GNU GRUB (Grand Unified Bootloader) is the most widely used bootloader among Linux distributions. It's responsible for loading the kernel into memory and passing control to it.

A simple GRUB configuration file (/boot/grub/grub.cfg) could look like this:


menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    load_video
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='(hd0,msdos1)'
    linux /vmlinuz root=/dev/sda1 ro quiet splash
    initrd /initrd.img
}

Kernel Initialization

The kernel is the core of the Linux system. It initializes the system's memory, configures device drivers, and starts the scheduler to allow processes to run. It also sets up user-space applications to launch.

Init System

After the kernel is loaded, it runs the init process, which is the ancestor of all other processes. In modern Linux distributions, systemd is the default init system. It initializes the rest of the system by starting services and daemons.

A simple systemd service file could look like this:

[Unit]

Description=My Service

[Service]

ExecStart=/usr/bin/my-service

[Install]

WantedBy=multi-user.target

Runlevel Programs

In the Linux boot process, runlevels define the state of the system and the set of services running. Each runlevel represents a different system configuration, and it determines which programs and services will be started. Runlevels help manage the system's mode of operation, whether it's in single-user mode, multi-user mode, or with a graphical interface. Transition between runlevels is often controlled by the init process or its successor, systemd. The selection of runlevels influences which programs and services are executed during the boot process, allowing for customization and flexibility in configuring the Linux system.

Frequently Asked Questions

What is the first program that runs when a Linux system boots up?

The first program that runs when a Linux system boots up is the BIOS.

What is the role of GRUB in the Linux boot process?

GRUB is a boot loader, it loads the Linux kernel into memory and passes control to it.

What does the init process do in the Linux boot process?

The init process (usually systemd in modern Linux distributions) starts services and daemons, initializing the rest of the system.

Conclusion

In conclusion, the Linux boot process is a coordinated sequence of events, from the initial power-on of the system to the final user space initialization. Understanding each step of this process can significantly aid in troubleshooting, system configuration, and overall knowledge of Linux operations. Each component - from BIOS to boot loader, kernel, init process, and user space programs - plays an integral role in making the Linux operating system functional and efficient.

You can also refer to other similar articles.

You may refer to our Guided Path on Code Studios for enhancing your skill set on DSACompetitive ProgrammingSystem Design, etc. Check out essential interview questions, practice our available mock tests, look at the interview bundle for interview preparations, and so much more!

Happy Learning, Ninja!

Live masterclass