Linux boot process description

Source: Internet
Author: User
Linux system boot process description this article describes the linux system boot process, which belongs to the scope of personal understanding. if the expression in this article is incorrect, please criticize and correct it! After the computer starts up, it must first load BIOS (Basic Input/Output System) information. BIOS contains a lot of important information, including CPU information, this document describes the boot process of a linux system. it is a personal understanding. if the description is incorrect, please criticize and correct it! After the computer starts up, it must first load BIOS (Basic Input/Output System) information. BIOS contains many important information, including CPU information, device startup sequence information, hard disk information, and memory information, clock information. The BIOS performs POST (power-on self-check) and then reads the boot block from the hard disk, floppy disk, or CDROM according to the boot sequence set in the BIOS. The linux system starts from OxFFFFO in the BIOS. The first job of BIOS is POST. the job of POST is to check the hardware. The second task is to enumerate and initialize local devices. 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. grub configuration is implemented through/boot/grub. conf. Next we need to load the kernel image to the memory. the kernel image is compressed by zlib, usually a zimage or bzimage. there is a routine before the image to implement a small amount of hardware settings, decompress the kernel image and place it in the memory. then, the routine will call the kernel to start the kernel boot process. After the kernel is started, it will query all the hardware information of the computer to the bios, and then start to manage these devices by yourself, so that linux will try to drive these devices using the kernel ,, some drivers of these devices are included in the kernel, called static drivers, and some are stored in the file system. they are not attached to any file system yet, therefore, the kernel will try to be mounted to the root file system. the root file system must contain at least the/etc,/bin,/boot,/lib, and/dev5 directories, the root file system is mounted in read-only mode, because it is still in the startup phase of linux and is unstable to avoid damage to system data. 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.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.