The first step of the boot process is the BIOS (Basic Input Output System).
1. BIOS – Basic Input/Output System
- Performs system integrity checks
- Initializes hardware, detecting drives, USB, CD-ROMs, network cards, and any other hardware.
- Searches, loads, and executes the boot loader program.
- Go step-by-step through each boot device based on the boot device order it is configured to follow until it finds one it can successfully boot from.
- It does this by scanning the PCIe peripheral bus.
- In a Linux server, it means reading the MBR (master boot record: the first 512 bytes on a hard drive) and loading and executing the boot code inside the MBR to start the boot process.
- BIOS loads and executes the MBR boot loader
2. MBR – Master Boot Record
- After the BIOS initializes the hardware and finds the first device to boot, the boot loader takes over.
- It is located in the 1st sector of the bootable disk. :/dev/hda, or /dev/sda
- MBR is less than 512 bytes in size.
- This has three components
1) primary boot loader info in 1st 446 bytes
2) partition table info in next 64 bytes
3) mbr validation check in last 2 bytes. - It contains information about GRUB
- MBR loads and executes the GRUB boot loader.
The following list shows the boot loader depending on the device from a boot starts:
GRUB : boot from a hard drive
syslinux : boot from a USB
isolinux : boot from a CD-ROM
pxelinux : boot from a network
3. GRUB – Grand Unified Bootloader
- Chooses the kernel images to be executed out of multiple ones.
- If you don’t select on the splash screen, it loads the default kernel image as specified in the grub configuration file.
- GRUB has the knowledge of the filesystem
- The GRUB info contains kernel and initrd image
- The function of GRUB is to get the Linux kernel loaded into memory and running.
- GRUB loads and executes Kernel and initrd images.
4. Kernel
- Kernel handles OS processes, such as memory management, task scheduling, I/O, interprocess communication, and overall system control.
- Kernels are located in the /boot directory, along with an initial RAM disk image, and device maps of the hard drives.
- Kernels are in a self-extracting, compressed format to save space.
- It is loaded as a compressed image file into memory, decompressed, and a few fundamental functions
- They include memory management, detecting CPU, interrupt handling
- It mounts the root file system as specified in the “root=” in grub.conf
- It executes the /sbin/init program
- init was the 1st program to be executed by Linux Kernel so PID of init is “1”
- The kernel also mounts the initial RAM disk that was loaded previously as the temporary root file system during the boot phase.
- initrd (Initial RAM Disk) is used by kernel as temporary root file system until kernel is booted and the real root file system is mounted.
- initrd has some crucial configuration files, kernel modules, and programs that the kernel needs in order to find and mount the real root file system.
5. Init
- init is the parent of all processes on the system and it takes over the boot process
- It establishes and operates the entire user space.
- Starting up necessary user services, and switching to a user-environment when system startup is completed.
- Looks at the /etc/inittab file to decide the Linux run level
- 0-6: halt, Single user mode, Multiuser(without NFS), Full multiuser mode, unused, X11, reboot
- identifies the default initlevel from /etc/inittab and uses that to load all appropriate program.
6. Systemd
- Like init, systemd is a daemon that manages other daemons.
- All daemons, including systemd, are background processes.
- Systemd is the first daemon to start (during booting) and the last daemon to terminate
Runlevel programs
- Depending on your default init level setting, the system will execute the programs from its run level directories
- Programs start with S are used during startup. S for the startup.
- Programs start with K are used during shutdown. K for the kill.