CentOS Series boot-up process

Source: Internet
Author: User
Tags network function

When we use the Linux operating system, just press the power button, there will be some messy code, after a while the landing screen will appear, then during this time the system itself did what? Now let's talk about what the system has done in this period of time.

System Initialization process: post-->bootsequence (BIOS)-->bootloader (MBR)-->kernel (RAMDisk)-->rootfs (readonly)-->/sbin/ Init ()/sbin/init

First step: power-on self-test (post)

After the system power-on, the hardware self-test, is under the control of the computer CPU, the RAM chip in a program to map to the ROM address space, and complete the instructions to check whether the hardware is healthy. such as CPU devices, network cards, sound cards and other devices are intact. When the check is complete and there is no problem with the hardware and the basic hardware, start the BIOS.

Step two: Boot boot bootsequence (BIOS)

After the system power-on self-test process is over, the control of the system is transferred to Bootloader. Bootloader stored on the hard disk, this time the machine can not obtain external storage or network information, such as date, time and other important parameters are obtained from the CMOS. When it comes to CMOS, what is CMOS? CMOS full name is complementary metal-oxide Semiconductor(intended to refer to the complementary metal oxide semiconductor storage, is a large-scale application of integrated circuit chip manufacturing raw materials) is a computer motherboard on a read-write RAM chip, mainly used to save the current system hardware configuration and operators of certain parameters set. The hard disk must be formatted as a file system in order to store things under the operating system, then the boot program wants to load the hard disk on the operating system must have to support the file system format of the driver, unfortunately, only a 446K of space can not be done, Therefore, in the subsequent sector of the MBR will have this driver, will go to the second paragraph 64 bytes to find the driver, and the remaining two bytes is the check byte, if the return value is 55AA, it is valid. In Linux, usually in the/boot/vmlinuz-version-the model, and then the kernel is decompressed into memory.

Step Three: Load kernel

after importing the kernel, the system enters its own initialization, first probing all recognizable hardware devices, then loading the hardware driver (possibly with Randisk), then mounting the root filesystem in a read-only manner and finally running the first program of user space (/sbin/ Init)

The init program is different in the current CentOS distribution category.

On centos5: SYSV Init

Configuration file:/etc/initab

On the CENTOS6: upstart

Configuration file:/etc/initab/etc/init/*.conf

On the CENTOS7: systemd

Configuration files:/usr/lib/systemd/system/,/etc/systemd/system

What is Randisk again?

It is one of the features of the Linux kernel: use caching to speed up file access on disk

CENTOS5:INITRD Tool Program: MKINITRD

CENTOS6, 7:initramfs Engineering Program: DRACUT,MKINITRD

Fourth Step: Boot loader (grub load)

For grub, it contains the knowledge of the file system. He can load the Linux kernel from the ext2 or ext3 file system. Once bootloader completes the boot loader phase and can find the bootloader location, the first section starts loading the bootloader into memory to begin the second paragraph. The Grub boot loader phase transforms the original two-segment bootloader into a three-stage bootloader.

Stage1:bios loading the MBR inside the grub, because only 446 bytes, can not achieve too much functionality, so it is necessary to load 1.5 stages of the file.

stage1.5: Load the file system identification program, to identify the file system, do not load the file system can not be recognized, unable to find boot, you can not set the boot partition to LVM.

Stage2: Start looking for the kernel and start the kernel

Fourth step: Load Kernel

Geub the kernel is loaded into memory to run, the kernel is generally compressed, the first to be decompressed. When the kernel is loaded into memory, the file system is not yet available, and he uses the INITRAMFS that bootloader loads into memory. The system places the extracted kernel in memory, invokes functions to initiate a series of initializations, and various devices.

Fifth step: Read the Initrd/etc/inittab configuration file

Configuration file/etc/inittab

Each row defines a process for an action and its object

ID: identifier of a task

RunLevel: Start this service at those levels

Action: Under what conditions to start this task

Process: Task

Action

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

Respawn: Once this task is terminated, it is automatically restarted

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

Sysinit: Sets the system initialization mode, where/etc/rc.d/rc.sysinit scripts are typically specified here

K*: The service to be stopped: k##, priority, the smaller the number, the more priority to shut down, the dependent service is first closed, and then the dependent

S*: The service to start: s##, priority, the smaller the number, the higher the priority to start; Dependent services start first, and dependent services start


Chkconfig: Control/etc/init.d/the startup or shutdown status of each service script at each level

View : Chkconfig--list Name

Added: Chkconfig--add name

Delete: Chkconfig--del name

To modify the specified connection type:

Chkconfig [--level levels] name <on|off|restat>

--level levels: Refers to the level to be controlled: default is 2345

After the kernel is loaded, the first process started is the/sbin/init,init process will read the/etc/initab, the main function of this process is to prepare the software environment, all the actions are configured in/etc/initab, execute initab to set the system's default level of operation, and #来改变系统默认级别 with Init.

Level of System: 0--7

0: Shutdown, shutdown

1: Single-user mode. Root user, no authentication, maintenance mode

2: Multi-user mode: Network function is started, but NFS is not started, maintenance mode

3: Multi-user mode: Full function mode, text interface

4: Reserved level: Not currently used for special purposes, but used at level three

5: Multi-user mode: Full function mode, graphical interface

6: Restart: reboot

Sixth step: Start the system service/etc/rc.d/rc/sysinit


There are many settings to perform/etc/rc.d/rc/sysinit initialization:

1: Set host name

2: Set Welcome info

3: Activate Udev and SELinux

4: Mount all file systems defined in the/etc/fstab file

5: Detects the root file system and re-mounts the root file system in read-write mode

6: Set the system clock

7: Set kernel parameters according to/etc/sysctl.conf file

8: Activating LVM and soft raid devices

9: Activate swap device

10: Load Drivers for additional devices

11: Cleanup operation

OST--Boot Sequence (BIOS)--Boot Loader (MBR)--Kernel (RAMDisk)--rootfs--Switchroot N/init---/etc/inittab,/etc/init/*.conf--Set default run level--system initialization script--Shut down or start service at the corresponding level--start terminal




This article is from the "11275479" blog, please be sure to keep this source http://11285479.blog.51cto.com/11275479/1757240

CentOS Series boot-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.