CentOS system Start-up process

Source: Internet
Author: User

CentOS System Start-up process

First, the Linux startup process analysis

Boot is not as long as the stand-alone power button and shut down as long as the power button to turn off it? What is the knowledge? That's true, but since Linux is a multi-user, multi-tasking operating system, you don't have to be online when you're shutting down, and if you happen to have a large group of online jobs when you shut down, then the people who work online are immediately disconnected, that's not killing people? Some of the data is priceless.

In addition, Linux in the implementation of the time, although you will only see the black one in the interface, there is no interface, but other it is a lot of process in the background, such as log file management program, routine work scheduling, of course, there are a lot of network services, such as mail server,www server and so on. If you switch the machine casually, it will have a great loss to the interests of the company.

Since start-up is a serious matter, we need to understand the whole process of starting up, and also make it easier to find out the problems that may occur in the startup process, and the solution after the problem occurs.


Ii. List of start-up processes

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/79/14/wKioL1aIokGCZuJHAALJifTc-CM426.jpg "title=" 2012061111050069 (1). jpg "alt=" wkiol1aiokgczujhaaljiftc-cm426.jpg "/>

start the first step -- load the BIOS

When the computer is powered on, the computer loads the BIOS information First, and The BIOS information is so important that the computer must find it at the very beginning because the BIOS included in the CPU Information, device boot sequence information, hard disk information, memory information, clock information , PNP features, and so on. After that, the computer has a spectrum and knows which hardware device to read. after the BIOS has given control of the system to the first sector of the hard disk, Linux has started to control the system.

    start Part Two-read

0 track first sector is called mbr master boot record 512 bytes, but it contains pre-boot information, partition table information. Can be divided into two parts: the first part of the guide to go, accounted for the 446 bytes The second part is partitioned table, a total of 66

When the system locates the hard disk MBR specified by the BIOS , it is copied to the physical memory where the 0*7C00 address resides. Actually the content that is copied to the physical memory is Boot Loader, and specifically to your computer, that is lilo or grub .

start the third step --boot Loader

        boot  Loader  bootloader : It's heavily dependent on hardware, Systems of different architectures have different bootloader

There are several types of Boot Loader, with Grub,Lilo , and spfdisk as common Loader, but now the main distribution is mainly Grub .

The system reads the grub configuration information in memory (typically menu.lst or grub.lst), and follow this configuration information to start a different operating system.

Start the fourth step -- load the kernel

According to the path of the kernel image set by grub, the system reads the memory image and does the decompression operation. At this point, the screen will generally output "uncompressing Linux" prompt. When the decompression core is complete, the screen output "OK,booting the kernel".

   system places the compressed kernel in memory and calls the Span style= "FONT-FAMILY:CALIBRI;" >start_kernel linux linux The kernel is already set up, based on the linux The program should be working properly.

Start_kernel () is defined in init/main.c , which is similar to the main () function in a general executable program. What the system did before was just some initialization that would allow the kernel program to perform minimally, and the real kernel initialization process started here. The function start_kerenl () will invoke a series of initialization functions to complete various aspects of the kernel itself, in order to eventually build a basic and complete Linux core environment.

InStart_kenrel ()At the end of the kernel throughKenrel thread ()Create the first system kernel thread (that is,1process), which executes the kernel'sInit ()function, which is responsible for the next stage of the startup task. Last CallCpues_idle ()function, enters the system main loop body port by default will always executeDefault_idele ()the instructions in the function, i.e.CPUof theHaltinstruction until other processes in the ready queue need to be dispatched to perform other functions, the only process in the system that is in a ready state is theKernel_hread ()created byInitprocess (kernel thread), so the kernel does not enterDefault_idle ()function instead of turningInit ()function to continue the startup process.

Start the fifth step -- user layer init sets the operating level according to the inittab file

After the kernel is loaded, the first program to run is /sbin/init, which reads the /etc/inittab file and initializes it according to the file.

In fact, the main function of the/etc/inittab file is to set the operating level of Linux , which is set in the form of ":Id:5:initdefault: ", This indicates that Linux needs to run on level 5 . Linux runs at the following levels:

0: Turn off the machine

1: Single-user mode

2: Multi-user mode with no network support

3: Multi-user mode with network support

4: Reserved, not used

5: Multi-user mode withnetwork support with X-window Support

6: Reboot the system, that is, restart

Start the sixth step --init Process Execution rc.sysinit

After the run level is set, the first user layer file executed by the Linux system is the /etc/rc.sysinit script

program, it does a lot of work, including setting PATH, setting network configuration (/etc/sysconfig/network) , start Swap Partitioning, setting /proc and so on. The final completion state of the thread init is to enable the normal user program to be executed normally, so as to really complete the system environment for the application to run. Once you have prepared all of this, the system begins to enter the initialization phase of the user layer. The kernel executes the corresponding user-level initialization program through the system call Execve () load, and then attempts to load the program "/sbin/init ","/etc/init", "/bin/init ", and "/bin/sh ". as long as one of the program loads succeeds, the system starts the initialization of the user layer without going back to Init () the function segment. at this point, theinit () function ends and the boot portion of the Linux kernel ends.

Start the seventh step --Start the kernel module

The kernel modules are loaded according to the files in the /etc/modules.conf file or the /etc/modules.d directory.

Start eighth step -- execute scripts with different runlevel

Depending on the runlevel, the system runs a script that rc0.d to the response in rc6.d to perform the appropriate initialization and start the appropriate service.

Start the Nineth step -- execute /etc/rc.d/rc.local

Rc.lacal is the place where Linux is left to personalize the user after everything is initialized , so that the settings and startup things can be put here

Start Tenth step -- Execute /bin/login program, enter login status

At this time, the system has entered the waiting for the user input username and password time, has been able to use their own account log in the system.

Brief summary

1. Load the BIOS hardware information and self-test, and obtain the first bootable device based on the settings.

2. Read and execute the boot loader (that is, grub, etc.) of the MBR in the first boot device

3. loading kernel,kernel based on boot loader settings will start detecting hardware and loading drivers

4. After the hardware driver succeeds, kernel will invoke the INIT process actively, and Init will get run-level information

5.Init executes the/etc/rc.d/rc/sysinit file to prepare the operating environment for software execution (e.g. network, time zone, etc.)

6.init execution of Run-level for each service (script mode)

7.init execute/etc/rc.d/rc.local file

8.the init execution Terminal Maumee Program Mingetty to drive the login process, and finally waits for the user to log in.



This article is from the "lkm" blog, make sure to keep this source http://boblkm.blog.51cto.com/10835326/1731026

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.