Linux 的启动流程可以分为 5 个阶段:
1. 内核引导:当计算机启动时,首先运行 BIOS 程序,该程序会检查硬件设备,然后加载主引导记录(MBR)。MBR 通常存储在硬盘的第一个扇区中,它包含一个小程序,称为引导加载程序,该程序负责加载 Linux 内核。
2. 内核加载:引导加载程序从硬盘上加载 Linux 内核映像,并将其加载到内存中。然后,引导加载程序将控制权转移给内核。
3. 内核初始化:内核加载后,它将初始化硬件设备,建立内存映射,并启动其他必要的系统进程。
4. 启动 init 进程:内核初始化完成后,它会启动第一个用户进程,即 init 进程。init 进程是所有其他用户进程的父进程,它负责启动系统的其他部分,如文件系统、网络等。
5. 用户登录:init 进程启动后,会启动登录进程(login process),等待用户登录。用户登录后,登录进程会启动用户的 shell 进程,用户就可以与系统进行交互了。
整个 Linux 启动流程可以概括为:BIOS 程序→MBR 中的引导加载程序→Linux 内核→init 进程→登录进程→用户 shell 进程。
The Linux boot process can be divided into five stages:
1. Kernel boot: When the computer starts, the BIOS program is executed first, which checks the hardware devices and then loads the Master Boot Record (MBR). The MBR usually stores in the first sector of the hard drive and contains a small program called the boot loader, which is responsible for loading the Linux kernel.
2. Kernel loading: The boot loader loads the Linux kernel image from the hard drive and loads it into memory. Then, the boot loader transfers control to the kernel.
3. Kernel initialization: After the kernel is loaded, it initializes the hardware devices, establishes memory mappings, and starts other necessary system processes.
4. Start the init process: After kernel initialization is complete, it starts the first user process, which is the init process. The init process is the parent process of all other user processes and is responsible for starting other parts of the system, such as the file system and network.
5. User login: After the init process starts, it starts the login process and waits for the user to log in. After the user logs in, the login process starts the user's shell process, and the user can interact with the system.
The entire Linux boot process can be summarized as: BIOS program → boot loader in MBR → Linux kernel → init process → login process → user shell process.
Mbr
引导程序
加载程序
在启动前需要安装Linux系统
建立内存映射
内核初始化
内核进程
Linux内核