Detailed Linux boot process

  
 

Startup process 1. Load the BIOS hardware information; 2. Read the MBR Kernel Loader (also known as lilo, grub, spfdisk, etc.) boot information; 3. Load Kernel's operating system
core Information; 4. Kernel executes the init program and obtains run-level information; 5. init executes the /etc/rc.d/rc.sysinit file; 6. activates the core plug-in module (/etc/modules.conf); Init executes the run-level batches (Scripts); 8. init executes the /etc/rc.d/rc.local file; 9. executes the /bin/login program; 10. starts the shell to control the host after logging in.

The following are some important parts to explain:

Before loading the kernel, there will be bios power-up, mbr boot, etc., but not within the scope of this article, so Again. When the system starts, there is no operating system in the memory, so the kernel must be loaded first. The loading process is complicated and this is not overstated.

After the init kernel is loaded, the first program executed is init, so its process pid is always 1. /etc/inittab is the configuration file for the init program. Read information such as the startup level from here.

/etc/rc.d/rc.sysinit Init After loading the configuration, first execute the rc.sysinit file. Its general work is as follows, as seen from the data, but has not been studied in detail. 1. Set the default path: ( PATH ) 2. Set the network status: the system will read /etc/sysconfig/network and the data in the file, such as NETWORKING, FORWARD_IPV4, HOSTNAME, DOMAINNAME, GATEWARY, The settings of GATEWAYDEV and so on are read into the system. 3. Activate the system's replacement space (simple can be thought of as virtual memory): swapping 4. Check the file system: At this time, the system will check some possible directories, such as /fsckoptions and /forcfsck and /fastboot. Directory, when your system has abnormal shutdown (such as sudden power outages, etc.), then Linux will automatically force the root filesystems to check. Simply think about it, it seems to be under Windows
system, when you do not shut down normally, the same situation will be seen when scanning the hard disk during the boot process! 5. Peripheral settings and system-set parameters ( /proc ): On Linux or Unix systems, you will find a very strange sector in the root directory, that is /proc 啰! In fact, this directory is recorded in the memory, it will be built each time you boot. His main function is to record the latest status of some interface devices of the host! For example, the network is around, the input and output are around, and so on. If you have nothing, don't hack into it! There will be problems 6. Set some parameters of Plug and Play (PNP); 7. Clear /etc/mtab; 8. mount root and /proc file system: Ok, after setting some data, of course Need to write down the information! At this time, the root and /proc information will be given to him on the file system! 9. Decide whether to use the module, load the module 10. Check the file system: Same as before, the current /fastboot check flag is turned on, and you will check your other sectors with fsck! (Use fsck) 11. Hang up other file system 12. Set the console font 13. Open quota 14. Clear unnecessary files, such as lock, pid 15. Set clock 16. serial port Initialize 17. Turn on the boot message via Dmesg is placed in /var/log/dmesg in /etc/rc.d/rcX.d/depending on the startup level, after rc.sysinit is executed. The script will be executed in the corresponding rcX.d directory. For example, if level is 3, execute the script in the /etc/rc.d/rc3.d/directory. In the rcX.d directory, there is no actual script! Instead, put the character link of the actual script in the /etc/rc.d/init.d directory. Why do you do that. This is the same as writing a program, a common module. For example, rc3.d, rc5.d will start many of the same scripts. So just put it in the /etc/rc.d/init.d directory, the link will be fine. So in the init.d directory should be placed all the scripts, at different levels, to select the call can be. Note: /etc/init.d is the same as /etc/rc.d/init.d. Whoever links to who does not know.

You can use the chkconfig --list command to see the startup and shutdown of each runlevel service.

/etc/rc.d/rc.local This is the personalization module rcX.d is executed. After that, the script to be executed uniformly (it seems that some levels do not execute it). So it is more appropriate for the user to want some operations that the system automatically performs. For example, some devices are automatically mounted when the system starts up. Why is it appropriate to put it here? If you write some execution operations before loading the kernel, it will definitely not work. Because some operations are required after some services are started. After the execution of rc.sysinit rcX.d, most of the system services have been started, and it is more appropriate to perform some user operations in rc.local.

Copyright © Windows knowledge All Rights Reserved