Linux 内核模块 | 加载 / 添加 / 删除 / 优先级

注:本文为 “Linux 内核模块加载 / 添加 / 删除 / 优先级” 相关文章合辑

机翻,未校。

未整理去重。


How Linux Kernel Boots?

Linux 内核如何启动?

Last Updated: 26 Apr, 2023

Many processes are running in the background when we press the system’s power button. It is very important to learn the booting process to understand the working of any operating system. Knowing how the kernel boots is a must to solve the booting error. It is a very interesting topic to learn, let us start with the basics. A simplified read of the boot method is given below:
当我们按下系统的电源按钮时,许多进程都在后台运行。了解任何作系统的工作情况,了解引导过程是非常重要的。了解内核如何引导是解决引导错误的必要条件。这是一个非常有趣的学习话题,让我们从基础开始。下面给出了 boot 方法的简化阅读:

Stages of Linux Boot Process:

Linux 启动过程的阶段:

  1. The machine’s BIOS (Basic Input/Output System) or boot microcode hundreds and runs a boot loader.
    机器的 BIOS(基本输入/输出系统)或引导微码数百并运行引导加载程序。
  2. Boot loader finds the kernel image on the disk and loads it into memory, to start the system.
    引导加载程序在磁盘上找到内核映像并将其加载到内存中,以启动系统。
  3. The kernel initializes the devices and their drivers.
    内核初始化设备及其驱动程序。
  4. The kernel mounts the basis filesystem.
    内核挂载基础文件系统。
  5. The kernel starts a program referred to as init with a method ID zero
    内核启动一个称为 init 的程序,其方法 ID 为零
  6. init sets the remainder of the system processes in motion.
    init 设置系统进程的其余部分。
  7. For some purpose, init starts a method permitting you to log in, typically at the top or close to the top of the boot sequence.
    出于某种目的,init 会启动一个允许您登录的方法,通常在引导序列的顶部或靠近顶部。

How Linux Kernel Boots?

Booting Proces

启动过程

Startup Message:

启动消息:

Traditional UNIX operating system manufactures several diagnostic messages upon boot that tell you regarding the boot method. The messages come back initially from the kernel and so from processes and low-level formatting procedures that init starts. However, these messages aren’t pretty or consistent, and in some cases, they aren’t even terribly informative. Additionally, hardware enhancements have caused the kernel to start a lot quicker than before the messages flash by therefore quickly, it may be tough to check what’s happening. As a result, most current Linux distributions do their best to cover boot medical specialty with splash screens and different varieties of filler to distract you whereas the system starts.
传统的 UNIX作系统在引导时会产生几条诊断消息,告诉您有关引导方法的信息。消息最初来自内核,因此来自 init 启动的进程和低级格式化过程。然而,这些信息并不漂亮或一致,在某些情况下,它们甚至没有提供太多信息。此外,硬件增强导致内核的启动速度比消息闪过之前快得多,因此可能很难检查发生了什么。因此,大多数当前的 Linux 发行版都尽最大努力通过启动画面和不同种类的填充物来覆盖启动医疗专业,以在系统启动时分散您的注意力。

Kernel Initialization and Boot Options:

内核初始化和启动选项:

  1. CPU examination CPU 检查
  2. Memory examination 记忆检查
  3. Device bus discovery 设备总线发现
  4. Device discovery 设备发现
  5. Auxiliary kernel system setup 辅助内核系统设置
  6. Root filesystem mount 根文件系统挂载
  7. User-space begin. 用户空间开始

The first 2 steps aren’t too exceptional, however, once the kernel gets to devices, the question of dependencies arises. As an example, the disk device drivers might rely on bus support and SCSI system support. In general, you won’t need to worry regarding the dependencies, except that some necessary parts are also loadable kernel modules instead of a part of the most kernel.
前 2 个步骤并不是太特殊,但是,一旦内核到达设备,依赖关系问题就出现了。例如,磁盘设备驱动程序可能依赖于总线支持和 SCSI 系统支持。一般来说,你不需要担心依赖关系,除了一些必要的部分也是可加载的内核模块,而不是大多数内核的一部分。

Kernel Parameters:

内核参数:

When the Linux kernel starts, it receives a group of text-based kernel parameters containing some further system details. The parameters specify many alternative kinds of behavior, like the number of diagnostic outputs the kernel ought to manufacture and device driver–specific choices. The Ro parameter instructs the kernel to mount the basis filesystem in read-only mode upon user area begins. This normal read-only mode ensures that fsck can safely check the basis filesystem before attempting to do something serious. When the check, the bootup method remounts the basis filesystem in read-write mode.
当 Linux 内核启动时,它会收到一组基于文本的内核参数,其中包含一些进一步的系统详细信息。这些参数指定了许多替代行为类型,例如内核应该制造的诊断输出的数量和特定于设备驱动程序的选择。Ro 参数指示内核在用户区开始时以只读模式挂载基础文件系统。这种正常的只读模式确保 fsck 可以在尝试执行严重作之前安全地检查基础文件系统。检查时,bootup 方法以读写模式重新挂载基础文件系统。

Boot Loader Tasks:

引导加载程序任务:

  • Select from multiple kernels.
    从多个内核中进行选择。
  • Switch between sets of kernel parameters.
    在内核参数集之间切换。
  • Provide support for booting different operating systems.
    为引导不同的作系统提供支持。

Bootloaders have become significantly advanced since the origin of the Linux kernel, with options like command-line history and menu systems, however, a basic want has perpetually been flexibility in kernel image and parameter choice. One stunning development is that some wants to have really diminished. As an example, as a result of being able to perform associate emergency or recovery boot from a USB device, you seldom need to worry about manually getting into kernel parameters or going into single-user mode. Current bootloaders supply a lot of power than ever, which may be notably handy if you’re building custom kernels or simply wish to tweak parameters.
自 Linux 内核诞生以来,引导加载程序已经变得非常先进,具有命令行历史记录和菜单系统等选项,但是,一个基本需求一直是内核映像和参数选择的灵活性。一个令人震惊的发展是,有些人希望真正减少。例如,由于能够从 USB 设备执行关联的紧急或恢复启动,您很少需要担心手动进入内核参数或进入单用户模式。当前的 bootloader 提供了比以往更多的功能,如果您正在构建自定义内核或只是希望调整参数,这可能非常方便。

Boot Loader Overview:

引导加载程序概述

  • GRUB – A near-universal normal on Linux systems, with BIOS/MBR and UEFI versions.
    GRUB – Linux 系统上几乎通用的正常现象,具有 BIOS/MBR 和 UEFI 版本。
  • LILO – One of the primary Linux bootloaders. ELILO could be a UEFI version.
    LILO – 主要的 Linux 引导加载程序之一。ELILO 可以是 UEFI 版本。
  • SYSLINUX – It may be organized to run from many alternative styles of filesystems.
    SYSLINUX – 它可以被组织为从许多替代样式的文件系统运行。
  • LOADLIN – Boots a kernel from DOS.
    LOADLIN – 从 DOS 引导内核。
  • System-boot a straightforward UEFI boot manager.
    系统引导 一个简单的 UEFI 引导管理器。
  • coreboot – A superior replacement for the computer BIOS which will embody a kernel.
    coreboot – 计算机 BIOS 的卓越替代品,它将体现内核。
  • Linux Kernel EFISTUB A kernel plug-in for loading the kernel directly from associate EFI/UEFI System Partition.
    Linux 内核 EFISTUB 用于直接从关联的 EFI/UEFI 系统分区加载内核的内核插件。
  • EFI Linux – A UEFI boot loader meant to function as a model and reference for different UEFI boot loaders.
    EFI Linux – 一种 UEFI 引导加载程序,旨在用作不同 UEFI 引导加载程序的模型和参考。

Introduction and Work of Few Bootloaders mentioned above:

上面提到的几个 Bootloader 的介绍和工作:

1) GRUB:

GRUB stands for Grand Unified Boot Loader. One of GRUB’s most vital capabilities is filesystem navigation that enables straightforward kernel image and configuration choice.
GRUB 代表 Grand Unified Boot Loader。GRUB 最重要的功能之一是文件系统导航,它支持直接的内核映像和配置选择。

  • Upon finding the boot code, the BIOS hundreds and executes it. This is often wherever GRUB begins.
    找到引导代码后,BIOS 百人并执行它。这通常是 GRUB 的起点。
  • The GRUB core hundreds.
    GRUB 核心数百个。
  • The core initializes. At now, GRUB will currently access disks and filesystems.
    核心初始化。目前,GRUB 目前将访问磁盘和文件系统。
  • GRUB identifies its boot partition and hundreds of configurations there.
    GRUB 标识其引导分区和其中的数百个配置。
  • GRUB offers the user an opportunity to vary the configuration.
    GRUB 为用户提供了更改配置的机会。
  • GRUB executes the configuration after a timeout or user action.
    GRUB 在超时或用户作后执行配置。
  • In the course of execution of the configuration, GRUB might load further code within the boot partition. a number of these modules are also preloaded.
    在执行配置的过程中,GRUB 可能会在 boot 分区中加载更多代码。其中许多模块也已预加载。
  • To load and execute the kernel GRUB executes boot commands.
    为了加载和执行内核,GRUB 会执行引导命令。

2) LILO (LInux LOader):

It was the first bootloader developed for Linux, still some users use it today. If we compare it to the GRUB bootloader it is quite simple and primarily used with BIOS system. To install it on Linux system one can install it using package manager like apt or yum. After installation it can be easily configured by editing its configuration file located at /etc/lolo.conf.
它是第一个为 Linux 开发的引导加载程序,今天仍然有一些用户使用它。如果我们将它与 GRUB 引导加载程序进行比较,它非常简单,主要用于 BIOS 系统。要在 Linux 系统上安装它,可以使用 apt 或 yum 等包管理器进行安装。安装后,可以通过编辑位于 ‘/etc/lolo.conf’ 的配置文件来轻松配置它。

3) SYSLINUX:

It is lightest among other bootloaders; it can perform booting from removable media such as CDs or USB drives. Its key feature is that it supports different filesystems, a command-line interface and the ability to boot from multiple devices. For example, to install SYSLINUX on a USB drive we can configure SYSLINUX setting by editing its configuration file located in /syslinux/syslinux.cfg.
它是其他引导加载程序中最轻的;它可以从 CD 或 USB 驱动器等可移动媒体执行引导。它的主要特点是它支持不同的文件系统、命令行界面以及从多个设备启动的能力。 例如,要在 USB 驱动器上安装 SYSLINUX,我们可以通过编辑位于 ‘/syslinux/syslinux.cfg’ 的配置文件来配置 SYSLINUX 设置。

Conclusion:

结论:

It is very important to know how Linux kernel boots and to know that one must know how to solve boot problems. The Linux boot process has several stages that include BIOS, boot loader, kernel initialization, device and driver initialization. While kernel is responsible for specifying various behaviors and device drivers-specific option whereas bootloader is responsible for providing flexible kernel image and parameter selection. We discussed the most common boot loader and overall, we can conclude that it is important for system administrators, developers and single users using Linux operating systems.
了解 Linux 内核如何引导以及必须知道如何解决引导问题非常重要。Linux 启动过程有几个阶段,包括 BIOS、启动加载程序、内核初始化、设备和驱动程序初始化。内核负责指定各种行为和设备驱动程序特定的选项,而 bootloader 负责提供灵活的内核映像和参数选择。我们讨论了最常见的引导加载程序,总的来说,我们可以得出结论,它对于使用 Linux作系统的系统管理员、开发人员和单个用户很重要。


Linux: How to load a kernel module automatically at boot time

Linux:如何在启动时自动加载内核模块

Author: Vivek Gite

Last updated: February 10, 2022

How do I load a Linux kernel module automatically at boot time to recognize my hardware during the system boot sequence?

如何在引导时自动加载 Linux 内核模块,以便在系统引导顺序中识别我的硬件?

The Linux kernel follows modular kernel design. Loadable Kernel Modules (LKM) are object files that contain code to extend the running kernel or so-called base kernel. LKM’s are typically used to add support for new hardware, filesystems, NICs and more. Most of the time, they are device drivers for hardware, but LKM’s are common for file systems, firewalls, and other purposes. This page explains how to load a Linux kernel module (driver) at boot time using configuration options.

Linux 内核遵循模块化内核设计。可加载内核模块(LKM)是对象文件,其中包含扩展正在运行的内核或所谓的基本内核的代码。LKM 通常用于添加对新硬件、文件系统、nic 等的支持。大多数情况下,它们是硬件的设备驱动程序,但 LKM 通常用于文件系统、防火墙和其他用途。本页解释了如何在启动时使用配置选项加载 Linux 内核模块(驱动程序)。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值