Linux Learning Notes: System boot boot process

Source: Internet
Author: User

Linux system boot Boot process

Recently found himself in just mastering a few more hard wounds:

    • First, knowledge system fragments, such as Linux, this learning point that learning point, the result is not a system, string up;

    • Second, the memory time is short, a lot of content learned to forget, the final result is to meet a knowledge point can think of oneself indeed learned, but now can't remember.

    • Third, the level of understanding is simple, such as today to organize the contents of the Linux boot, before the general know, not known as understanding, I think learning a knowledge point at least to be able to systematically speak out, rather than have a vague general understanding.

Individual noun explanations

1.BIOS(Basic Input Output System): basic inputs and outputs. In fact, it is a set of fixed to the computer board on a ROM chip on the program, it holds the most important basic input and output of the computer program, post-boot self-test program and the system self-start program, it can read and write the system settings from the CMOS specific information.

2.MBR(Master boot Record): Master boot record. The hard disk's 0 cylinders, 0 heads, and 1 sectors are referred to as the primary boot sector (also called the Master Boot Record MBR).

MBR is not part of any operating system, nor can it be read with the disk operation commands provided by the operating system, but may be modified and rewritten through commands.

3.Grub(GRand Unified Bootloader): GNU Grub is a multi-OS launcher from the GNU project. Grub is the implementation of a multi-boot specification that allows users to have multiple operating systems at the same time on the computer and select the operating system that they want to run when the computer starts. Grub can be used to select different cores on the operating system partition or to pass startup parameters to those cores.

Linux boot Process Preview

What to do when the power key is pressed:

Created with Rapha?l 2.1.0 Press the Power key Load BIOS Read MBR Boot Loader Boot Loader User Layer Init sets the operating level according to the Inittab file init Process Execution Rc.sysinit booting the kernel module executing scripts at different run levels Executive/etc/rc.d/rc.local Execute/bin/login program, enter login status Boot Complete Detailed analysis of the boot process first step, load bios

The function of the BIOS consists of two parts, the post code and the runtime service respectively. After the post phase is complete it will be purged from memory, and the runtime service will be retained for the target operating system startup. The detailed work done in the BIOS two phases is as follows:

    1. Step 1: Power-on self-test post (power-on), mainly responsible for detecting the system peripheral critical equipment (such as: CPU, memory, graphics card, I/O, keyboard mouse, etc.) is normal. For example, the most common is the memory loose situation, the BIOS self-test stage will be error, the system can not start up;

    2. Step 2: After step 1 succeeds, a small program is executed to enumerate the local device and initialize it. This step is primarily based on the system boot order that we set up in the BIOS to search for the drives that are used to boot the system, such as hard disks, CDs, USB drives, floppy disks, and networks. We take the hard drive as an example, the BIOS now reads the first sector of the hard drive (mbr,512 bytes) and executes the code inside. In fact, the BIOS here does not care what is in the first sector of the boot device, it is simply responsible for reading the sector content and executing it.
      At this point, the BIOS task is completed, and then the system-initiated control is transferred to the MBR section of the code.

Second step, read MBR

When the system locates the MBR of the hard disk specified by the BIOS, it is copied to the physical memory where the 0X7C00 address resides. Actually the content that is copied to the physical memory is boot Loader, and specifically to your computer, that is LILO or grub.

Add:

One sector of the hard disk master boot record MBR consists of 4 parts.

    1. The Master Boot program (offset address 0000h–0088h), which is responsible for loading from the active partition and running the system boot program.

    2. Error message data area, offset address 0089h–00e1h is an error message, 00e2h–01bdh is all 0 bytes.

    3. The partition table (Dpt,disk Partition table) contains 4 partition entries, offset address 01BEH–01FDH, 16 bytes per partition table entry, 64 bytes for partition entry 1, partition entry 2, partition entry 3, and partition item 4.

    4. The end glyph, offset address 01fe–01ff, has a 2-byte value of end flag 0xaa55 or 0X55AA, called magic number. If the flag is incorrect, the system cannot start.

Step three, Boot Loader

Boot Loader is a small program that runs before the operating system kernel runs. Through this small program, we can initialize the hardware device, set up a map of the memory space, so as to bring the system's hardware and software environment to a suitable state, in order to finally call the operating system kernel ready to do everything. Boot Loader is available in several ways, including Grub and Lilo, which are common loader. The system reads the GRUB configuration information in memory (typically menu.lst or grub.lst) and launches a different operating system according to this configuration information.

Fourth step, load the kernel

Based on the path of the kernel image set by grub, the system reads the memory image and does the decompression operation. At this point, the screen will generally output "uncompressing Linux" prompt. When the decompression core is complete, the screen output "OK, booting the kernel".

The system places the extracted kernel in memory and calls the Start_kernel () function to start a series of initialization functions and initialize the various devices to complete the Linux core environment. At this point, the Linux kernel has been established, Linux-based programs should be able to run properly.

Fifth step, user layer init according to the Inittab file to set the operating level

After the kernel is loaded, the first program to run is/sbin/init, which reads the/etc/inittab file and initializes it based on the file.

The main function of the/etc/inittab file is to set the Linux operating level, which is set in the form ": Id:5:initdefault:", which indicates that Linux needs to run on level 5. Linux runs at the following levels:

    • 0: Turn off the machine
    • 1: Single-user mode
    • 2: Multi-user mode with no network support
    • 3: Multi-user mode with network support
    • 4: reserved, not used
    • 5: Multi-user mode with network support with X-window support
    • 6: Reboot the system, that is, restart
Sixth step, init Process Execution Rc.sysinit

After setting the run level, the Linux system executes the first user layer file that is the/etc/rc.d/rc.sysinit script, which sets the path, sets the network configuration (/etc/sysconfig/network), starts the swap partition, sets/ Proc and so on.

Seventh step, boot the kernel module

The kernel modules are loaded according to the files in the/etc/modules.conf file or the/ETC/MODULES.D directory.

Eighth step, execute scripts with different runlevel

Depending on the runlevel, the system will run the appropriate script from RC0.D to RC6.D to perform the appropriate initialization and start the appropriate service.

The Nineth step, the execution/etc/rc.d/rc.local

If you open this file, there is a word, read it, you will be the role of this command at a glance:

This script is executed after all of the other init scripts.
You can put your own initialization stuff in here if you don ' t
Want to does the full Sys V style init stuff.

Rc.local is the place where Linux is left to the user to personalize after all initialization work. You can put the things you want to set up and start up here.

Tenth step, execute/bin/login program, enter login status

At this time, the system has entered waiting for the user input username and password status, the user can log into the system with their own account

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Linux Learning Notes: System boot boot process

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.