What Happens When/During :
Image From Red Hat Linux and SimplyLinux Page

What Happens When/During :

Part 1: During Linux System Boot & Startup

Preface: As part of improving my own general knowledge, I have hit upon the ( Brilliant? Foolish ?) idea of doing a series of "What Happens When/During:". In each part, I will jot down how I understand what transpires BTS ( Behind the Scenes and not the Korean Boy Band, though they totally Rock ). The following article should mostly be correct BUT I would love it if people can fill the gaps in my knowledge and correct my understanding where it's misguided.

Here goes Part 1.

During Linux System Boot & Startup

BOOTing is short for Bootstrapping, ie a process that can progress without the need for external and/or Human intervention.

The Linux BOOT & Startup consists mainly of 4 phases, which can be further subdivided as shown and explained below.

?

?????????? ???? → ????????/???????? → ??????/?????? → ????????2 (?????????? 1 ???????? ???????????? → ?????????? 2 ???????? ????????????) → ???????????? → ?????????????? → ??????????

?

BOOT is described as from switching on till the Kernel is initialized, and startup is just after that ( systemd --switched-root --system --deserialize?starts as PID 1)

???????? ??????????????:

  • ???????? ???????? -->?Power turned on --> Computer runs POST ( Power On Self Test, part of BIOS i.e. Basic I/O System) to check all h/w OK and startable --> It checks the BIOS, RAM, CPU, h/w devices, Storage devices, etc in that Order --> If all OK then locates the first boot sector containing Valid record (MBR)--> Loads it into RAM and passes control over to it
  • ????????? ???????????? --> GRUB2?is the?Boot Loader on most Linux distros nowadays. It can be configured from /boot/grub2/grub.cfg. The primary function is to load Linux Kernel onto the memory

  1. ?????????? 1 --> BIOS POST has loaded the MBR boot record onto the RAM. The bootstrap code image ( boot. img )?is of less than 512 bytes ( ~ 446 bytes TBE )?and it just looks for the next sector where the next GRUB image is located.??This ( stage 1.5? ) has a larger image file located on /boot/grub2/. Contains standard folder structures like EXT/FAT/NTFS etc. Begins execution of the drivers to start Stage 2.
  2. ?????????? 2--> It has to load the right runtime Kernel module from /boot/grub2/vmlinuz*. Stage 2 locates and loads the Linux kernel into the RAM. And passes control over to the Kernel.

?

  • ???????????? ???????????????????????????? --> Kernel Images are in compressed form on the Disk ( /boot/grub2/vmlinuz*). Once the Kernel is loaded into the RAM, it extracts itself from its compressed image ( initrd or initramfs image files ). Once fully extracted and loaded, it mounts the root partition in read-only mode, frees up the memory, and then kicks off systemd.

?????????????? ??????????????:

  • Systemd --> Its job is to startup all filesystems, devices, system services and processes, etc to make the Linux system productive and workable. Systemd mounts the /etc/ and other filesystems. Reads the configuration files from there and starts up the various Devices and Services maintaining dependencies as defined in the config/unit files. It also sets the 'target' ( approx equivalent to run level in SysV init ) through the reading of the *.target file. The target level helps group together and trigger a series of dependencies. E.g. the multi-user.target unit will startup NetworkManager.service and dbus.service etc. The default target is under /etc/systemd/system/default.target


It's ON


PS:--> What Happens When you turn on your Windows Desktop is also almost the same, except for Run Levels and the SysV-Init process that initializes is slightly different from systemd.

J林 .

DevOps SRE TechOps Support

2 年

Thanks for such a detailed post Kaushik!

要查看或添加评论,请登录

Kaushik Banerjee ( He/Him/His )的更多文章

社区洞察

其他会员也浏览了