linux系统引导七个步骤
An operating system (OS) is the low-level software that manages resources, controls peripherals, and provides basic services to other software. In Linux, there are 6 distinct stages in the typical booting process.
操作系统(OS)是管理资源,控制外围设备并向其他软件提供基本服务的低级软件。 在Linux中,典型的引导过程分为6个不同的阶段。
1. BIOS (1. BIOS)
BIOS stands for Basic Input/Output System. In simple terms, the BIOS loads and executes the Master Boot Record (MBR) boot loader.
BIOS代表基本输入/输出系统。 简单来说,BIOS会加载并执行主引导记录(MBR)引导加载程序。
When you first turn on your computer, the BIOS first performs some integrity checks of the HDD or SSD.
首次打开计算机时,BIOS首先对HDD或SSD进行完整性检查。
Then, the BIOS searches for, loads, and executes the boot loader program, which can be found in the Master Boot Record (MBR). The MBR is sometimes on a USB stick or CD-ROM such as with a live installation of Linux.
然后,BIOS搜索,加载并执行引导加载程序,该程序可在主引导记录(MBR)中找到。 MBR有时位于USB记忆棒或CD-ROM上,例如在Linux的实时安装中。
Once the boot loader program is detected, it's then loaded into memory and the BIOS gives control of the system to it.
一旦检测到引导加载程序,它将被加载到内存中,然后BIOS将控制权交给它。
2. MBR (2. MBR)
MBR stands for Master Boot Record, and is responsible for loading and executing the GRUB boot loader.
MBR代表主引导记录,并负责加载和执行GRUB引导加载程序。
The MBR is located in the 1st sector of the bootable disk, which is typically /dev/hda
, or /dev/sda
, depending on your hardware. The MBR also contains information about GRUB, or LILO in very old systems.
MBR位于可启动磁盘的第一个扇区,通常是/dev/hda
或/dev/sda
,具体取决于您的硬件。 MBR还包含有关GRUB或旧系统中的LILO的信息。
3. GRUB (3. GRUB)
Sometimes called GNU GRUB, which is short for GNU GRand Unified Bootloader, is the typical boot loader for most modern Linux systems.
有时称为GNU GRUB(GNU GRand统一引导加载程序的缩写),是大多数现代Linux系统的典型引导加载程序。
The GRUB splash screen is often the first thing you see when you boot your computer. It has a simple menu where you can select some options. If you have multiple kernel images installed, you can use your keyboard to select the one you want your system to boot with. By default, the latest kernel image is selected.
引导计算机时,通常会首先看到GRUB初始屏幕。 它有一个简单的菜单,您可以在其中选择一些选项。 如果安装了多个内核映像,则可以使用键盘选择要用于系统引导的映像。 默认情况下,选择最新的内核映像。
The splash screen will wait a few seconds for you to select and option. If you don't, it will load the default kernel image.
启动屏幕将等待几秒钟,供您选择和选择。 如果不这样做,它将加载默认的内核映像。
In many systems you can find the GRUB configuration file at /boot/grub/grub.conf
or /etc/grub.conf
. Here's an example of a simple grub.conf
file:
在许多系统中,可以在/boot/grub/grub.conf
或/etc/grub.conf
找到GRUB配置文件。 这是一个简单的grub.conf
文件的示例:
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-194.el5PAE)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-194.el5PAE ro root=LABEL=/
initrd /boot/initrd-2.6.18-194.el5PAE.img
4.内核 (4. Kernel)
The kernel is often referred to as the core of any operating system, Linux included. It has complete control over everything in your system.
内核通常被称为任何操作系统(包括Linux)的核心。 它可以完全控制系统中的所有内容。
In this stage of the boot process, the kernel that was selected by GRUB first mounts the root file system that's specified in the grub.conf
file. Then it executes the /sbin/init
program, which is always the first program to be executed. You can confirm this with its process id (PID), which should always be 1.
在引导过程的此阶段,由GRUB选择的内核首先安装grub.conf
文件中指定的根文件系统。 然后,它执行/sbin/init
程序,该程序始终是要执行的第一个程序。 您可以通过其进程ID(PID)确认此值,该ID应该始终为1。
The kernel then establishes a temporary root file system using Initial RAM Disk (initrd) until the real file system is mounted.
然后,内核会使用Initial RAM Disk(initrd)建立一个临时根文件系统,直到安装了实际文件系统为止。
5.初始化 (5. Init)
At this point, your system executes runlevel programs. At one point it would look for an init file, usually found at /etc/inittab
to decide the Linux run level.
此时,您的系统将执行运行级别程序。 有时它会寻找一个init文件,该文件通常在/etc/inittab
找到,以确定Linux的运行级别。
Modern Linux systems use systemmd to choose a run level instead. According to TecMint, these are the available run levels:
现代Linux系统使用systemmd来选择运行级别。 根据TecMint的介绍 ,以下是可用的运行级别:
Run level 0 is matched by poweroff.target (and runlevel0.target is a symbolic link to poweroff.target).
运行级别0与poweroff.target匹配( runlevel0.target是指向poweroff.target的符号链接)。
Run level 0 is matched by poweroff.target (and runlevel0.target is a symbolic link to poweroff.target).
运行级别0与poweroff.target匹配( runlevel0.target是poweroff.target的符号链接)。
Run level 0 is matched by poweroff.target (and runlevel0.target is a symbolic link to poweroff.target).Run level 1 is matched by rescue.target (and runlevel1.target is a symbolic link to rescue.target).
运行级别0与poweroff.target匹配( runlevel0.target是指向poweroff.target的符号链接)。 运行级别1与result.target匹配(而runlevel1.target是到rescue.target的符号链接)。
Run level 0 is matched by poweroff.target (and runlevel0.target is a symbolic link to poweroff.target).Run level 1 is matched by rescue.target (and runlevel1.target is a symbolic link to rescue.target).
运行级别0与poweroff.target匹配( runlevel0.target是指向poweroff.target的符号链接)。 运行级别1与result.target匹配(而runlevel1.target是到rescue.target的符号链接)。
Run level 0 is matched by poweroff.target (and runlevel0.target is a symbolic link to poweroff.target).Run level 1 is matched by rescue.target (and runlevel1.target is a symbolic link to rescue.target).Run level 3 is emulated by multi-user.target (and runlevel3.target is a symbolic link to multi-user.target).
运行级别0与poweroff.target匹配( runlevel0.target是指向poweroff.target的符号链接)。 运行级别1与result.target匹配(而runlevel1.target是到rescue.target的符号链接)。 运行级别 3由multi-user.target仿真(而runlevel3.target是指向multi-user.target的符号链接)。
Run level 0 is matched by poweroff.target (and runlevel0.target is a symbolic link to poweroff.target).Run level 1 is matched by rescue.target (and runlevel1.target is a symbolic link to rescue.target).Run level 3 is emulated by multi-user.target (and runlevel3.target is a symbolic link to multi-user.target).
运行级别0与poweroff.target匹配( runlevel0.target是指向poweroff.target的符号链接)。 运行级别1与result.target匹配(而runlevel1.target是到rescue.target的符号链接)。 运行级别 3由multi-user.target仿真(而runlevel3.target是指向multi-user.target的符号链接)。
Run level 0 is matched by poweroff.target (and runlevel0.target is a symbolic link to poweroff.target).Run level 1 is matched by rescue.target (and runlevel1.target is a symbolic link to rescue.target).Run level 3 is emulated by multi-user.target (and runlevel3.target is a symbolic link to multi-user.target).Run level 5 is emulated by graphical.target (and runlevel5.target is a symbolic link to graphical.target).
运行级别0与poweroff.target匹配( runlevel0.target是指向poweroff.target的符号链接)。 运行级别1与result.target匹配(而runlevel1.target是到rescue.target的符号链接)。 运行级别 3由multi-user.target模拟(而runlevel3.target是指向multi-user.target的符号链接)。 运行级别5通过graphical.target仿真(和runlevel5.target是符号链接到graphical.target)。
Run level 0 is matched by poweroff.target (and runlevel0.target is a symbolic link to poweroff.target).Run level 1 is matched by rescue.target (and runlevel1.target is a symbolic link to rescue.target).Run level 3 is emulated by multi-user.target (and runlevel3.target is a symbolic link to multi-user.target).Run level 5 is emulated by graphical.target (and runlevel5.target is a symbolic link to graphical.target).
运行级别0与poweroff.target匹配( runlevel0.target是指向poweroff.target的符号链接)。 运行级别1与result.target匹配(而runlevel1.target是到rescue.target的符号链接)。 运行级别 3由multi-user.target仿真(而runlevel3.target是指向multi-user.target的符号链接)。 运行级别5通过graphical.target仿真(和runlevel5.target是符号链接到graphical.target)。
Run level 0 is matched by poweroff.target (and runlevel0.target is a symbolic link to poweroff.target).Run level 1 is matched by rescue.target (and runlevel1.target is a symbolic link to rescue.target).Run level 3 is emulated by multi-user.target (and runlevel3.target is a symbolic link to multi-user.target).Run level 5 is emulated by graphical.target (and runlevel5.target is a symbolic link to graphical.target).Run level 6 is emulated by reboot.target (and runlevel6.target is a symbolic link to reboot.target).
运行级别0与poweroff.target匹配( runlevel0.target是指向poweroff.target的符号链接)。 运行级别1与result.target匹配(而runlevel1.target是到rescue.target的符号链接)。 运行级别 3由multi-user.target仿真(而runlevel3.target是指向multi-user.target的符号链接)。 运行级别5通过graphical.target仿真(和runlevel5.target是符号链接到graphical.target)。 运行级别6由reboot.target仿真(而runlevel6.target是指向reboot.target的符号链接)。
Run level 0 is matched by poweroff.target (and runlevel0.target is a symbolic link to poweroff.target).Run level 1 is matched by rescue.target (and runlevel1.target is a symbolic link to rescue.target).Run level 3 is emulated by multi-user.target (and runlevel3.target is a symbolic link to multi-user.target).Run level 5 is emulated by graphical.target (and runlevel5.target is a symbolic link to graphical.target).Run level 6 is emulated by reboot.target (and runlevel6.target is a symbolic link to reboot.target).
运行级别0与poweroff.target匹配( runlevel0.target是指向poweroff.target的符号链接)。 运行级别1与result.target匹配(而runlevel1.target是到rescue.target的符号链接)。 运行级别 3由multi-user.target仿真(而runlevel3.target是指向multi-user.target的符号链接)。 运行级别5通过graphical.target仿真(和runlevel5.target是符号链接到graphical.target)。 运行级别6由reboot.target仿真(而runlevel6.target是指向reboot.target的符号链接)。
Run level 0 is matched by poweroff.target (and runlevel0.target is a symbolic link to poweroff.target).Run level 1 is matched by rescue.target (and runlevel1.target is a symbolic link to rescue.target).Run level 3 is emulated by multi-user.target (and runlevel3.target is a symbolic link to multi-user.target).Run level 5 is emulated by graphical.target (and runlevel5.target is a symbolic link to graphical.target).Run level 6 is emulated by reboot.target (and runlevel6.target is a symbolic link to reboot.target).Emergency is matched by emergency.target.
运行级别0与poweroff.target匹配( runlevel0.target是指向poweroff.target的符号链接)。 运行级别1与result.target匹配(而runlevel1.target是到rescue.target的符号链接)。 运行级别 3由multi-user.target仿真(而runlevel3.target是指向multi-user.target的符号链接)。 运行级别5通过graphical.target仿真(和runlevel5.target是符号链接到graphical.target)。 运行级别6由reboot.target仿真(而runlevel6.target是指向reboot.target的符号链接)。 紧急被emergency.target匹配。
systemmd will then begin executing runlevel programs.
然后,systemmd将开始执行运行级别程序。
6.运行级别程序 (6. Runlevel programs)
Depending on which Linux distribution you have installed, you may be able to see different services getting started. For example, you might catch starting sendmail …. OK
.
根据您安装的Linux发行版,您可能会看到不同的服务入门。 例如,您可能会捕获starting sendmail …. OK
starting sendmail …. OK
These are known as runlevel programs, and are executed from different directories depending on your run level. Each of the 6 runlevels described above has its own directory:
这些称为运行级别程序,根据运行级别从不同目录执行。 上述6个运行级别中的每一个都有自己的目录:
- Run level 0 –
/etc/rc0.d/
运行级别0 –/etc/rc0.d/
- Run level 1 –
/etc/rc1.d/
运行级别1 –/etc/rc1.d/
- Run level 2 –
/etc/rc2.d/
运行级别2 –/etc/rc2.d/
- Run level 3 –
/etc/rc3.d/
运行级别3 –/etc/rc3.d/
- Run level 4 –
/etc/rc4.d/
运行级别4 –/etc/rc4.d/
- Run level 5 –
/etc/rc5.d/
运行级别5 –/etc/rc5.d/
- Run level 6 –
/etc/rc6.d/
运行级别6 –/etc/rc6.d/
Note that the exact location of these directories varies from distribution to distribution.
请注意,这些目录的确切位置因分发而异。
If you look in the different run level directories, you'll find programs that start with either an "S" or "K" for startup and kill, respectively. Startup programs are executed during system startup, and kill programs during shutdown.
如果在不同的运行级别目录中查找,则会发现以“ S”或“ K”开头的程序分别用于启动和终止。 启动程序在系统启动期间执行,并在关闭期间终止程序。
That's everything you need to know about the Linux booting process. Now go out there and make Tux proud.
这就是您需要了解的有关Linux启动过程的所有信息。 现在去那里,让Tux感到骄傲。