Tag Archives: linux boot process

RHEL6 boot process

RHEL6 boot process

Understand step by step how RHEL6 system boots. Walkthrough of  RHEL6 boot process which lists all the tasks, activities happen during boot.

Anyone starting to learn Linux must know the boot process of Linux. Here is this post I will be explaining the boot process of Red Hat Enterprise Linux 6 i.e. RHEL6. In brief RHEL6 boot process can be summarized as below :

  1.  Powered on system loads boot loader once it completes POST. The boot loader in turn loads GRUB.
  2. GRUB loads kernel into memory which further loads necessary modules and mount root partition as read-only.
  3. Kernel invokes /sbin/init program and hands it over the boot process.
  4. Init program loads all services as per run level and mounts mount points
  5. The user is presented with a login screen.

Lets see each point in detail to understand RHEL6 boot process properly.

1. Power on and boot loaders:

Whenever the system turned on, it runs POST (Power on self-test) to check all hardware and its operating state. Once POST is cleared, the system runs BIOS. BIOS is a basic input-output system which is the lowest level interface for hardware. BIOS gets loaded in memory and checks system, connected peripherals, boot device path. Lastly, BIOS will load the first sector of the bootable disk in memory which is the MBR master boot record. Once MBR loaded, BIOS hand over boot control to it.

MBR is a small machine code that has a first stage boot loader. The first stage or stage-1 boot loader exists to locate the second stage boot loader and load it in memory only. The second stage or stage-2 boot loader is GRUB. Now boot control is with GRUB.

In UEFI based systems, BIOS is replaced by UEFI. It’s much powerful than BIOS. It has its own architecture, CPU, device drivers. It can mount and read file systems. Such systems have EFI partitions that have EFI’s own boot loaders which can load operating systems or stage-2 boot loaders.

2. GRUB:

GRUB displays a list of available kernels to the user in the graphical interface (like below). Its configuration file is /boot/grub/grub.conf (for BIOS) or /boot/efi/EFI/redhat/grub.conf (for UEFI). Here user can select its kernel to boot using arrow keys and press enter. If not then it will boot default selected kernel when selection time passes out. We can even reset the forgotten root password on this screen.

Once GRUB destined to load the kernel, it searches the kernel binary of it under /boot partition. The boot loader then places one or more appropriate initramfs (Initial RAM file system) images into memory (as seen in the above screenshot). The initramfs is used by the kernel to load drivers and modules necessary to boot the system. Once kernel and initramfs are loaded into memory, boot control is taken by the kernel.

3. Kernel:

Once kernel gets boot control, it quickly run though below tasks:

  • Initialize and configure memory, hardware, and attached peripherals.
  • Decompress initramfs into /sysroot and loads necessary drivers from it
  • Loads virtual devices related to file systems like LVM etc.
  • Free up memory by removing initramfs image
  • Create a root device, mount root partition (read-only)

Now, the kernel is fully loaded and operational. But no services loaded in the system yet so the system is not usable for humans. To load rest of the services kernel calls /sbin/init program and hand it over boot process to him.

4. Init program :

/sbin/init i.e. init process spawns very first in a system with PID 1 and it will be parent process for many system processes or zombie/defunct processes all the time. Init executes and calls various scripts as below :

  • Runs /etc/rc.d/rc.sysinit to start swap, set environment, FS checks, and some system initialization steps.
  • Process jobs in /etc/event.d directory which has run level specific settings
  • Set function library /etc/rc.d/init.d/functions
  • Runs background processes from their respective rc directories. Default specified in /etc/inittabe.g. for run level 3, it will execute /etc/rc.d/rc3.d/ . Mostly rc directories are having symbolic links of start/stop services.
  • Once all processes started in the specified run level, init finishes, and spawns login screen.

5. Login screen:

Once init completes loading RC directories, it forks Upstart which in turns call /sbin/mingettymingetty will be forked for each virtual console. Run level 1 i.e. single user mode has 1 while run level 2 to 5 has 6 virtual consoles. /sbin/mingetty starts communication with tty devices, sets terminal modes, prints login screen (with messages if any), and prompt username to the user!

This completes RHEL6 boot process from power up to login prompt!