Linux内检查确认用程序-用于为Debian和衍生产品编译和更新最新Linux内核的脚本

时间:2020-03-21 11:46:05  来源:igfitidea点击:

不久前,我们发布了有关工具UKUU的教程,该工具用于在基于DEB的系统(例如Ubuntu,Linux Mint)中安装和/或者更新最新的Linux内核。

今天,我们将看到一个名为“ Linux Kernel Utilities”的类似工具。
它是一组BASH Shell脚本,可用于编译和/或者更新Debian及其衍生版本的最新Linux内核。

Linux Kernel Utilities包含以下三个脚本。

  • compile_linux_kernel.sh-从源代码编译并安装最新的Linux内核,
  • update_ubuntu_kernel.sh-下载并安装或者更新预编译的Ubuntu内核,
  • remove_old_kernels.sh-删除所有不活动/未使用的Linux内核。

在这个简短的教程中,我将解释如何在Ubuntu 16.04 LTS中安装和使用Linux Kernel Utilities。

Linux内检查确认用程序-编译和更新最新Linux内核的脚本

安装Linux内检查确认用程序

我们可以通过两种方式安装Linux Kernel Utilities。

方法1:

推荐的方法是git clone使用以下命令来克隆存储库:

$git clone https://github.com/mtompkins/linux-kernel-utilities.git

上面的命令会将存储库的内容克隆到当前工作目录中名为“ linux-kernel-utilities”的文件夹中。

转到该目录:

$cd linux-kernel-utilities/

使用以下命令使脚本可执行:

$chmod 750 *.sh

脚本将在必要时提示更新。
要更新它们,只需运行:

$git pull

方法2:

安装此脚本的另一种方法是下载DEB软件包并手动安装。

转到“发行”页面并下载最新版本。

在撰写本教程时,最新版本为1.1.6.

$wget https://github.com/mtompkins/linux-kernel-utilities/releases/download/v1.1.6/linux-kernel-utilities_1.1.6_all.deb

然后,如下所示安装它。

$sudo dpkg -i linux-kernel-utilities*.deb

所有脚本都将安装在/opt位置下。
我们可以从此处执行脚本。

要删除它,请运行:

$sudo dpkg -r linux-kernel-utilities

编译Linux内核

正如我在简介部分中提到的那样,Linux Kernel Utilities由三个脚本组成。
compile_linux_kernel.sh脚本用于从http://www.kernel.org下载和编译最新的内核。

该脚本将显示该站点上可用的Linux内核列表,因此我们可以从列表中选择一个。

运行以下命令以列出可用的内核。
我们无需以sudo或者root用户身份运行这些脚本。
如有必要,系统将提示我们输入root密码或者sudo密码。

$./compile_linux_kernel.sh

单击确定继续。

如果存在,此脚本将首次安装缺少的依赖项。

接下来,从列表中选择一个内核进行下载。

只需按照屏幕上的说明编译并安装所选的Linux内核。

要编译并安装最新的可用Linux内核,请运行:

$./compile_linux_kernel.sh --latest

另外,我们可以从本地存档文件编译并安装内核。

$./compile_linux_kernel.sh --archive=linux-4.11.6.tar.xz

下载并安装预编译的Linux内核

update_ubuntu_kernel.sh脚本将允许我们从https://kernel.ubuntu.com下载和安装或者更新可用Linux内核的列表。

要从中安装预编译的内核,请运行:

$./update_ubuntu_kernel.sh

它将列出来自Kernel.ubuntu.com的所有可用的预编译Linux内核。
只需输入列表中的任何数字即可安装所选的内核。

[...]
[+] Retrieving available kernel choices . . .
 _ Precompiled kernels available from kernel.ubuntu.com:
 1) Linux v4.11 2) Linux v4.11.6 3) Linux v4.11.5 4) Linux v4.11.4 
 5) Linux v4.11.3 6) Linux v4.11.2 7) Linux v4.11.1 8) Linux v4.10 
 9) Linux v4.10.17 10) Linux v4.10.16 .
 .
 .
 .
 253) Linux v4.0.9-wily 254) Linux v4.0.8-wily 255) Linux v4.0.7-wily 256) Linux v4.0.6-wily 
 257) Linux v4.0.5-wily 258) Linux v4.0.4-wily 259) Linux v4.0.3-wily 260) Linux v4.0.2-wily 
 261) Linux v4.0.1-wily 262) Linux v4.0-vivid
Select your desired kernel:1

安装新内核后,重新启动并登录到新安装的内核。

要安装最新的可用Linux内核,请运行:

$./update_ubuntu_kernel.sh --latest

上面的命令直接从Kernel.ubuntu.com上选择可用的最新版本并进行安装。

删除非活动的Linux内核

remove_old_kernels.sh脚本将从Ubuntu系统中删除不活动的和未使用的内核。
使用此脚本时请小心。
它只会离开当前加载的Linux内核。
所有旧内核将被删除。
强烈建议在执行此脚本之前需要重新启动。

$./remove_old_kernels.sh

键入“ y”,然后按Enter键以删除旧内核。
系统将要求我们输入sudo用户密码以卸载旧内核。

A reboot is recommended before running this script to ensure the current kernel tagged
as the boot kernel is indeed registered and old kernels properly marked for removal.
If you have just installed or modified your existing kernel and do not reboot before
running this script it Jan render you system INOPERABLE and that would indeed suck.
You have been warned.
~the Mgmt
[?]Continue to automatically remove ALL old kernels? (y/N)y

现在,旧内核已从Ubuntu系统中删除。