Linux Booting Process Explained in 6 Easy Steps
The Linux Booting Process is a sequence from powering on to login prompt involving BIOS checks, MBR loading, GRUB menu, kernel startup, and init launching system services. It ensures proper system readiness for users.
🤖AI Overview:
The Linux Booting Process begins with system power-on and progresses through BIOS checks, the Master Boot Record loading, and the GRUB boot loader. This loads the Linux kernel and initial RAM disk, followed by the kernel starting the init process. Init handles runlevels and services to complete system startup.
List Of The Top 6 Steps In The Linux Boot Process
1 - BIOS 2 - MBR 3 - GRUB 4 - Kernel 5 - Init 6 - Runlevel
Bios boot process
- BIOS stands for Basic Input / Output System.
- It does some health checks to the system.
- The boot loader program searches, loads, and executes.
- To find the boot loader, go to Floppy, CD-ROM, or hard drive. You can press a key to change the boot process while starting the BIOS. (Usually F12 and F2 depending on your system)
- As soon as the boot loader program is detected and loaded into memory, the bios give it control (boot loader).
- So in simple terms, the BIOS loads and executes the MBR boot loader.
MBR boot process
- MBR stands for Master Boot Record.
- MBR is located in the first sector of the bootable disk. It is usually /dev/hda/ or /dev/sda/.
- The MBR size is less than 512 bytes, which has 3 components: 1– Primary boot loader information in the first 446 bytes 2– Partition table
- information in the next 64 bytes. 3– Check or check MBR validation which is done in the last 2 bytes.
- MBR contains information about GRUB (or LILO in older systems).
- So in simple terms, MBR is responsible for loading and running the GRUP boot loader.
GRUB boot process
- GRUB stands for Grand Unified Bootloader.
- If you have multiple kernels installed on your system, you can select one to run.
- GRUB displays the splash page (meaning the operating system logo), waits for a few seconds, if you do not enter anything, Grab itself executes the default kernel specified in its configuration file.
- GRUB has filesystem knowledge. (The old LILO Linux didn’t detect filesystem)
- The GRUB settings file is in the path /boot/grub/grub.conf/ (which is linked to the /etc/grub.conf file)
- Below is an example of the grub.conf file for CentOS
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-194.el5PAE)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-194.el5PAE ro root=LABEL=/
initrd /boot/initrd-2.6.18-194.el5PAE.img
- As you can see in the information above, this file contains the kernel and initrd image.
- So, simply put, GRUB only loads and executes Kernel and initrd image.
Kernel boot process
- The file mounts the root system according to what is specified against “root =” in the grub.conf file.
- Kernel runs the program /sbin/init/.
- Since init was the first program to run by Kernel Linux, it has been the No. 1 process id or PID. Pe -ef | command Run grep init to check the PID.
- initrd stands for Initial RAM Disk.
- initrd is used by the kernel as a temporary root system file until the kernel is booted and the main root file system is mounted. It also
- includes drivers needed to compile itself, which will help it access hard drive partitions or other hardware.
Init boot process
- init examines the /etc/inittab file to decide on the run level in Linux.
- Below you can see the running levels
0 - halt 1 - single user mode 2 - multiuser, without NFS 3 - full multiuser mode 4 - unused 5 - x11 6 - reboot
- init actually identifies the default init level via the /etc/inittab file and uses it to load all the required programs.
- Run the grep –color initdefault/etc/inittab command on your system to see the run level or default execution levels.
- If you want to create trouble for yourself, you can set your default run level to 6 or 0. Since you know the meaning of 0 and 6, you never do that. 🙂
- You may want to set your default run level to 3 or 5.
Runlevel applications
- When the Linux system is booting, you may see various services that are starting up. For example, it may tell you that the Sendmail service was successfully launched. “starting Sendmail… OK,” which are actually run level programs that run from the run level directory (specified by your run level).
- Depending on your default init level settings, the system will run through one of its subroutine directories.
Run level 0 – /etc/rc.d/rc0.d/ Run level 1 – /etc/rc.d/rc1.d/ Run level 2 – /etc/rc.d/rc2.d/ Run level 3 – /etc/rc.d/rc3.d/ Run level 4 – /etc/rc.d/rc4.d/ Run level 5 – /etc/rc.d/rc5.d/ Run level 6 – /etc/rc.d/rc6.d/
- Note that there are also symbolic links directly to the following directories in /etc. So /etc/rc0.d is linked to /etc/rc.d/rc0.d.
“rc0.d -> rc.d / rc0.d“ - In the /etc/rc.d/rc*.d/ directory, you should see programs that started with S and K.
- Programs that start with S are used when the operating system is up. S is for the startup.
- Programs that start with K are used during the shutdown of the operating system. K is for the kill.
- Along with S and K, there are a number of numbers in the program name that indicates the sequence number of the program to be started or killed.
- For example, S12syslog is for starting a Syslog service, whose sequence number is 12. S80sendmail is for starting the Sendmail service, which has sequence number 80. So the Syslog program should start before Sendmail.
Conclusion
Understanding the Linux Booting Process helps beginners appreciate the technical steps that transform powered-off hardware into a fully operational system ready for user interaction. Each stage—from BIOS initializing hardware to init managing system services—is essential for a stable and efficient boot.
When learning Linux, familiarizing yourself with this process can aid troubleshooting and system configuration. For example, problems during boot often relate to one of these stages, such as corrupted GRUB configuration or missing kernel files.
By mastering the Linux Booting Process, you build a strong foundation for deeper Linux administration skills and gain confidence in managing your system.
If you want to experiment with the Linux Booting Process hands-on, consider setting up a virtual private server (VPS) or using virtual machine software to safely explore boot configurations and recovery options.
This clear understanding ensures you know what happens behind the scenes every time you start a Linux machine, preparing you for effective system management now and in the future.
FAQ
2. What role does BIOS play in the Linux Booting Process?
BIOS (Basic Input Output System) performs initial hardware checks and locates the boot loader program. It hands over control to the boot loader after loading it from devices like hard drives, CDs, or USBs.
3. What is the Master Boot Record (MBR) in the Linux Booting Process?
The MBR is a small data sector at the beginning of a bootable disk. It contains the primary boot loader code, the partition table, and validation data. MBR's main function is to load and execute the next stage boot loader, typically GRUB.
4. How does GRUB function in the Linux Booting Process?
GRUB (Grand Unified Bootloader) allows selection between multiple Linux kernels. It displays a menu and loads the chosen kernel along with the initial RAM disk (initrd) image, preparing the system to start the kernel.
5. What happens during the Kernel stage of the Linux Booting Process?
The kernel mounts the root filesystem as specified in its configuration and launches the init process. It manages system resources and hardware, establishing the core of the operating system.
6. What is the purpose of the init process in the Linux Booting Process?
Init is the first process started by the kernel. It reads the "/etc/inittab" file to determine the system runlevel and initiates the necessary services and programs for that runlevel.
7. What are runlevels in the Linux Booting Process?
Runlevels define different modes of operation, like system halt, single user mode, multiuser mode without network, full multiuser with GUI, and reboot. Each runlevel runs specific scripts to start or stop services accordingly.
8. How can I identify the default runlevel in Linux?
The default runlevel is specified in the "/etc/inittab" file. You can check it using the command: "grep initdefault /etc/inittab". This determines which services are started at boot.
9. How does the Linux Booting Process handle system services at startup?
At a defined runlevel, the init process runs scripts located in specific directories, starting services labeled with an S prefix and stopping those with a K. The sequence is controlled by numbers indicating start order.
10. Can the Linux Booting Process be customized?
Yes, users can modify GRUB configuration to change the default kernel or timeout, adjust the default runlevel for different boot modes, and manage startup services by editing runlevel scripts.