Linux boot process is the process of starting a Linux computer through to the point where the operating system is fully functional and you can log in. The process involved in booting a Linux machine can be summed up in 6 steps (by me).
The 6 stages of the Linux boot process are:
- UEFI/EFI/BIOS STAGE.
- MBR STAGE
- BOOT LOADER STAGE.
- KERNEL STAGE
- INIT PHASE
- RUN LEVEL PHASE.
(1)UEFI/EFI/BIOS STAGE: UEFI: means Unified Extensible Firmware Interface, EFI-Extensible Firmware Interface, BIOS-Basic Input, and Output System. This firmware is actually designed by the manufacturer of the hardware – the computer on which the Linux operating system was installed. Basic Input and Output System is becoming obsolete as many manufacturers prefer to use UEFI/EFI on their hardware. UEFI is the latest and greatest.
UEFI is expected to phase out EFI in the near future. Well, enough of the story. UEFI/EFI/BIOS is responsible for providing the link between itself(the firmware) and the operating system.
The UEFI/EFI/BIOS starts the boot process.
The UEFI/EFI/BIOS carries out various checks to ensure that the hardware is prepared for the operating system startup, checks like the POST check – Power On Self Test. It is this program that launches the boot loader.
To properly understand what I am saying, imagine that you boot up a windows machine and then press f10 (on some windows systems) to go to startup options and then select the boot menu. The boot menu screen where you are able to select boot from cd, boot from USB, boot from a hard drive is the UEFI/EFI/BIOS Stage.
This is the link or interface that enables you to boot the system or load the boot loader from the desired device.
EXAM PREP: BIOS/UEFI/EFI can also load pxe boots from the networks. Pxe means reboot Execution Environment. It allows you to boot a system using a boot server on the network. The pxe boot server listens to request and when it finds one, it installs the operating system onto the computer directly
Before we get to the Boot Loader stage, there is a little stage called the (2)MBR phase or stage. This stage is simply a sector on the bootable disk that contains some information about the GRUB2 to be loaded into RAM.
Boot Loader: Linux boot loader is GRUB and GRUB2. Grub stands for GRand Unified Bootloader. For
(3)GRand Unified Bootloader: This stage loads the kernel and loads all its associated modules and libraries from a file called initramfs. In centos7 and higher GRUB2 is used while in centos6 and lower, GRUB is used. In order words, GRUB is an outdated form of GRUB2.
From the image above, grub is responsible for loading the kernel and that’s why the grub menu has presented you with 2 versions of the kernel. Use the up and down arrow keys to select the kernel to load and then press enter. You could use the e key to edit the kernel. Let’s try this option and see what we get.
You could also press the c key to enter the grub command prompt.
Grub file can be found and configured at
#nano /etc/default/grub or #cd /etc/grub.d
Grub2 file can be found at
This file should never be edited directly. Even if you try, you will get a permission denied message. Use your sudo powers, and you will still be presented with a series of messages informing you of the power you have in your hands.
The best way to edit this file is to use:
If you are having permission issues, just do a
enter root password
Now try to access #nano /etc/grub2.cfg
Notice that this file gets it settings from the /etc/default/grub and the etc/grub.d files above. So you may prefer to edit grub using those files. For me, I will edit the timeout settings to 10s using the etc/grub2.cfg file.
Reboot your system and it should take exactly 10s before your default kernel is booted into.
Boot files are generally found in the /boot directory including kernel files, initramfs, grub2 directory. You could also find /efi directory in /boot for systems that utilize the legacy efi programs.
CONFIGURATIONS THAT CAN BE MADE ON GRUB/GRUB2 FILES ARE:
- Choose a default kernel to boot into.
- Set the timeout before the default kernel will begin to boot.
- Hide the boot menu
- Add a password to a boot file.
EXAM PREP: NFS – Network file system is loaded by the bootloader and not the BIOS/UEFI/EFI
The (4)kernel is loaded from the hard drive, LUN, software raid, and then control is handed over to the system initialization software which is currently the systemd. This is the (5)init phase and this phase starts the system services.
KERNEL MODULES AND LIBRARIES
These are programs that provide more functionality tot he kernel. We could use some commands to manage these modules:
mkinitrd command: The intiramfs file is created by this command #mkinitrd /boot/initramfs-2.x.x.x.x.img
For Debian based systems, use mkinitramfs to create the initramfs file. These commands call the dracut command indirectly.
Grub2-install: Use this command to repair a corrupt bootloader
Initramfs: This file contains necessary kernel modules that a system requires when booting up. The file is created by mkinitrd and mkinitramfs commands respectively. This file is located in the /boot directory.
vmlinuz: indicates the kernel version. These versions will be created for different versions of files. It is a compressed form of the kernel file.
Grub2-mkconfig – is a command used to create grub and grub2 config files
Vmlinux: is the kernel file itself.
EXAM PREP: When the kernel is corrupt and system crashes, data is saved temporarily in dump. This is usually referred to as kernel panic.
(6)SYSTEM RUNLEVEL: At this stage, the system boots and starts up many services. It is very common at this stage to see
and so on. Different runlevels are involved in starting these services.
run-level 0 is shutdown (init 0)
run-level 1 is single-user mode (init 1 or init S)
run-level 3 is the multiuser mode with networking
run-level 4 is unused
run-level 5 is the multiuser mode with networking and graphical user interface
run-level 6 is reboot (init 6
At this point, you can now log in. To see which run-level you are at simply run the command.
To see these different run levels mentioned above, go to the file
Read more about the Linux boot process here.
Also, read our post on how to install the Linux operating system step by step guide