BIOS consists of two parts: POST code and runtime services. After the POST is completed, it will be cleared from the memory, but the service will remain in the memory when the BIOS is running. The BIOS searches active and bootable devices in the order defined in the settings.
A boot device can be a partition on a hard disk, a CD-ROM, a floppy disk, a network device, or a USB device. Linux usually performs boot from the hard disk. The primary partition MBR contains the primary boot loader. When the MBR is loaded into RAM, the BIOS transfers the control to the MBR, which is also called the primary boot sector. This is the first sector that must be read when the computer accesses the hard disk after it is started, located in 0 cylinder, 0 track, 1 sector. The MBR Master Boot Program is a 512-byte image. The first 446 bytes are the primary Boot Loader. The next 64 bytes contain partition table information, and two special bytes OxAA55 are used to check the validity of MBR.
If you want to start the system, you must start the kernel. Obviously, the MBR cannot store the kernel, but there is a small program in the MBR that can load the kernel in other locations. This mini program is the boot loader, that is, GRUB. GRUB allows you to select the operating system to start. GRUB packages three important files. Stage1, Stage2, and Stage1.5. Stage1 are usually stored in MBR, which is used to load Stage2 at system startup and forward control to it. Stage2 is the core of GRUB, and all functions are completed by it. Stage1.5 is a bridge between Stage1 and Stage2, because Stage2 is large and usually stored in a file system, but Stage1 cannot recognize the file system, stage1.5 to guide Stage2 in a file system. Stage2 is the core of GRUB, but not the core of linux. After grub is loaded, it is used to load the linux kernel.
< p>
After the kernel completes the boot, it loads the init program in the process space. The process number is 1, and the init process is the initiator and controller of all processes. It is the first running process, the init process will determine the running level to enter based on/etc/inittab, and then directly execute/etc/rc. d/rc. sysinit initializes the system and loads the startup information to the/var/log/dmesg file. After all the system services are started, run the/etc/rc. d/rc. local script to start the programs that need to be started.