Linux system startup process

Source: Internet
Author: User
Tags network function

The concept of the computer's start-up process has remained on by pressing the power-on key, and then waiting for it to open automatically. However, there is almost no knowledge of the open process, including how it can activate itself after a series of processes including the internal.

at the moment it's just The startup process of the Linux system has a superficial understanding, but the process of its initiation also wants to share it with its own understanding.

General There are a few steps in the Linux system boot process:

Press Power key BIOS self-test system boot Linux kernel boot init system login System

each of these processes can be subdivided into many sub-processes. Press the Power key This step is needless to say, we start with the BIOS self-test.

BIOS self-Test

BIOS Self-test can be divided into two stages

First Stage: POST(power-on-self test), mainly detect the host hardware equipment such as:CPU, memory, hard disk, video card and so on is normal;

Phase II: After the completion of the first phase, it will press The system boot order set in the BIOS to search for bootable disk devices. such as: CD, hard disk,U disk, etc. after the first bootable device is searched, the contents of the first sector of the device are read and executed. The BIOS task is complete.


System boot:

to understand the system boot first we need to understand what is MBR(Master Boot Record). The hard disk's 0 cylinders,0 heads, and1 sectors are referred to as the primary boot sector. It consists of three parts, the Master boot Program (Bootloader), the hard disk partition table DPT(Disk Partition table),and the hard disk active flag (55AA its structure is as follows:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/79/0D/wKiom1aGNT_g0QlaAABLC69EpII926.png "title=" 1.png " alt= "Wkiom1agnt_g0qlaaablc69epii926.png"/>


which Bootloader is the boot loader, and its main functions are:

1, provide the menu, allow the user to select the system to start or different kernel version;

2, load the selected kernel into memory, unzip, expand, and then give the control of the system to the kernel;

currently The most commonly used Bootloader in Linux is GRUB;

There are three main stages of grub boot:

Stage1: The simple function is to read the first sector into memory, but note that Stage1 is not capable of identifying the file system.

stage1.5: As the intermediate bridge betweenstage1 and stage2, stage1.5 has the ability to identify the file system, after which grub can access / The Stage2 file in the Boot/grub directory and loads the Stage2 into memory for execution.

Stage2: When loaded into memory execution, it first parses the grub configuration file /boot/grub/grub.conf, then loads the kernel image into memory and transfers control to the kernel. The kernel immediately initializes the devices in the system and makes the relevant configuration work, including CPU,I/O, storage devices, and so on.


Linux kernel boot:

The kernel is loaded into memory in the previous step and the control of the system is obtained, and the kernel immediately initializes the device in the system after gaining control, including CPU,I/O, storage, etc.;

about the Linux device driver loading may require initrd(ramdisk). Because one-step drivers are compiled directly into the kernel file, the other part will be in the form of a module in the INITRD ;

after initializing the hardware and loading each hardware driver, the kernel mounts the root filesystem in a read-only manner and runs the first process sequence /sbin/init. Thereafter, the control of the system is given to the/sbin/init process.

System initialization

The/sbin/init process is the first program that the system starts, and it is the parent process for all other processes. When it takes over the control of the system first, it first reads the/etc/inittab file to execute the corresponding script to initialize the system, such as setting up the keyboard, font, loading module, setting up the network, etc.

There is a very important setup option in niittab runlevel. start different services according to the different runlevel, so that the Linux usage environment is different. Basically RunLevel is divided into 0-6 ,7 levels:

0: shutdown,shutdown

1: Single user mode (sigle user),root user, no authentication, maintenance mode;

2: Multi-user mode (Multi user), will start the network function, but will not start NFS; maintenance mode;

3: Multi-user mode (Multi user), full function mode, text interface;

4: Reserved level: Currently no special use purposes, but customary with the 3- level use;

5: Multi-user mode (Multi user), full function mode, graphical interface;

6: Restart mode,

The process of initializing the system is done mainly by executing some script configuration files:

1, the implementation of the system initialization script (/etc/rc.d/rc.sysinit), the basic configuration of the system, read and write to mount the root file system and other file systems, to this system is basically run up, It is necessary to determine the operation level and start the corresponding service later.

2, execute /etc/rc.d/rc script. The file defines the order in which the service starts with K after S, and the service state of each run level is placed in the/ETC/RC.D/RC*.D(*=0~6) directory, all files are pointing to /etc/init.d a symbolic link to the corresponding file. Rc.sysinit analyzes the/etc/inittab file to determine the boot level of the system before it executes the files under/ETC/RC.D/RC*.D.

3. Execute user-defined bootloader /etc/rc.d/rc.local

after all the system startup tasks have been completed,Linux will start the terminal or X-window to wait for the user to log in.

Enter the user name and password in the last step to log into the system.


above is the process of booting the Linux system. Some of these steps are not very detailed, just to give you a preliminary understanding of the Linux startup process. If you want to know more detailed steps, you can expand yourself.

Below is a reprint of the System Guide flowchart, easy to comb the entire process

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M02/79/0D/wKiom1aGNh7yOvS_AAcSNNSWIho944.jpg "title=" 2.jpg " alt= "Wkiom1agnh7yovs_aacsnnswiho944.jpg"/>


Linux system startup 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.