Thursday, December 22, 2022

Linux Boot Process

 As a user, when you press the power button of system, you get the login screen on your monitor and after login starts working.

Have you ever think what is going between you press power button and login screen appear?

There is a booting process for any operating system which executed one-by-one, and finally, you get the Operating system’s login screen.

Here we go through the Linux boot process step by step. it will helps you to understand the Linux booting sequence from pressing power button to get login screen.

There are six high-level stages for Linux booting process:

  • BIOS – Basic Input/Output System executes MBR
  • MBR – Master Boot Record execute GRUB
  • GRUB – Grand Unified Bootloader executes Kernel
  • Kernel – Kernel executes /sbin/init
  • Init – Init executes runlevel programs
  • Runlevel – Runlevel programs are executed from /etc/rc.d/rc*.
  • Stage 1: BIOS [First step of Linux boot process]

    BIOS stands for Basic Input/Output System. BIOS responsibilities are to search boot loader (GRUB, LILO) program to load and execute it.

    BIOS search boot loader into a floppy, CD-rom, or hard drive. You can change the boot sequence from BIOS setup during BIOS startup.

    When the loader program found and loaded into the memory, BIOS gives the control it. So, BIOS use to loads and execute the MBR booting loader.

  • Stage 2: MBR

    MBR stands for Master Boot Record. It is more important part for Linux Boot process.

    MBR located into the 1st sector of the bootable drive. Generally, /dev/had, or /dev/sda.

    MBR stores in 512 bytes in size, there are three components of MBR.

    • Primary boot loader information stored in 1st 446 bytes
    • Partition table information stored in the next 64 bytes
    • MBR validation check stored in the last 2 bytes.

    MBR stored information about any boot loader; in our case, it is having information about GRUB boot loader.In short MBR loads and executes the GRUB loader.

  • Stage 3: GRUB

    GRUB stands for Grand Unified Bootloader.

    It stores all information about operating system image to load and execute.

    If you have more than one operating system, all entry will be in this GRUB file, and you can choose to make the default one.

  • In short MBR loads and executes the GRUB loader.

    Stage 3: GRUB

    GRUB stands for Grand Unified Bootloader.

    It stores all information about operating system image to load and execute.

    If you have more than one operating system, all entry will be in this GRUB file, and you can choose to make the default one.

  • GRUB display splash screen on system boot and wait for few seconds to get user input to choose the operating system, if you don’t enter anything, it loads the default kernel image as specified in the grub configuration file.

    Grub has the knowledge of the filesystem in your operating system.

    You can find the GRUB configuration file at “/boot/grub/grub.conf,” the sample of file grub.conf is shown below:

  • #boot=/dev/sda default=0 timeout=5 splashimage=(hd0,0)/boot/grub/splash.xpm.gz hiddenmenu title CentOS (7.2.18-324.el5PAE) root (hd0,0) kernel /boot/vmlinuz-7.2.18-324.el5PAE ro root=LABEL=/ initrd /boot/initrd-7.2.18-324.el5PAE.img

  • As you can see in the file, it has information of kernel and initrd image.

  • In simple term GRUB loads and executes Kernel and initrd images.

Stage 4: Kernel

When kernel loads, it mount the root file system and execute /sbin/init program. As init was the first program run by the Linux kernel, it has one(1) as process id (PID), which you can check by using below command:

# ps –ef | grep init

The initrd stands for Initial RAM Disk.


Stage 5: Init

In the Linux boot process, It checks file “/etc/inittab” to decide the Linux run level.

There are seven(7) run levels available with the Linux operating system:

  • 0 – halt
  • 1 – single-user mode
  • 2 – Multiuser, without NFS
  • 3 – Full multiuser mode
  • 4 – unused
  • 5 – X11
  • 6 – reboot

Init will check and identifies the default initlevel from file “/etc/inittab” to load all appropriate program required for the run level.

You can check your system’s configured default run level by executing below command:

$ grep initdefault /etc/inittab

Stage 6: Runlevel

One default run level identified; it will execute all required program for that run level.

The system will check and execute run level programs from the following 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/

There is symbolic linked directory also available in “/etc” directory, /etc/rc0.d is linked to /etc/rc.d/rc0.d and so on.

You can check all program under the directory /etc/rc.d/rc*.d/ which is starting with S and K.

The program which starts with S used during startup. S stands for the startup.

Sample Game App Deployment on EKS cluster

 https://padmakshi.medium.com/setting-up-an-eks-cluster-and-deploying-a-game-application-a-step-by-step-guide-08790e0be117