Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Boot process and Service Control of CentOS 7 system (1)

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1. Diagram of CentOS system startup process

Second, start-up detailed explanation

1. Post

After the server host is powered on, the CPU, memory, graphics card, keyboard and other devices will be initially tested according to the settings in the motherboard BIOS. After successful detection, the control of the system will be transferred according to the preset boot sequence, and will be handed over to the local hard disk most of the time.

2. MBR boot

When booting the system from the local hard disk, first transfer the system control to the partition containing the operating system boot file according to the setting of MBR (Master Boot Record master boot record) in the first sector of the hard disk, or call the boot menu (GRUB) directly according to the boot information in the MBR record.

3. GRUM menu

For Linux systems, GRUB is the most widely used multi-system bootstrap program. After system control is passed to GRUB, a boot menu will be displayed for the user to choose, and the Linux kernel file will be loaded according to the selected option (or default), and then system control will be transferred to the kernel.

4. Add and cut Linux kernel

The Linux kernel is a pre-compiled special binary file, which is between various hardware resources and system programs, and is responsible for resource allocation and scheduling. After the kernel takes over the control of the system, it will completely control the running process of the entire Linux operating system.

5.INIT process initialization

In order to complete the further system boot process, the Linux kernel first loads the "/ sbin/init" program in the system into memory to run (the running program is called a process), and the init process is responsible for completing a series of system initialization processes.

Init process

Similar to using numbers to mark user accounts and group accounts, processes (running programs) in the Linux system are also marked with numbers, and the identity tag of each process is called PID. In the process of booting the Linux system, the init process is the first process in the system, and the PID (process tag) number is always 1.

After the init process runs, other programs in the system will be executed one after another, and new processes will be generated continuously. These processes are called child processes of the init process. Conversely, the init process is the parent process of these processes. Of course, these sub-processes can also further generate their own sub-processes, continue to multiply in turn, and finally form a leafy process tree to provide services for users.

As can be seen from the above description, the init process is the "ancestor" of all the processes running in the entire Linux system, so the init process is not allowed to be terminated easily. When you need to switch between different system running states, you can send the correct execution parameters to the init process, and the init itself will complete the relevant operations.

III. Systemd unit type

four。 Operation level

Linux allows different boot loaders to be assigned to different occasions, which is called "runlevel". That is, at startup, you determine which programs to run according to the run level.

Classification of run level (runlevel):

Five. MBR sector failure repair

The MBR boot record is located in the first sector (512B) of the physical hard disk, which is also known as the main boot sector (MBR sector). It contains not only part of the data of the system boot program, but also the partition table record of the whole hard disk. When the main boot sector fails, you may not be able to enter the boot menu, or you may not be able to load the system because you cannot find the correct partition location, and you are likely to enter a black screen when booting the host through the hard drive.

(1) prepare a disk in advance

(2)。 Back up the MBR boot file to a new disk

Dd if=/dev/sda of=/data/sda.mbr.bak bs=512 count=1

(3)。 Simulated destruction of the mbr boot sector

Dd if=/dev/zero of=/dev/sda bs=512 count=1

(4)。 Restarting reboot will result in the following dhcp search

(5)。 Put the drive of the system image file into, restart, and press the ESC key during the reading process to select CD-ROM Drive

(6)。 Select Troubleshooting troubleshooting issu

(6)。 Select Rescue a Centos system

(7)。 After waiting for a while, enter 1 in the following interface to choose to continue

(8)。 At this time, type ls and you will find that the mount point where we put the backup files is not in the list.

(9)。 Let's create a new mount point and mount the sdb1 to that folder, and you will see the files we backed up earlier

(10)。 Overwrite this backup file to our mbr sector boot file

(11)。 Enter reboot to restart

In this way, the repair is complete.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report