In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
What is the startup sequence of the Linux system? for this question, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
Linux startup sequence
Power on-Power on self Test (BIOS)-hardware check
-MBR (find the system that needs to be booted, as multiple systems may be installed on the actual computer)
-bootloader system initialization, loading kenel into memory
-Kernel execution, deciding which devices need driver initialization, mounting the root file system, and starting the first process, init
-start / etc/rc.d/sysinit
(this is the first script executed by init. In Redhat, / etc/rc.d/rc.sysinit mainly does the same initialization work in each running mode, including: calling keymap and system font, starting swapping, setting hostname, setting NIS domain name, checking (fsck) and mount file system, opening quota, loading sound card module, setting system clock.)
(rc--run command runs commands, d-wizard processes, processes that cannot be seen during startup, / etc file is a very important configuration file, do not modify it)
-load other modules (memory, hard drive, optical drive, etc.)
-run level script (/ etc/rc.d/rc $RUNLEVEL # $RUNLEVEL is the default running mode, with a maximum of 6 layers. The programs started at each level are different, and there is no relationship between each layer)
-execute / etc/rc.d/rc.local (very important, you need to set this to modify on startup after installing tomcat)-execute / bin/login-shell startup
Expansion: Linux boot process
After the system is powered on, the first hardware self-test is carried out, and then the bootloader initializes the system and loads the kernel. After the kernel is loaded into memory, execution begins. Once the kernel is up and running, the detection of the hardware determines which device drivers need to be initialized (the hardware detection here is different from the previous hardware self-test, which is checked within the system to determine whether initialization is needed). From here, the kernel can mount the root file system (this process is similar to the process that Windows recognizes and accesses disk C). After the kernel mounts the root file system and initializes all device drivers and data structures, it completes the boot process by starting a user-level program called init.
Expansion: startup sequence
The Init process is the first user process after the system starts, so its pid (process number) is always 1. The first thing the init process does is read the initdefault id value in the inittab file under the / etc/ directory, which is called the run level (run-level). It determines the level at which the system runs after startup. The running level determines most of the behavior and purpose of system startup. This level ranges from 0 to 6 and has different functions. Different runtime levels are defined as follows:
# 0-stop (never set initdefault to 0, otherwise the system will never start)
# 1-single user mode
# 2-Multi-user, no NFS
# 3-full multiuser mode (standard runlevel)
# 4-system reserved
# 5-X11 (x window)
# 6-restart (never set initdefault to 6, otherwise you will always restart)
Expand: the relationship between / etc/rc.d/ and / etc/rc.d/init.d
Let's first explain what's in the init.d. This directory contains scripts, typically startup scripts for some of the services set up by linux when it is installed as a rpm package. The system installs a lot of rpm packages, and there are a lot of corresponding scripts in it. Executing these scripts can be used to start, stop, and restart these services.
As mentioned earlier, scripts in the / etc/rc.d/init.d directory are similar to the registry in windows and are executed when the system starts. The program runs here (the init process reads the run level). I believe you can guess from the naming point of view that it is time to run / etc/rc.d/init.d inside the script, otherwise why it is also called init.d. Yes, it's time to run the scripts in init.d, but not directly, but selectively because the system doesn't need to start all the services.
So, how does the system choose what needs to be started and what doesn't? At this point, the run level I just mentioned works.
After determining the run level that the system starts, the / etc/rc.d/rc script is executed first. In the source code of both RH9 and FC7, it is check_runlevel () from the beginning (although the implementation code is different, but also more or less the same). After knowing the run level, for each run level, there is a subdirectory under rc.d that is rc0.d,rc1.d. .. Rc6.d . Under each directory are some links to scripts that are part of the init.d directory. The services to be executed at each level are placed in the corresponding directory. For example, the services to be started at level 5 are all placed under rc5.d, but what is placed under this rc5.d are linked files, linked to the corresponding files in init.d, and scripts in the actual working init.d.
Expansion: rc? The role of .d
In rc?.d? Representing different run levels, / etc/rc.d/rc executes scripts in the corresponding directory according to the run mode specified by its parameters (run level, which you can set in the inittab file). Anything that starts with Kxx is called with stop as a parameter; anything that starts with Sxx is called with start as an argument. The order of the invocation is xx from small to large. For example, assuming that the default running mode is 3Magneto etc/rc.d/rc3.d/ rc.dUnip RC invokes the script under / script as described above.
For example, the run level for entering graphical mode is 5, which means that all processes starting with S in rc5.d will run, and the run level for network multi-user text mode is 3, which means running all processes starting with S in rc3.d.
Single-user mode is rc1.d, if it is rc0.d, it is turned off, in which there is no S, all the process names that begin with K, which means to kill the process.
Note: the rest of the operation (1) exit (2) logout (logout) (3) reboot (restart) (4) shutdown (with parameters, you can use shutdown--help/shutdown -? / man shutdown-man [meaning of the manual- manual] will describe the instructions in detail, exit with Q), that is, power off the virtual machine, and then power off the virtual machine.
(5) generally, the computer will be turned off when you hit init0.
Linux startup hierarchy
Note: NFS network file system, can be connected to the Internet when there is NFS.
Configuration file
The function of etc directory:
The / etc directory is used to store configuration files in the system, and basically all configuration files can be found here. These files are generally named in the form of XXX.conf. By editing these files, you can change and manage the system. For example, / etc/xinetd.conf is the configuration file of the xinetd service, / etc/resolv.conf is used to specify the local DNS server address, and so on.
We have installed a new software. Its configuration files may be stored in the / etc directory, or in another directory, such as the directory where the software main program is located. Sometimes for ease of administration, symbolic links to new software configuration files can be established in the / etc directory so that no matter how the software is installed, we can find its configuration files in the / etc directory.
For example, if the named process configuration file named.conf for the DNS service is generally stored in the / var/named directory, you can establish the above symbolic link with the following command:
# ln-s / var/named/named.conf / etc/named.conf
Modify the configuration of the DNS service later, just edit / etc/named.conf.
Rc0.d is a directory, not a file, as follows:
-- esc any one of the linux instructions five times, and all instructions appear.
-- instruction plus-- help or instruction plus--? You can give the corresponding prompt information of the instruction or use man shutdown--, which can tell us the relevant operation of shutdown.
Exist exits the terminal terminal, shutdown shuts down, and logout logs out.
This is the answer to the question about what the startup sequence of the Linux system is. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.