In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
CentOS6 system startup process
The operating system (OS) is also a program. If you let this special program run after the hardware is powered on, and what this particular program does during startup, as shown in the following figure:
can be seen from the figure that system startup (not just Linux) can be roughly divided into several main processes: hardware initialization-- > find and load the operating system kernel-- > kernel initialization-- > operating system operating environment initialization-- > login initialization-- > user initialization after successful login (including initialization of graphical interface or shell)-> end user successfully enter
The operating system and start using the operating system.
The following is a brief description of the above main processes with an example of CentOS6 system entry command behavior.
1. Press the power supply to power on. When the motherboard is powered on, CPU begins to work, executing a very small hard-coding program at the fixed address: BIOS, so BIOS takes control of CPU.
The 2.BIOS program performs a power-on self-test (Power-On Self-Test,POST) of the hardware to determine what hardware is available and whether it is faulty. For the operating system boot process we are going to explore, the most important thing is to find the correct MBR on these disks in order according to the order in which disks are detected (besides disks, it can also be other hardware devices, such as USB drives, CDs, network cards, etc.), and MBR begins to take control of CPU.
3.MBR is the first piece of code that boots the kernel of the system, and its location is fixed in the first sector of the disk (if not fixed, you don't know how to find MBR). The code segment that boots the kernel is called BootLoader. In addition to MBR, you need to boot the kernel step by step through other code segments of the boot system, so to boot a kernel, you need to jump and execute multiple segments of BootLoader. Depending on the boot management tools used (such as LILIO, GRUB, GRUB2, etc.), the title and location of the boot code snippet in this section are different, but the first code segment that boots the kernel must be called MBR, and it must be in the first sector of the disk, so MBR is called the master boot record (Master Boot Record).
4. When the kernel image is found, the kernel image is loaded into memory and unzipped (if compressed), and the kernel begins to take control of CPU and run, during which the kernel does a lot of work, including initializing the kernel, mounting the real root directory and switching from the temporary root directory to the real root directory, starting some important processes such as idle, process scheduler, init process, and so on. Then start executing the first process in user space, the init process, so the init process takes control of CPU and begins to enter user space.
After the 5.init process starts running, it means that the operating system has really started successfully, but it still needs to do system-level initialization, such as setting hostname, setting hardware parameters, loading hardware drivers, mounting some file systems in / etc/fstab, and so on. After all the initialization of the system-level running environment is completed, the user login interface is provided, that is, init starts the process of the getty class.
After the process of the 6.getty class starts, it will open a terminal and prompt the user to enter a user name, then start a login process to let the user enter and verify the password. After the password verification, the user has the right to log in. If the login is allowed, the corresponding shell process of the user, such as the bash process, will be started according to the configuration in / etc/passwd.
After the 7.shell process starts, it reads the configuration file corresponding to the shell and initializes it according to the login and interactive shell operation mode. After the initialization is completed, it will enter the login and interactive shell, that is, under the command line.
8. At this point, users can use the operating system through the shell command line.
CentOS7 system startup process
There are two major differences between CentOS7 startup and CentOS6 startup:
1) in the kernel boot phase, CentOS7 uses grub2 boot by default, while CentOS6 uses traditional grub boot by default.
2) initialization of the system environment and the following process. After the kernel initialization is completed, the process of starting PID=1, and this process in CentOS7 is systemd, which is quite different from the initialization of the init process in CentOS6.
Systemd features:
1) realize parallel startup of service during system initialization.
2) start the daemon as needed
3) automatic service dependency management
4) use both socket and D-Bus bus activation services
5) Snapshot of system status.
The following is a brief description of the CentOS7 startup process, details refer to: man bootup help manual.
1) initialize UEFI or BIOS and run POST post
2) Select the boot device
3) Boot the kernel, do some kernel initialization, and load initramfs
4) start the systemd process, and the systemd process works in the initramfs environment
5) systemd executes all units of initrd.target, including mounting / etc/fstab, switching from the virtual root file system of ramdisk to the real root file system
6) systemd executes the default target configuration, and its configuration file is / etc/systemd/system/default.target
7) systemd executes sysinit.target initialization system and basic.target prepares operating system
8) systemd starts native and server services under multi-user.target
9) systemd executes / etc/rc.d/rc.local under multi-user.target
10) systemd executes getty.target under multi-user.target to allow users to log in
11) start the shell process and initialize it, and finally enter the command line
The most important thing to pay attention to in the above process of is that the work of systemd is well ahead of schedule: it is involved in the rest of the work during the kernel initialization phase. When systemd finishes switching over the root file system, it will officially enter the initialization process of the operating system, which will proceed to step 6), that is, select the default "run level" according to the default target configuration file default.targe.
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: 271
*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.