The general process of the Linux system startup process (10 steps)

  
 

If the liunx system is started, I just said about it, but the specific process is not well understood. Today, I will find the following flow chart on the Internet and explain it in detail according to the figure. If there is any problem, please indicate .


Starting the first step--Loading the BIOS device to power up, the BIOS information will be loaded first, and the BIOS information is very important. The first reason is because the BIOS contains information about the CPU, device startup sequence information, hard disk information, memory information, clock information, PnP characteristics, and so on. After that, the computer has a spectrum of knowing which hardware device should be read.

Starting the second step--Reading MBR It is well known that the first sector of the 0th track on the hard disk is called MBR, which is the Master Boot Record, which is the master boot record. Its size is 512 bytes. , pre-boot information, partition table information is stored. After the system finds the MBR of the hard disk specified by the BIOS, it copies it to the physical memory where the 00&00 address is located. In fact, the content copied to the physical memory is the Boot Loader, and specific to your device, that is lilo or grub.

Starting the third step--The Boot LoaderBoot Loader is a small program that runs before the OS
kernel runs. Through the small program, we can initialize the hardware device, establish a map of the memory space, and bring the system's hardware and software environment to a suitable state, in order to prepare for the final call of the operating system
kernel. There are several types of Boot Loader, of 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 the grub configuration information in the memory (usually menu.lst or grub.lst) and starts different operating systems according to this configuration information.

Starting the fourth step--loading the kernel According to the path of the kernel image set by grub, the system reads the memory image and decompresses it. At this point, the screen will generally output the prompt "Uncompressing Linux". When the decompressed kernel is complete, the screen outputs <OK, booting the kernel”. The system places the decompressed kernel in 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 kernel environment. At this point, the Linux kernel has been built, and Linux-based programs should work fine.

Start the fifth step--user layer init according to the inittab file to set the runlevel kernel is loaded, the first program is /sbin/init, the file will read /etc/inittab File, and based on this file to initialize the work. In fact, the main function of the /etc/inittab file is to set the running level of Linux. The setting form is "ld:5:initdefault:", which means that Linux needs to run at level 5. The operating level of Linux 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: Supported by X-Window with network support Multi-user mode 6: Reboot the system, that is, restart the knowledge about the /etc/inittab file. In fact, there are still many

starting the sixth step--init process execution rc.sysinit after setting the run level The first user layer file executed by the Linux system is the /etc/rc.d/rc.sysinit script, which does a lot of work, including setting the PATH, setting the network configuration (/etc/sysconfig/network), Start the swap partition, set /proc, and more. If you are interested, you can check the rc.sysinit file in /etc/rc.d. The script inside is enough for you to watch for a few days.

Starting the seventh step--Starting the kernel module is based on /etc Load the kernel module in the /modules.conf file or in the /etc/modules.d directory.

Starting the eighth step--executing scripts of different runlevels According to different runlevels, the system will run the corresponding scripts from rc0.d to rc6.d to complete the corresponding initialization work and startup. The corresponding service.

Start the ninth step--execute /etc/rc.d/rc.local If you open this file, there is a sentence inside, after reading it, you will see the effect 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 after everything is initialized Linux is left to users to personalize. You can put the things you want to set up and start here.

Start the tenth step--execute the /bin/login program and enter the login state. At this point, the system has entered the waiting for the user to enter the username and password. You can log in to the system with your own account. :)=== The long startup process is over, everything is quiet … in fact, behind this, there are more complicated underlying function calls, which have not yet been learned, and will be recorded for everyone later.

Copyright © Windows knowledge All Rights Reserved