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

What is the boot process started by the Linux system?

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

Share

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

This article introduces the relevant knowledge of "what is the boot process started by the Linux system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

LINUX is free and open source software, in LINUX everything is a file, no matter the command, operation, etc., are saved in the form of a file. This blog is to record where to write the file to complete the boot process when LINUX starts.

The LINUX version used is that CentOS5,CentOS and Ubuntu are both ideal versions for their own contact use.

Take the CentOS5.5 version as an example to introduce the boot process of LINUX. The specific process is as follows:

Each step is described in detail below:

1) the first step of firmware firmware self-test is to perform CMOS/BIOS POST power-up self-test on the hardware, and check whether the hardware is normal at the physical level. For example, check whether the hard drive is plugged in and so on.

2) the second step is to read the BootLoader of MBR in the hard disk, and the self-startup program is commonly used under Linux, GRUB. The main function of this step is to load the kernel. The kernel is stored in the / boot directory

3) the third step is the process of loading kernel Kernel

The main functions are: 1, driver hardware, Kernel contains a large number of drivers. 2. Start init process.

4) the init process, mainly reading the / etc/inittab file, executes the default run level and continues to boot. It should be noted that the PID of the init capital is always 1, which is the parent of all processes, while the negative range of the init process is 0, which is the kernel scheduler Kernel scheduler.

5) / etc/inittab defines the initialization operation.

The main format of the command is: id: runlevels: action: process

Where, as shown in the red box in the above figure

1. There are 7 running levels of run-levels, and 0mur6 is as follows:

0-halt shutdown

1-Single user mode single user mode

2-Multiuser,withoutNFS multiuser mode without network (text mode)

3-Full multiuser mode fully functional multi-user mode (text mode)

4-unused reservation

5-X11 graphical multiuser mode

6-reboot restart

You can switch according to these 7 run levels.

The command is: view current runlevel # runlevel, switch runlevel # init [0 | 1 | 2 | 3 | 4 | 5 | 6]

2. There are also several important values in acion:

1 initdefault: specify the default startup level of the system, as shown in the figure above, which is usually used for repair. For example, if we want to enter single-user mode, we can set it to 1, not 0 or 6 by default, otherwise it cannot be started.

2sysinit: the system starts to execute the commands specified in process

As can be seen from the contents of the inittab file, the runlevel is not set, that is, / etc/rc.d/rc.sysinit will be executed no matter which runlevel it is.

6) initdefault, as mentioned in step 5, mainly reads the information in / etc/inittab to determine what the default run level is.

7) / etc/rc.d/rc.sysinit

Run to line 21 in the inittab file and start the script instead. Complete the startup of the system service program, such as setting the system environment variables, setting the system clock, loading fonts, checking the loading file system, generating system startup information log files, and so on. Because it is a basic service, because its run-level is set to empty:: that is, any level, action is set to sysinit. That is, the script needs to be started at any run level to complete the startup of the basic service.

8) after the basic service is started, the script / etc/rc.d/rc will be executed

After loading the basic service, start the corresponding directory according to different running levels. Its working principle is to determine the default running level of the system, that is, what is in step 6, and then execute the service startup script under the corresponding rcN.d directory as shown in the figure.

9) execute the service startup script in the / etc/rc.d/rcN.d directory

Take a look at the contents of this directory:

Where S represents the script to start and K represents the script to be closed

The number indicates the start order, and the value with small value takes precedence. Mainly the management of some services.

In this step, you need to explain the / etc/rc.d/init.d directory. The scripts in this directory are real scripts, while those in rcN.d are all soft links in the init.d directory, that is, all the files in rcN.d eventually need to look for real scripts in init.d.

Take a look at the details:

At this point, the interface will prompt for the user name and password, that is to say, the system is up. After the process of entering the user name and password, the boot process is over.

Finally, it should be noted that the idea of LINUX's boot process is roughly the same, but the details are different because of the version, the name or location of the configuration file is different, this time I use the CentOS version, and the Ubuntu version does not have inittab files and grup.conf files, so if you are interested, you can follow this way of thinking to explore.

PS: about GRUB

GNU GRUB ("GRUB" for short) is a boot loader from the GNU project. GRUB is an implementation of the multi-boot specification, which allows users to have multiple operating systems in the computer at the same time and choose which operating system they want to run when the computer starts. GRUB can be used to select different kernels on operating system partitions or to pass boot parameters to those kernels.

The predecessor of GNU GRUB is Grand Unified Bootloader. It is mainly used for Unix-like systems; like most Linux distributions, GNU systems use GNU GRUB as its initiator. Solaris has also used GNU GRUB as the initiator on x86 systems since version 06.

GRUB is dynamically configurable; it loads configuration information at startup and allows modifications at startup, such as selecting different kernels and initrd. To this end, GRUB provides a simple Bash-like command-line interface that allows users to write new startup sequences.

GRUB is very light. It supports multiple executable formats; in addition to operating systems that support multiple booting, it also supports operating systems that do not support multiple booting, such as Windows and OS/2, through chained boot functions. GRUB supports all Unix file systems, as well as FAT and NTFS file systems for Windows, as well as LBA mode. GRUB allows users to view the contents of files in the file system it supports.

GRUB has a variety of user interfaces. Most Linux distributions take advantage of GRUB's support for graphical interfaces, providing customized startup menus with background patterns, and sometimes mouse support. By setting the text interface of GRUB, the remote terminal can be started through serial port.

GRUB can download operating system images from the network, so it can support diskless systems. GRUB supports decompressing its image before starting the operating system.

Unlike other initiators, GRUB can interact directly with the user through the GRUB prompt. Before loading the operating system, type c in the GRUB text mode screen to enter the GRUB command line. You can also enter the GRUB prompt on systems that do not have an operating system or have an operating system without a "menu.lst" file. With commands like bash, the GRUB prompt allows the user to start any operating system manually. By recording the appropriate commands in the "menu.lst" file, an operating system can be started automatically.

GRUB has a wealth of terminal commands that users can view the details of hard disk partitions, modify partition settings, temporarily remap disk order, boot from any user-defined configuration file, and view the configuration of other initiators on file systems supported by GRUB. So, even if you don't know what's installed on a computer, you can boot an operating system from an external device.

GRUB scrolls the screen to select the operating system you want to boot. By adding relevant information to the "menu.lst" file, GRUB can control 150 or more startup options and use the arrow keys to select them at startup.

Through chain startup, one starter can start another. GRUB can be launched from DOS, Windows, Linux, BSD, and Solaris systems with 2-3 lines of command.

Although GRUB compiles and packages Unix-like systems, there is also a GRUB for DOS and Windows. GRUB can also be installed as an isolated system without any operating system. Using GRUB when booting from CD requires 1 file, while booting from floppy disk, hard disk, and USB devices requires 2 files. These files can be found on any Linux CD that supports GRUB, and users can find them easily.

This is the end of the content of "what is the boot process started by the Linux system". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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: 273

*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