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

Process Analysis of Linux Startup process

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

Share

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

This article is about the process analysis of the Linux startup process. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Start the first step-- load BIOS

When you power on the computer, the computer will load BIOS information first. BIOS information is so important that the computer must find it at the beginning. This is because BIOS contains CPU-related information, device boot sequence information, hard disk information, memory information, clock information, PnP features, and so on. After that, the computer knows which hardware device to read.

Start the second step-- read MBR

As we all know, the first sector of track 0 on the hard disk is called MBR, that is, Master Boot Record, that is, the master boot record. Its size is 512 bytes, although the space is small, but it contains pre-boot information and partition table information.

After the system finds the MBR of the hard drive specified by BIOS, it will copy it to the physical memory where the 0 × 7c00 address is located. In fact, what is copied to physical memory is Boot Loader, and for your computer, it is lilo or grub.

Start the third step-- Boot Loader

Boot Loader is a piece of Mini Program that runs before the operating system kernel runs. Through this Mini Program, we can initialize the hardware devices and establish a memory space mapping, thus bringing the software and hardware environment of the system to an appropriate state, so as to make everything ready for the final call to the operating system kernel.

There are several kinds of Boot Loader, among which Grub, Lilo and spfdisk are common Loader.

Let's take Grub as an example. After all, not many people use lilo and spfdisk.

The system reads the grub configuration information in memory (usually menu.lst or grub.lst) and starts different operating systems according to this configuration information.

Start the fourth step-- load the kernel

According to the path of the kernel image set by grub, the system reads the memory image and decompresses it. At this point, the screen usually outputs a prompt for "Uncompressing Linux". When the kernel is unzipped, the screen outputs "OK, booting the kernel".

The system places the decompressed kernel in memory and calls the start_kernel () function to start a series of initialization functions and initialize various devices to complete the establishment of the Linux core environment. At this point, the Linux kernel has been set up, and Linux-based programs should work properly.

Start the fifth step-the user layer init sets the running level according to the inittab file

After the kernel is loaded, the first program to run is / sbin/init, which reads the / etc/inittab file and initializes it based on it.

In fact, the main function of the / etc/inittab file is to set the running level of Linux, which is set in the form of ": id:5:initdefault:", which indicates that Linux needs to run on level 5. The running level of Linux is set as follows:

0: shutdown

1: single user mode

2: multi-user mode without network support

3: multi-user mode with network support

4: reserved, unused

5: multi-user mode with network support and X-Window support

6: reboot the system, that is, restart

As a matter of fact, there is still a lot of knowledge about the / etc/inittab file, which is designed in the post-preface article. Please look forward to it.

Start step 6-- the init process executes rc.sysinit

After setting the running level, the first user-level file executed by the Linux system is the / etc/rc.d/rc.sysinit script, which does a lot of work, including setting PATH, setting network configuration (/ etc/sysconfig/network), starting swap partition, setting / proc, and so on. If you are interested, you can check the rc.sysinit file in / etc/rc.d. The script in it will last you for a few days: P

Start step 7-start the kernel module

Specifically, the kernel module is loaded according to the / etc/modules.conf file or the file in the / etc/modules.d directory.

Start step 8-execute scripts at different run levels

Depending on the running level, the system will run the corresponding script from rc0.d to rc6.d to complete the corresponding initialization work and start the corresponding service.

Start step 9-execute / etc/rc.d/rc.local

If you open this file, there is a sentence in it. After reading it, you will know the function of this command at a glance:

# This script will be executed * after* all the other init scripts.

# You can put your own initialization stuff in here if you don't

# want to do the full Sys V style init stuff.

Rc.local is the place where Linux is left for users to personalize after all initialization work. You can put what you want to set up and start up here.

Start step 10-execute the / bin/login program and enter the login state

At this point, the system has entered the time to wait for users to enter username and password, and you can log in to the system with your own account. :)

Thank you for reading! This is the end of this article on "process Analysis of Linux Startup process". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

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