如何在Ubuntu,Debian,Mint,Kali,CentOS中手动下载,编译和安装自定义Linux内核?...

本文详细介绍了如何在Ubuntu、Debian、Mint和Kali以及CentOS、Fedora上从kernel.org下载Linux内核源代码,使用GCC进行编译,并通过多线程加速编译过程。首先,通过wget命令下载内核源代码,接着安装必要的GCC和依赖项。然后,提取源代码,创建编译配置,并使用make命令进行编译。最后,文章还提到了如何使用-j选项以提高编译速度。
摘要由CSDN通过智能技术生成

Linux is a Operating System kernel and user space applications will create different distributions like CentOS, Ubuntu, Mint, Kali around this kernel. Kernel can be downloaded freely and used without any license fee. In this tutorial we will learn how to download Linux Kernel from kernel.org and compiling with GCC . An the last step installing or upgrading the kernel.

Linux是一个操作系统内核,用户空间应用程序将围绕该内核创建不同的发行版,如CentOS,Ubuntu,Mint和Kali。 内核可以免费下载和使用,无需任何许可费用。 在本教程中,我们将学习如何从kernel.org下载Linux Kernel以及如何使用GCC进行编译。 安装或升级内核的最后一步。

下载内核源代码 (Download Kernel Source Code)

Kernel source code is originally maintained in the kernel.org . But there are a lot of mirrors which serve to download the kernel source code. In this step we will download kernel source code by using wget command like below. Current stable version of the Linux Kernel is 4.17.6.

内核源代码最初在kernel.org中维护。 但是有很多镜像可以用来下载内核源代码。 在这一步中,我们将使用如下的wget命令下载内核源代码。 Linux内核的当前稳定版本是4.17.6

$ wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.17.6.tar.xz
Download Kernel Source Code
Download Kernel Source Code
下载内核源代码

安装GCC和其他要求(Install GCC and Other Requirements)

GCC is most popular compiler for C and C++ source codes in Linux environment. We will use GCC in order to compile and create binaries for Linux Kernel . We will install gcc with the following command for different distributions.

GCC是Linux环境中最流行的C和C ++源代码编译器。 我们将使用GCC来为Linux内核编译和创建二进制文件。 我们将使用以下命令为不同的发行版安装gcc

Ubunt,Debian,Mint,Kali: (Ubunt, Debian, Mint, Kali:)

$ sudo apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc flex libelf-dev bison

CentOS,Fedora: (CentOS, Fedora:)

$ sudo yum install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc flex libelf-dev bison
Install GCC and Other Requirements
Install GCC and Other Requirements
安装GCC和其他要求

提取内核源代码(Extract Kernel Source Code)

Kernel source code has a lot of text type data which may take a lot of disk space and bandwith. So Linux Kernel code is distributed in compressed formats like xz , tar.gz etc. We download Kernel Source code as xz so we need to extract source code  with the tar command like below.

内核源代码包含大量文本类型数据,这可能会占用大量磁盘空间和带宽。 因此Linux内核代码以xztar.gz等压缩格式分发。我们将内核源代码下载为xz因此我们需要使用tar命令提取源代码,如下所示。

$ tar xvf linux-4.17.6.tar.xz

创建编译配置 (Create Compile Configuration)

We will create a configuration which will used to compile required modules and kernel features.

我们将创建一个配置,该配置将用于编译所需的模块和内核功能。

$ make menuconfig
Create Compile Configration
Create Compile Configration
创建编译配置

用GCC编译Linux内核源代码并制作(Compile Linux Kernel Source Code with GCC and Make)

We will use make command wich will run compile process according to the configuration we have created with the make menuconfig command.

我们将使用make命令,它将根据我们使用make menuconfig命令创建的配置运行编译过程。

$ make
Compile Linux Kernel Source Code with GCC and Make
Compile Linux Kernel Source Code with GCC and Make
用GCC编译Linux内核源代码并制作

更快地编译Linux内核(Compile Linux Kernel Faster)

By default make command will make compile with a single thread . But as modern CPU’s have multiple cores which gives ability to use multiple threads we can run parallel compile with -j option of the make command. In this case we specify 4 threads

默认情况下,make命令将使用单个线程进行编译。 但是由于现代CPU具有多个内核,这些内核可以使用多个线程,因此我们可以使用make命令的-j选项运行并行编译。 在这种情况下,我们指定4个线程

$ make -j 4
Compile Linux Kernel Faster
Compile Linux Kernel Faster
更快地编译Linux内核
LEARN MORE  Grep and Filter IP Address In Linux
了解更多Grep和在Linux中过滤IP地址

翻译自: https://www.poftut.com/how-to-download-compile-and-install-custom-linux-kernel-manually-in-ubuntu-debian-mint-kali-centos/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值