Centoos system Start-up process

Source: Internet
Author: User
Tags network function

Brief introduction:

   作为一个Linux运维工程师,必须要熟悉Linux系统的启动流程,才能在Linux系统出现故障时及时地发现问题,解决问题;下面将为大家介绍一下CentOS系统的系统启动流程。

CentOS startup process

  根据所示,centos系统总体可分为5个阶段:POST加电自检—BOOT启动引导阶段—Grub启动引导阶段—Kernel初始化阶段—进程引导阶段(init)。

A Post power-on self-test
This stage is required for all operating systems, that is, the device boot, the motherboard hardware detection stage,

Two Boot boot boot phase
When the hardware self-test is not a problem, the BIOS will look for each boot device in order, the first boot device, that is, the device to be used for this boot, usually the first sector of the disk, which has the MBR of the system boot loader, MBR provides users with a menu, Allows the user to select a system to launch or a different kernel version, load the user's selected kernel into a specific space in RAM, unzip, expand, and then transfer control of the system to the kernel.
And the MBR of the boot program can be divided into three parts, the first 446 bytes of bootloader boot program, copy boot operating system, 64 bytes in the middle of the partition table, each 16 to identify a partition, there can be only 4 partitions, 3 primary partitions and one extended partition The last 2 self is the validity identification of the MBR area, which is generally identified as 55AA, which is valid

Three Grub Boot Boot phase
Grub (GRand Unified bootloader "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.
Grub can be divided into two versions, grub 0.x called Grub Legacy;grub 1.x called GRUB2. Systems prior to CentOS 6 are typically grub legacy, the path to the configuration file is/boot/grub/grub.conf or/etc/grub.conf,centos 7 is grub2, and the path to the configuration file is/boot/grub2/ Gurb2.cfg or/etc/grub2.cfg

 Grub的引导可以分为三步:    Stage 1:mbr引导    Stage 1_5:mbr之后的扇区,让stage1中BootLoader能识别stage2所在分区上的文件系统    Stage 2:将主引导程序载入磁盘分区中(CentOS 6 /boot/grub/,CentOS 7 /boot/grub2)

Four Kernel initialization phase
When the system reads the kernel boot parameters in the grub.conf file, the kernel enters the kernel initialization boot phase. The kernel initialization process is carried out in four steps, first the kernel detects all the hardware devices that can be identified, then loads the hardware driver for the hardware device, and the kernel needs to load the driver with the pseudo file system RAMDisk when the hardware driver is loaded. The kernel mounts a root filesystem in a read-only manner, and transfers the root filesystem to the normal system, and then runs the first program of user space:/sbin/init, at this point, the initialization phase of the kernel is complete.

Five Process Boot phase
After the first program/sbin/init the kernel starts the user space, Init takes over the CentOS system completely, and Init is the parent of all other processes;
Init program in different versions of the CentOS system, in CentOS 5, the init program is SYSV init, its configuration file is/etc/inittab, in CentOS 6, the INIT program is upstart, its configuration file is/etc/ Init/&.conf, while the/etc/inittab file is used only to define the default RunLevel, in CentOS 7, the INIT program is SYSTEMCTL and its configuration file is/usr/lib/system/ or/etc/system/ system/.

The init boot stage can be divided into four parts, 1. Set the default RunLevel, 2. Run the system initialization script, complete the system initialization, 3. Close the service that needs to be stopped at the corresponding level, start the service that needs to start at the corresponding level, 4. Set the login terminal (start the graphical interface if you want to start the graphical interface)

1. Set the default run level
The operating level of the CentOS system is the operating mechanism set up for the purpose of system operation or maintenance, and is divided into 7 levels, namely
0: Shutdown, shutdown
1: Single user mode, login user as root user, no authentication required, maintenance mode
2: Multi-user mode (multi user), will start the network function, but will not start NFS, for maintenance mode
3: Multi-user mode (multi user), full function mode, file interface
4: Reserved level, currently no special purpose, but accustomed to use with 3 levels of functionality
5: Multi-user mode (multi user), full function mode, graphical interface
6: Restart, reboot
Levels 3 and 5 are the default levels of the CentOS system, and if level switching is required, you can use init+# to switch levels, and to see the current runlevel, you can use the Who-r or RunLevel command to view

2. Run the system initialization script
The system initializes the script as a/etc/rc.d/rc.sysinit script, and the following information is set after the script executes
(1) Set host name
(2) Setting welcome information
(3) Activate Udev and SELinux
(4) Mount all file systems defined in the/etc/fstab file
(5) Detecting the root file system and re-mounting the root filesystem in read and write mode
(6) Setting 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) Loading drivers for additional devices
(11) Cleaning operation

    1. Turn off services that need to be stopped at the corresponding level and start the service at the corresponding level
      When the system selects the running level # that starts, the INIT process runs the corresponding service script in/etc/rc.d/rc#.d/, closes the service that needs to stop at the corresponding level, and starts the service that needs to start at the corresponding level.
      K: To stop the service, k##, priority, the smaller the number, the more priority to shut down, dependent on the service first shut down, and then shut down the dependent
      S: To start the service, s##, priority, the smaller the number, the more priority starts, the dependent service starts first, and the dependent service starts after

4. Set the login terminal (if you want to start the graphical interface, start the graphical interface)
When the init process starts the service that needs to start at the corresponding level, it will enter the last step of the system boot process, which is to set up the login terminal, if the graphical interface needs to be started, then start the graphical interface, when the login terminal is started, the CentOS system start-up process is completed, After entering the correct username and password, you will be able to use the CentOS system normally.

Above for my CentOS system to start the process of some summary understanding, if there is inappropriate, I hope that the great God a lot of guidance, thanks to each friend's reading.

Centoos system Start-up 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.