CentOS system Start-up process

Source: Internet
Author: User
Tags network function


the start-up process for the CentOS system :

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/78/CA/wKioL1aDemOhEXseAABYNcSDDKg204.png "title=" System boot. png "alt=" Wkiol1ademohexseaabyncsddkg204.png "/>

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" title= "system start. png" alt= "Spacer.gif"/>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


1. Post power-on self-test


When the computer's hardware is power-up, a self-test is usually called post (Power On Self test), and the power-on process checks to see if the parts of the computer are present and working properly.




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




2. Load bootloader


after the self-test is complete, the BIOS program on the motherboard is usually the first one to turn to the first drive Fan Area that Master Boot Record (MBR) to load the bootloader.

Master boot record MBR (master boot record) in the first sector of the disk, the size is 512 bytes: the first 446 bytes

Is bootloader, the middle 64 bytes is the DPT is the disk partition table, the last two bytes is the valid identity of the MBR, 55AA indicates that the MBR is valid.


The role of bootloader is to allow the user to select the system to be launched or a different kernel version, to load the user-selected kernel into a specific space of RAM, unzip, expand, and then transfer control of the system to the kernel, but since the size of the bootloader is only 446 bytes, means that it can implement a limited number of code and tasks, so CentOS uses the grub mechanism to start the system boot process.

grub divides the boot process into 1, 22 stages, the first phase loads the bootloader, at which point the bootloader does not load the kernel, but instead loads the second stage of grub into memory, which can then be implemented in memory without the limitations of the MBR to implement many complex functions and loads the user-selected kernel and is able to pass parameters to the kernel.




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



3, initialization of the kernel


The initialization of the kernel (kernel) is divided into four steps:


1, detection of all the hardware equipment can be identified ;

2. load the hardware driver (it is possible to load the driver with the help of RAMDisk ); Since the kernel is not likely to compile all of the hardware devices directly into the kernel, when the kernel cannot load the driver for the device on which the root file system resides, The generated RAMDisk file is created by a specific tool program, and RAMDisk is a lite version of the root filesystem that runs in memory, and it works by:

    ramdisk will be in load a virtual root file system in memory to identify the driver required by the real root filesystem and load, after loading, the kernel will be able to identify and mount the real root filesystem, at this time ramdisk then switch the root to the real root filesystem and exit the memory yourself

3. mount the root file system as read-only , prevent the kernel from having a bug that causes data loss on the root file system, and the kernel will re-mount the root file system in read-write mode during system initialization

4. Finally, the task is forwarded to the init program to load the first application running the user space:/sbin/init


kernel-level system initialization process summary :

Post power-on-bootsequence (BIOS)--Bootloader (MBR)--Kernel (RAMDisk)--Rootfs (readonly)--/sbin/ Init ()




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




4, run the INIT program, take over the user space


In CentOS 5, for example, the INIT program first sets the operating level of the system and the tasks to be started at all levels by reading its configuration file /etc/inittab


init configuration file :/etc/inittab determines which services are started in the system initialization, each of which defines an action and the corresponding process

id:runlevels:action:process

ID: A unique identifier for a task;

RunLevel: The level at which this task is started; #,### can also be empty, indicating all levels

Action: Under what conditions to start this task;

Process: a specific task;

Action: The scene at startup

Wait: Executes once while waiting to switch to the level at which the task is located;

Respawn: Once this task is terminated, it will be restarted automatically;

Initdefault: Sets the default RunLevel, at which time the process is omitted;

Sysinit: Sets the system initialization mode, where the specified/etc/rc.d/rc.sysinit system initialization script is typically



operating level : is the mechanism set for the purpose of running or maintaining the system, the default is to run the 3,5 level

0-6:7 levels;

0: Shutdown, shutdown

1: Single user mode, root user, no authentication required; Maintenance Mode

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

3: Multi-user mode (multi user), fully functional mode, text interface

4: Reserved level: Not currently used for special purposes, but used with 3 levels of functionality

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

6: Restart mode, reboot


1. Specify the operating level

For example Id:3:initdefault: Indicates that 3 levels are run by default


2. Run the system initialization script

such as Si::sysinit:/etc/rc.d/rc.sysinit

Indicates that the/etc/rc.d/rc.sysinit script will be run at all levels to complete system initialization


After the system initialization is complete, the INIT program runs the script under/etc/init.d/* (/etc/rc.d/init.d/*) to determine which services to turn on or off when the system starts.

The/etc/init.d/* (/etc/rc.d/init.d/*) script can accept a run-level number for the parameter setting the service that needs to be opened or stopped at the corresponding level

S* in/etc/rc.d/rc#.d/: Represents the service to start; K*: Represents the service to be stopped


3, define the starting terminal ,

For example:

Tty1:2345:respawn:/usr/sbin/mingetty tty1

... ...

Tty6:2345:respawn:/usr/sbin/mingetty Tty6

Indicates that when the system runs at level 2345, the/usr/sbin/mingetty program starts the TTY1-6 virtual terminal automatically, and the/usr/sbin/mingetty file invokes the login program to let the user log in



Summary (User-space start-up process):

Read/sbin/init (/etc/inittab) Set the default run level-run the system initialization script, complete the system initialization--close the service (k*) that needs to be stopped at the corresponding level, start the service that needs to be turned on at the corresponding level (s*)-- Set Login terminal [--> start graphics terminal]


When the login terminal is completed, the system starts to complete


CentOS system Start-up process

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.