Booting process in CentOS7

PatChanida L.
3 min readNov 6, 2017

--

Booting process in Linux system is important thing to understand for solve the troubleshoot problem. This content describes How is boot process work.

Figure below describes basic boot stages and what happens during each boot stage

BIOS

  • The BIOS (Basic Input/Output System), performs the POST (power on self test) to detect, test and initialize system hardware components.
  • Loads the MBR (Master boot record).
  • If some hardware broke,System will notice.
  • Once the boot loader program is detected and loaded into the memory, BIOS gives the control to it.
  • So, in simple terms BIOS loads and executes the MBR boot loader.

MBR

  • Master Boot Record (MBR) is the first sector of disk. It’s at first 512 bytes of the boot drive that is read into memory by the BIOS. Like the figure below in 512 are 446 bytes is data of boot loader, 64 bytes contain the partition table for the disk and the last 2 bytes are the “Magic Number” which is used for error detection in sector.
  • MBR discovers the bootable device and loads the GRUB2 boot loader into memory and transfers control over to it.
  • So, in simple terms MBR loads and executes the GRUB boot loader.

GRUB2 Bootloader

  • GRUB2 , GRUB stands for GRand Unified Bootloader. GRUB2 is default boot loader program in CentOS/RHEL7. This replaces the older version GRUB bootloader also called as legacy GRUB.
  • GRUB2 have configuration file that located at /boot/grub2/grub.cfg (Do not edit this file directly).
  • GRUB2 menu-configuration settings are taken from /etc/default/grub when generating grub.cfg.
  • It searches the compressed kernel image file also called as vmlinuz in the /boot directory.
  • GRUB2 loads the vmlinuz kernel image file into memory and extracts the contents of the initramfs image file into a temporary, memory-based file system (tmpfs).
  • The initial RAM disk (initrd) is an initial root file system that is mounted before the real root file system.
  • So, in simple terms GRUB just loads and executes Kernel and initrd images.

Kernel

  • Mounts the root file system as specified in the “root=” in grub.conf
  • Kernel executes the /sbin/init program
  • Since init was the 1st program to be executed by Linux Kernel, it has the process id (PID) of 1. Do a ‘ps -ef | grep init’ and check the pid.

Systemd

  • Systemd is the ancestor of all processes on a system.
  • Systemd reads the file linked by /etc/systemd/system/default.target (for example, /usr/lib/systemd/system/multi-user.target) to determine the default system target (equivalent to run level).
  • The system target file defines the services that systemd starts.
  • Systemd brings the system to the state defined by the system target, performing system initialization tasks such as:
    1. Setting the host name
    2. Initializing the network
    3. Initializing SELinux based on its configuration
    4. Printing a welcome banner
    5. Initializing the system hardware based on kernel boot arguments
    6. Mounting the file systems, including virtual file systems such as the /proc file system
    7. Cleaning up directories in /var
    8. Starting swapping

--

--