Article Title: gentoo system startup initialization. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
1. Startup Process
The init process determines the startup sequence and workflow through/etc/inittab. init will execute the/etc/init pointed to by the symbolic links under all/etc/runlevels/boot directories. d directory. After all the scripts referenced in the/etc/runlevels/boot directory are executed, the script pointed to by the symbolic link under the/etc/runlevels/default directory will continue to run.
Description
Run-level definition in inittab
L1: S1: wait:/sbin/rc single
L2: 2: wait:/sbin/rc nonetwork
L3: 3: wait:/sbin/rc default
L4: 4: wait:/sbin/rc default
L5: 5: wait:/sbin/rc default
L6: 6: wait:/sbin/rc reboot
The following definition is si: sysinit:/sbin/rc sysinit. This is the init process that will be initialized to rc and the system will be initialized by/sbin/rc sysinit, the/sbin/rc Script is the rc Script parameter (boot) for system initialization in rc: bootwait:/sbin/rc boot) it is the same as the/etc/runlevels sub-directory to be used.
After the rc completes, init determines which virtual terminals need to be activated and what commands each terminal needs to run:
The following definitions are available in inittab:
C1: 12345: respawn:/sbin/agetty 38400 tty1 linuxc2: 12345: respawn:/sbin/agetty 38400 tty2 linuxc3: 12345: respawn:/sbin/agetty 38400 tty3 linuxc4: 12345: respawn:/sbin/agetty 38400 tty4 linuxc5: 12345: respawn:/sbin/agetty 38400 tty5 linuxc6: 12345: respawn: /sbin/agetty 38400 tty6 linux Code defines which virtual terminals need to be activated when running at a certain running level and what commands each terminal needs to run
2. Start services and make adjustments
/Etc/init. d/xxxx status check the service running status/etc/init. d/xxxx zap manually sets the information to stop/etc/init. d/xxxx ineed View dependent services/etc/init. d/xxxx needsme which services need this service (needsme) or which services can use this service (usesme) rc-update add xxx default add service to default rc-update del xxx default Delete service rc-update-v show command will show all existing initialization scripts, the advantage of adding independent additional configurations to the running level is that after a software is reinstalled, gentoo configuration is not overwritten in/etc/conf. for more information about dgentoo documentation, see www.gentoo.org/doc/zh_cn/handbook/handbook-x86.xmlfirst. Your boot program will load the kernel image you defined in the boot program configuration file into the memory, and then it will tell the CPU to run the kernel. After the kernel is loaded and running, the kernel initializes all kernel-specific struct and tasks and starts the init process.
Then, this process ensures that all file systems (defined in/etc/fstab) have been mounted and can be used. Then, the process runs some scripts in/etc/init. d, which start some services you need so that you can get a successfully started system.
Eventually, when all the scripts are executed, init will activate the terminal (mostly just activating the virtual terminal, which can be accessed using Alt-F1, Alt-F2, etc ), and attaches a special process called agetty to it. This process ensures that you can log on to your system from these terminals by running login.
Gentoo does not randomly execute scripts under/etc/init. d. Even, it will not run all the scripts under/etc/init. d, but will only execute
Init runs all the scripts in the/etc/runlevels/boot directory to which the symbolic links point. Generally, it executes these scripts alphabetically, but some scripts contain dependencies, which means that the system can run the script only after another script is executed.
After all the scripts referenced in the/etc/runlevels/boot directory are executed, init continues to run the script pointed to by the symbolic link in the/etc/runlevels/default directory. Similarly, they execute these scripts alphabetically. Unless a script is dependent, the existing order will be changed to make the startup order more reasonable.
Of course, init does not determine all the startup sequence. It requires a configuration file to specify its workflow. The configuration file is/etc/inittab.
If you still remember the startup sequence we just described, you will remember that init first mounted all the file systems. This function is defined in the/etc/inittab configuration file. As follows: si: sysinit:/sbin/rc sysinit indicates that init must run/sbin/rc sysinit to initialize the system. The/sbin/rc Script is responsible for system initialization, so you may say that init itself does not do much-it just handed over the initialization system task to another process.
Next, init executes all scripts with symbolic links under the/etc/runlevels/boot directory. This is defined by the following line:
Rc: bootwait:/sbin/rc boot what is the running level?
We can see that init uses a number to determine the running level to be activated. The running level indicates the running status of your system. It contains a set of scripts (run-level scripts or initialization scripts) that you need to execute when you enter or exit a running level ).
Gentoo defines seven running levels: three internal running levels and four custom running levels. These internal run levels are called sysinit, shutdown, and reboot, respectively, and they do what they do, as they do: Initialize the system, shut down the system, and restart the system.
User-Defined running levels all have subdirectories with the same name under the/etc/runlevels Directory: boot, default, nonetwork, and single. Run-level boot starts all system services that must be used by other running levels. The other three running levels differ mainly in the services to be started: default is used for daily work; nonetwork is used without a network; in addition, single is used to repair the system.
[1] [2] Next page