If you use a Linux computer, knowing the Linux boot process can help you solve some computer booting errors. In this post, MiniTool Partition Wizard details every stage of the Linux boot process.
To boot a Linux computer, the PC should go through the following processes.
1. BIOS POST
Like Windows booting process, the first step of the Linux boot process is also the BIOS POST. When a Linux computer is powered on, the firmware built in ROM will be woken up. Then, it will do POST to check hardware like CPU, RAM, motherboard, hard drive, etc. If no component fails, the PC will go to the next stage.
In this step, BIOS will first find the bootable device. After finding the bootable device, it will go to the first sector of the device to read the MBR. MBR will tell the BIOS the location of GRUB (GRand Unified Bootloader). And then the GRUB will be loaded to RAM for running. Now, BIOS has turned the control of the computer over to GRUB.
The GRUB has OS information recorded. It will find and load the OS kernel into memory to execute. Now GRUB has turned the computer control over to the kernel, which is often referred to as the core of any operating system.
At the same time, GRUB will also load initrd/initramfs into RAM for running. The initrd/initramfs file is actually a virtual root file system, which has directories such as bin, lib, lib64, sys, var, etc, sysroot, dev, proc, tmp, etc. Its function is to establish a connection between the kernel and the real root file system.
The kernel will do the following things:
- Detect the hardware
- Load the driver of the root file system through the initrd/initramfs file
- Mount the root file system in read-write mode
- And run /sbin/init to complete the system initialization
In this stage, the init process will execute the /etc/rc.d/rcS.conf script to call /etc/rc.d/rc.sysinit. This process will do the following things:
- Get the network environment
- Mount the device
- Boot screen Plymouth
- Determine whether to enable SELinux
- Display the welcome screen
- Initialize the hardware
- Load user-defined modules
- Configure the parameters of the kernel
- Set the host name
- Sync memory
- Initialize device mapper and related devices
- Initialize the software disk array (RAID)
- Initialize the file system function of LVM
- Check the disk file system (fsck)
- Set disk quota
- Re-mount the system disk in read-write mode
- Update quota (not necessary)
- Start the system virtual random number generator
- Configure the machine (not necessary)
- Clear temporary files during the boot process
- Create an ICE directory
- Start the swap partition
- Write the boot information into the /var/log/dmesg file
After executing /etc/rc.d/rc.sysinit, the init will execute /etc/inittab to determine the system operating level. Linux has preset seven run levels (0-6). Generally speaking, 0 is shutdown, 1 is single-user mode (that is, maintenance mode), and 6 is restart. As for run level 2-5, they are multi-user modes (that is, normal mode).
After this step is completed, you can log into your computer for using the Linux OS.