egret启动服务器

egret启动服务器_启动服务器

Even the most experienced and highly qualified system administrators often have only a vague idea of what exactly happens during the server startup process. So, let's look at this process in detail.

即使是最有经验和最有资格的系统管理员,也往往对服务器启动过程中到底发生了什么一无所知。 因此,让我们详细看一下这个过程。

Server startup is a long and complicated series of operations depending on hardware, software, and the enabled configuration.

服务器启动是一系列漫长而复杂的操作,具体取决于硬件,软件和已启用的配置。

Without looking at all possible scenarios, let's see what happens during server startup in the following environment:

在不考虑所有可能的情况的情况下,让我们看看在以下环境中服务器启动期间会发生什么:

  • 64-bit Intel processor;

    64位Intel处理器;
  • Legacy startup mode;

    旧版启动模式;
  • MBR disk format;

    MBR磁盘格式;
  • GRUB2 loader.

    GRUB2加载程序。

升起,闪耀! (Rise and shine!)

The server startup is initiated using different methods, for example, by pressing

使用不同的方法(例如,通过按

打开 (Power On)

(most often). Another option is to use a network command (

(最经常)。 另一种选择是使用网络命令(

局域网唤醒 (Wake-on-LAN)

) or commands from external devices (

)或来自外部设备的命令(

PCIe唤醒,键盘唤醒,鼠标唤醒 (Wake-on-PCIe, Wake-on-Keyboard, Wake-on-Mouse)

). Commands are executed only if the corresponding parameters are enabled in

)。 仅在启用了相应参数的情况下才执行命令

BIOS设置实用程序 (BIOS Setup Utility)

(see below).

(见下文)。

The BMC module, which provides advanced server control options, is considered an individual device.

提供高级服务器控制选项的BMC模块被视为单独的设备。

The above methods are smart and require a specifically created command to be sent via data buses. A simple method is to start up when electricity becomes available in the power supply unit. In BIOS settings, this parameter is called AC Power Loss. It has three states:

上面的方法很聪明,需要通过数据总线发送专门创建的命令。 一种简单的方法是在电源单元中有电时启动。 在BIOS设置中,此参数称为交流电源损耗。 它具有三种状态:

  • 断电 (Power Off)

    — the server remains disabled.

    —服务器保持禁用状态。

  • 打开 (Power On)

    — the server starts up.

    —服务器启动。

  • 最后状态 (Last State)

    — the server only starts if it was on during the power supply loss.

    —仅在电源中断期间打开服务器时,服务器才能启动。

When using these methods, the processor receives the Reset signal and begins the startup procedure.

使用这些方法时,处理器会收到复位信号并开始启动过程。

第一次程序加载 (First program loading)

The first stage of the server startup is turning on the power supply unit and sending the

服务器启动的第一阶段是打开电源设备并发送

重启 (Reset)

signal to the processor. If the

信号发送给处理器。 如果

重启 (Reset)

signal is available, the processor clock generator is disabled, while processor registers are reset to factory settings.

信号可用,处理器时钟发生器被禁用,而处理器寄存器被重置为出厂设置。

During startup, transition processes occur in the power supply unit. Because of these processes, the output voltage may go beyond acceptable levels and negatively impact the processor operation. Therefore, the

在启动过程中,电源设备中会发生过渡过程。 由于这些过程,输出电压可能会超过可接受的水平,并对处理器的运行产生负面影响。 因此,

重启 (Reset)

signal is not removed until input power is completely stabilized.

在输入电源完全稳定之前,信号不会被消除。

Once the voltage is stable, the power supply unit sets the

电压稳定后,电源设备会设置

电源良好 (Power Good)

signal. This signal means that the motherboard can start all the server components. Then, the chipset maps all the connected devices to the address space, including ROM (read-only memory), using the following code:

信号。 该信号表示主板可以启动所有服务器组件。 然后,芯片组使用以下代码将所有连接的设备映射到地址空间,包括ROM(只读存储器):

基本输入输出系统 (Basic Input/Output System)

(BIOS). Then, the

(BIOS)。 然后,

重启 (Reset)

signal is removed, and the processor clock generator is started.

信号被删除,处理器时钟发生器被启动。

BIOS is a system that provides an API for managing hardware and connected devices. An important BIOS function is equipment initialization and testing during startup.

BIOS是一个提供用于管理硬件和连接的设备的API的系统。 BIOS的一项重要功能是在启动过程中进行设备初始化和测试。

egret启动服务器_启动服务器

Regardless of the number of system processes, only one core of one processor is woken up, while the other cores remain idle. This core is designated as

无论系统进程有多少,一个处理器中只有一个内核被唤醒,而其他内核则保持空闲状态。 该核心被指定为

自举处理器 (Bootstrap Processor)

(BSP, aka «the processor»). Once the

(BSP,又名“处理器”)。 一旦

重启 (Reset)

signal is removed, the processor registers are filled so that the processor operates in a special 32-bit mode called

信号被删除,处理器寄存器被填充,以便处理器以特殊的32位模式运行,称为

初始处理器模式 (Initial Processor Mode)

.

初始处理器模式 (Initial Processor Mode)

is the operation mode reached by the 64-bit processor only after reset. In this mode, the processor can execute 32-bit commands, while the address space is 4 GiB.

是只有复位后64位处理器才能达到的操作模式。 在这种模式下,处理器可以执行32位命令,而地址空间为4 GiB。

Once the

一旦

重启 (Reset)

signal is off, the processor command counter indicates the

信号关闭,处理器命令计数器指示

0xFFFFFFF0 (0xFFFFFFF0)

address, which is called the

地址,称为

重置向量 (Reset Vector)

. This is the address of the first command to be decoded and executed by the processor.

。 这是要由处理器解码和执行的第一条命令的地址。

Later, when Intel 80286 appeared, the reset vector could be moved to any location. Nevertheless, even modern processors start up in a mode compatible with 8086 and reset vector at 0x0.

后来,当Intel 80286出现时,复位向量可以移到任何位置。 尽管如此,即使是现代处理器也以与8086兼容的模式启动,并将矢量重置为0x0。

When calling the

致电时

0xFFFFFFF0 (0xFFFFFFF0)

address, the processor receives the first command from ROM. In

地址,处理器从ROM接收第一条命令。 在

遗产 (Legacy)

mode, this command is a

模式,此命令是

跳远 (Far Jump)

to the memory segment with the BIOS code. Once the first far jump has been performed, the processor enters the 16-bit

带有BIOS代码的内存段。 一旦执行了第一个远跳转,处理器就会进入16位

实模式 (Real Mode)

and begins executing the BIOS code.

并开始执行BIOS代码。

实模式 (Real Mode)

is a mode for compatibility with legacy 16-bit processors. In this mode, only 16-bit commands are available, while the address space («low memory») is limited by 1 MiB.

是与旧版16位处理器兼容的一种模式。 在此模式下,仅16位命令可用,而地址空间(«低内存»)受1 MiB限制。

As I mentioned before, the executable BIOS code is stored on an external device, which is a slow operation mode. So, first of all, BIOS initializes random access memory and copies its own ROM code to it. The BIOS remains compatible with legacy processors and performs all operations in 16-bit mode.

如前所述,可执行BIOS代码存储在外部设备上,这是一种缓慢的操作模式。 因此,首先,BIOS初始化随机存取存储器并将其自己的ROM代码复制到其中。 BIOS仍与旧式处理器兼容,并以16位模式执行所有操作。

开机自检 (Power On Self-Test)

开机自检 (Power On Self-Test)

(POST) is a key stage of the BIOS operation. POST can be full or partial. During full POST, all available controllers are checked and all the available RAM is tested, which may take a long time.

(POST)是BIOS操作的关键阶段。 POST可以全部或部分。 在完整POST期间,将检查所有可用的控制器并测试所有可用的RAM,这可能需要很长时间。

Partial POST makes startup faster and includes the minimum required range of operations:

部分POST使启动速度更快,并包括所需的最小操作范围:

  • checking integrity of BIOS programs in ROM using the checksum comparison mechanism;

    使用校验和比较机制检查ROM中BIOS程序的完整性;
  • detecting and initializing main controllers, system buses and connected devices;

    检测并初始化主控制器,系统总线和连接的设备;
  • determining the random access size and testing the first segment (64 kilobytes);

    确定随机访问大小并测试第一段(64 KB);
  • transferring control to the loader.

    将控制权转移到加载程序。

During POST, the server uses several methods to display information about passing tests. The most common are:

在POST期间,服务器使用几种方法来显示有关通过测试的信息。 最常见的是:

  • displaying the test identifier, POST code on the screen or using 7-segment motherboard indicators;

    在屏幕上显示测试标识符,POST代码或使用7段主板指示器;
  • audible indication;

    声音指示;
  • light signalling using LED combinations.

    使用LED组合发出光信号。
egret启动服务器_启动服务器

Displaying the current POST code is considered the most informative method of obtaining information about potential failures. If tests are passed successfully, codes alternate quickly. In the event of a fault, however, POST will be suspended and you will be able to see the failed test identifier. Motherboard manufacturers always enclose the description of what each code means.

显示当前POST代码被认为是获取有关潜在故障信息的最有用的方法。 如果测试成功通过,则代码会快速交替。 但是,如果发生故障,POST将被挂起,您将能够看到失败的测试标识符。 主板制造商总是附上每个代码含义的描述。

egret启动服务器_启动服务器

Modern motherboards include LED indication for detecting failed components. If the server starts successfully, a sound signal indicates that POST has been passed. The duration and number of sound signals make it possible to determine the failed component.

现代主板包括用于检测故障组件的LED指示灯。 如果服务器成功启动,则声音信号表示POST已通过。 声音信号的持续时间和数量使确定故障组件成为可能。

egret启动服务器_启动服务器

When maximum diagnostics precision is required, you can use an external device — POST card. Motherboards send POST test results via data buses, while the POST card processes this data and output it by means of available indicators.

如果需要最高的诊断精度,则可以使用外部设备-POST卡。 主板通过数据总线发送POST测试结果,而POST卡则处理这些数据并通过可用的指示器将其输出。

BIOS设置实用程序 (BIOS Setup Utility)

The BIOS has a special setup menu —

BIOS具有特殊的设置菜单-

BIOS设置实用程序 (BIOS Setup Utility)

. You can enter it by pressing the corresponding key during POST. BIOS entry keys are usually Del and F2. During the startup process, you can always see which key is used for opening BIOS settings.

。 您可以通过在POST期间按相应的键来输入它。 BIOS输入键通常是Del和F2。 在启动过程中,您始终可以看到哪个键用于打开BIOS设置。

egret启动服务器_启动服务器

BIOS设置实用程序 (BIOS Setup Utility)

provides a setup interface that can only be used with a keyboard. BIOS Setup Utility provides information about the installed hardware and makes it possible to modify motherboard and connected equipment operation parameters.

提供只能与键盘一起使用的设置界面。 BIOS Setup Utility提供有关已安装硬件的信息,并可以修改主板和连接的设备操作参数。

The names and options of parameters depend on many factors, such as:

参数的名称和选项取决于许多因素,例如:

  • BIOS version;

    BIOS版本;
  • motherboard model;

    主板型号
  • model of equipment installed in the motherboard.

    设备型号安装在主板上。

We are interested in

我们有兴趣

启动优先级 (Boot Priority)

. Boot priority defines the order in which BIOS queries devices to find a boot area in them. As soon as BIOS finds the boot area, control is transferred to the loader, and the next stage starts.

。 引导优先级定义BIOS查询设备以在其中查找引导区域的顺序。 BIOS找到引导区后,控制权立即转移到加载程序,然后下一个阶段开始。

egret启动服务器_启动服务器

操作系统加载器 (OS loader)

After completing POST, the BIOS performs a boot area search in a preset order. In

完成POST后,BIOS将按预设顺序执行引导区搜索。 在

遗产 (Legacy)

mode, the boot area on the disk is called

模式下,磁盘上的启动区域称为

主引导记录 (Master Boot Record)

(MBR).

(MBR)。

MBR (MBR)

is a special structure located in the first 512 bytes of the disk. These 512 bytes contain the following data:

是一种特殊的结构,位于磁盘的前512个字节中。 这512个字节包含以下数据:

  • 第一个加载程序阶段代码 (the first loader stage code)

    — 0 and 445 bytes;

    — 0和445字节;

  • 分区表 (partition table)

    — between 446 and 509 bytes;

    —在446和509字节之间;

  • 0xAA55幻数 (0xAA55 magic number)

    — between 510 and 511 bytes.

    —在510和511字节之间。

If there is no magic number (

如果没有幻数(

0xAA55 (0xAA55)

), MBR is considered not found on the disk, and the BIOS begins to query the next disk.

),则认为在磁盘上找不到MBR,BIOS开始查询下一个磁盘。

When the BIOS finds an MBR, it copies it from the disk to random access memory at the address

BIOS找到MBR时,会将其从磁盘复制到该地址处的随机存取存储器

0x7C00 (0x7C00)

and jumps to that address. After the jump,

并跳转到该地址。 跳后

阶段1 (Stage 1)

of the loader operation starts. Due to size limitations, the purpose of the first stage is to load

加载程序操作开始。 由于尺寸限制,第一阶段的目的是加载

第二阶段 (Stage 2)

code to memory and transfer control to it.

代码存储到内存,并将控制权转移给它。

第二阶段 (Stage 2)

code is stored between the MBR structure and the first disk partition. Historically, this area contains 31 kilobytes of memory and may reach 1 megabyte in present-day systems. However, for compatibility reasons, the second stage size is no more than 31 KB.

代码存储在MBR结构和第一个磁盘分区之间。 从历史上看,该区域包含31 KB的内存,在当今的系统中可能达到1 MB。 但是,出于兼容性原因,第二阶段的大小不超过31 KB。

The second stage prepares the environment for starting the third stage:

第二阶段准备开始第三阶段的环境:

  • loads the required file system drivers;

    加载所需的文件系统驱动程序;
  • finds the third stage code in the file system;

    在文件系统中查找第三阶段代码;
  • loads the code to RAM and transfers control to it.

    将代码加载到RAM并将控制权转移给RAM。

阶段 (Stage)

3 tasks are limited to setting up the environment and the loader:

3个任务仅限于设置环境和加载程序:

  • enable the

    启用

    保护模式 (Protected Mode)

    for the processor;

    用于处理器;

  • load installed GRUB2 extensions;

    加载已安装的GRUB2扩展;
  • find

    阶段4 (Stage 4)

    in the file system and transfer control to it.

    在文件系统中并将控制权转移给它。

保护模式 (Protected Mode)

is a compatibility mode for x86 processors. In this mode, the processor can execute 32-bit commands, while the address space is extended to 4 GiB. The Protected Mode has been significantly upgraded, and the following elements are available now:

是x86处理器的兼容模式。 在这种模式下,处理器可以执行32位命令,同时地址空间扩展到4 GiB。 保护模式已进行了重大升级,现在可以使用以下元素:

阶段4 (Stage 4)

operates in 32-bit mode. If necessary, it loads graphical interface extensions from the disk, parses the grub.cfg file, and displays the familiar OS selection menu.

在32位模式下运行。 如有必要,它将从磁盘加载图形界面扩展,解析grub.cfg文件,并显示熟悉的OS选择菜单。

egret启动服务器_启动服务器

操作系统内核 (OS kernel)

GRUB2 follows the Multiboot specification when loading the kernel's executable file. The loader checks the

加载内核的可执行文件时,GRUB2遵循Multiboot规范 。 装载机检查

0x1BADB002 (0x1BADB002)

magic number at the beginning of the kernel and verifies the checksum to make sure the kernel is compatible with the specification. If the check is passed, the kernel can be loaded to random access memory and assigned control.

内核开头的幻数,并验证校验和以确保内核与规范兼容。 如果检查通过,则可以将内核加载到随机存取存储器并分配控制权。

According to the same specification, the loader provides system info to the kernel, such as:

根据相同的规范,加载程序将系统信息提供给内核,例如:

  • current processor operation mode;

    当前处理器操作模式;
  • amount of RAM detected;

    检测到的RAM数量;
  • video output mode (text or pixels);

    视频输出模式(文本或像素);
  • screen resolution.

    屏幕分辨率。

Despite the fact that the loader used file system drivers and, possibly, graphical interface extensions, the loaded kernel will not get all the great stuff. First of all, after gaining control, the kernel «unlocks» the entire server potential and enables the

尽管加载程序使用了文件系统驱动程序以及可能的图形界面扩展,但加载的内核将无法获得所有功能。 首先,在获得控制权之后,内核将所有服务器潜力“解锁”并启用

长模式 (Long Mode)

for the processor.

用于处理器。

长模式 (Long Mode)

is the master mode of 64-bit processors. In this mode, the processor can execute 64-bit commands and use general-purpose 64-bit registers. The address space can store 16 EiB. Long Mode deprecates the segmented memory organization of the 32-bit architecture.

是64位处理器的主模式。 在这种模式下,处理器可以执行64位命令并使用通用64位寄存器。 地址空间可以存储16个EiB。 长模式不赞成使用32位体系结构的分段内存组织。

Despite the huge address space, only 48 of the available 64 bits are used for addressing. As a result, the maximum RAM is reduced to 256 TiB, which is 65536 times less than the address space size. In the foreseeable future, physical addressing is expected to be extended to 57 bits.

尽管地址空间很大,但可用的64位中只有48位用于寻址。 结果,最大RAM减少到256 TiB,比地址空间大小少65536倍。 在可预见的将来,物理寻址预计将扩展到57位。

After transition to the Long Mode, the kernel performs the minimum set of required operations:

转换为长模式后,内核执行最少的必需操作集:

  • it sets up page-based memory addressing;

    设置基于页面的内存寻址;
  • loads drivers and initializes the required equipment;

    加载驱动程序并初始化所需的设备;
  • configures memory and process schedulers;

    配置内存和进程调度程序;
  • finds and starts init.

    查找并启动init。

It should be noted that the server had been operating using a single core (BSP) before the process scheduler was configured. Configuring the scheduler «wakes up» other cores —

应该注意的是,在配置进程调度程序之前,服务器一直在使用单核(BSP)进行操作。 配置调度程序“唤醒”其他内核—

应用处理器 (Application Processors)

(AP). Cores are not directly interconnected and communicate with each other via local interrupt controllers —

(AP)。 内核没有直接互连,而是通过本地中断控制器相互通信—

本地高级可编程中断控制器 (Local Advanced Programmable Interrupt Controllers)

(LAPIC).

(LAPIC)。

The operating system kernel runs in the BSP. Using ACPI tables, the kernel has obtained information about available system processors during the initialization process. Using its own LAPIC, the BSP sends the "

操作系统内核在BSP中运行。 使用ACPI表,内核在初始化过程中获得了有关可用系统处理器的信息。 BSP使用自己的LAPIC发送“

初始化-启动-启动 (Init — StartUp — StartUp)

" sequence of interrupts to wake up all APs. After startup, application processors must also be started and transferred to Long Mode. This process is now faster since this work has already been performed by the main processor.

中断顺序以唤醒所有AP。启动后,还必须启动应用处理器并将其转移到Long Mode。由于主处理器已经完成了这项工作,因此该过程现在速度更快。

After initializing all APs, the process scheduler starts the

初始化所有AP之后,进程调度程序将启动

(Idle)

service process. As it appears from the process name, it does not do anything and uses the processor when no other processes are running.

服务流程。 正如从进程名称中显示的那样,它不执行任何操作,并且在没有其他进程在运行时使用处理器。

Once everything is set up and ready for operation, the operating system kernel starts the first process in the user space —

一切设置完成并准备就绪后,操作系统内核将启动用户空间中的第一个进程-

在里面 (Init)

. In turn, this process starts other processes in the user space. Once the init process has been started, the kernel enters standby mode and remains idle until tasks appear in the kernel space.

。 反过来,此过程将启动用户空间中的其他过程。 启动初始化过程后,内核进入待机模式并保持空闲状态,直到任务出现在内核空间中为止。

When all the processes are running, the server becomes available in the network and the Logon screen invitation can be seen in the console.

当所有进程都在运行时,服务器在网络中变得可用,并且可以在控制台中看到“登录”屏幕邀请。

结论 (Conclusion)

Starting the server and the operating system may seem simple and fast at a glance. In fact, it is a complicated process with a lot of peculiarities. Moving through this process is an evolution in miniature that extends performance from legacy 16-bit processors to modern 64-bit monster processors.

一目了然,启动服务器和操作系统似乎很简单快捷。 实际上,这是一个复杂的过程,具有许多独特之处。 在此过程中进行的是微型的演变,将性能从传统的16位处理器扩展到了现代的64位Monster处理器。

当出现128位处理器时,您是否认为它们将支持16位兼容模式? (When 128-bit processors appear, do you think they will support 16-bit compatibility mode?)

翻译自: https://habr.com/en/company/selectel/blog/500846/

egret启动服务器

相关文章:

  • 2021-04-17
  • 2022-02-27
  • 2021-11-29
  • 2022-02-07
  • 2022-02-06
  • 2021-09-18
  • 2021-06-06
猜你喜欢
  • 2021-07-13
  • 2021-08-10
  • 2022-02-02
  • 2021-05-24
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
相关资源
相似解决方案