CentOS system startup process 1-10 details

Source: Internet
Author: User

CentOS system startup process 1-10 details

Yesterday, a senior asked me that if the liunx system was started, I just gave a rough idea, but the specific process was not fully understood. Today I found the following flowchart on the Internet, according to the figure, it is described in detail. If there is any problem, please point it out.



Start Step 1 -- load BIOS
When the device powers up, the BIOS information is loaded first. The BIOS information is very important. The reason for the first startup is that the BIOS contains CPU information, device startup sequence information, hard disk information, memory information, clock information, and PnP features. After that, the computer will be aware of which hardware device should be read.

Start Step 2 -- read MBR
As we all know, the first sector of the 0th track on the hard disk is called MBR, that is, Master Boot Record, that is, the Master Boot Record. Its size is 512 bytes, which stores the pre-start information and partition table information.
After the system finds the MBR of the hard disk specified by the BIOS, it will copy it to the physical memory where the 0 × 7c00 address is located. In fact, the content copied to the physical memory is the Boot Loader, and to your device, it is lilo or grub.

Step 3 -- Boot Loader
Boot Loader is a small program that runs before the operating system kernel runs. Through small programs, we can initialize hardware devices and build a map of memory space, so as to bring the system's hardware and software environment to a suitable State, so as to make all preparations for the final call to the operating system kernel.
There are several Boot loaders, among which Grub, Lilo, and spfdisk are common loaders.
Let's take Grub as an example. After all, there are not many people using lilo and spfdisk.
The System reads grub configuration information (generally menu. lst or grub. lst) in the memory and starts different operating systems according to the configuration information.

Step 4-load the kernel
Based on the path of the kernel image set by grub, the system reads the memory image and decompress it. At this time, the screen will usually output the "Uncompressing Linux" prompt. After the kernel is decompressed, the screen outputs "OK, booting the kernel ".
The system places the decompressed kernel in the memory, and calls the start_kernel () function to start a series of initialization functions and initialize various devices to complete the establishment of the Linux core environment. So far, the Linux kernel has been established, and the Linux-based program should be able to run normally.

Step 5 -- User-layer init sets the running level based on the inittab File
After the kernel is loaded,The first program to run is/sbin/init, which reads the/etc/inittab file and initializes the file based on the file.
In fact, the main function of the/etc/inittab file is to set the Linux running level. The setting format is ": id: 5: initdefault :", this indicates that Linux needs to run on level 5. The Linux operating level is set as follows:
0: Shutdown
1: single-user mode
2: multi-user mode without network support
3: multi-user mode with network support
4: reserved, not used
5. Multi-user mode with network support and X-Window support
6. reboot the system.
There are still a lot of knowledge about the/etc/inittab file.

Start step 6 -- execute rc. sysinit in the init process
After the running level is set, the first user-layer file executed by Linux is/etc/rc. d/rc. the sysinit script program does a lot of work, including setting PATH, setting network configuration (/etc/sysconfig/network), starting swap partitions, and setting/proc. If you are interested, you can check the rc. sysinit file in/etc/rc. d. The script in it is enough for a few days.

Step 7 -- start the kernel module
The kernel module is loaded Based on the/etc/modules. conf file or the file in the/etc/modules. d directory.

Start Step 8-execute script programs of different running levels
Depending on the running level, the system will run the corresponding script programs from rc0.d to rc6.d to complete the initialization and start the corresponding service.

Start Step 9 -- run/etc/rc. d/rc. local
If you open this file, there is a sentence in it. After reading it, you will see the role of this command at a Glance:
# This script will be executed * after * all the other init scripts.
# You can put your own initialization stuff in here if you don't
# Want to do the full Sys V style init stuff.
Rc. local is a place for users to personalize Linux after all initialization work. You can put what you want to set and start here.

Start step 10-run the/bin/login program and enter the logon status
Now, the system has entered the waiting time for the user to enter username and password. You can use your account to log on to the system. :)
===
The long start process is over, and everything is quiet...
In fact, there are more complex underlying function calls behind this, and we haven't learned yet. We will record them later.

This article is from the "Practical notes" blog, please be sure to keep this source http://qiuyt.blog.51cto.com/1229789/1606083

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.