Reference:
Linux boot process
Linux boot process
Introduction to how the computer is started
Each hard disk has at most one MBR, this MBR has 512Bytes, starts with 0x55, 0xAA ends. MBR is divided into 446Bytes and 64Bytes, the former 446Bytes is some boot information, after 64Bytes is the partition table information, each partition has 16Bytes, so there are up to 4 primary partitions. However, there is an extended partition, Linux has a maximum of an extended partition, the extended partition can also have logical partitions, logical partitions Theoretically there is no limit.
Each partition can install an operating system, each operating system starts with a boot loader to start it, the boot loader will be placed in a place called boot sector. That is, at the beginning of each partition there will be a boot sector, which holds the operating system's bootstrapper, that is, the partition boot program. So the MBR will find this boot SECOTR during boot and boot loader. The most common boot loader in Linux is grub.
But what if I have multiple operating systems? The MBR then skips the search for the active partition in the partition table, and instead starts the boot loader, such as grub. Then let us choose which operating system to start.
The control of the computer is then handed over to grub for processing. Boot Loader main function: provide menu. If you have multiple operating systems, then you have the option to enable the boot sector for that operating system. Load into kernel. Start the operating system directly by pointing to a program segment that can be powered on. forwarded to other loader.
The MBR in this diagram is the boot loader that allows us to choose which operating system to load on our own kernel files. The red in the picture is the kernel file. Boot Process
The first is charging, starting the BIOS for hardware self-test, and then the BIOS transfers control to the next stage of the startup program.
Which device is the startup program for this next phase to be stored in? That is, the BIOS requires the ordering of an external device, which transfers control based on the ordering and the contents of the external device.
After the BIOS finds a device that has the highest priority and can be used as the boot device, it gives control to the MBR of the device, the next phase of the startup program .
The general partitioning of the entire device is recorded in the 64 bytes in the MBR. Locate the boot loader based on the MBR information, and then start the operating system's kernel based on the boot loader.
Once the above process is complete, control is transferred to the operating system. Grub
Grub is a popular boot loader for Linux that can load the Linux kernel based on grub.