查询当前内核的版本号和OS 镜像来源
[root@localhost ~]# uname -a
Linux localhost.localdomain 4.14.0-115.el7a.0.1.aarch64 #1 SMP Sun Nov 25 20:54:21 UTC 2018 aarch64 aarch64 aarch64 GNU/Linux
[root@localhost ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (AltArch)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (AltArch)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
当前操作系统发行厂商为:CentOS-7。内核版本号: 4.14.0-115.el7a.0.1
2. 从官方
http://vault.centos.org/7.6.1810/os/Source/SPackages/ 下载部分源码rpm 包kernel-alt-4.14.0-115.el7a.0.1.src.rpm
3. 编译内核之前,必须安装编译内核基本工具链。
笔者碰到问题:
error: Failed build dependencies:
xmlto is needed by kernel-alt-4.14.0-115.el7.0.1.aarch64
asciidoc is needed by kernel-alt-4.14.0-115.el7.0.1.aarch64
newt-devel is needed by kernel-alt-4.14.0-115.el7.0.1.aarch64
pciutils-devel is needed by kernel-alt-4.14.0-115.el7.0.1.aarch64
使用命令解决笔者的问题:
yum install –y xmlto asciidoc newt-devel pciutils-devel
通常要求的工具链:
sudo yum install rpm-build redhat-rpm-config asciidoc hmaccalc perl-ExtUtils-Embed pesign xmlto
sudo yum install audit-libs-devel binutils-devel elfutils-devel elfutils-libelf-devel
sudo yum install ncurses-devel newt-devel numactl-devel pciutils-devel python-devel zlib-devel
4. 编译之前确保mockbuild用户和mockbuild所属的组有效。
groupadd mockbuild
useradd mockbuild -g mockbuild
5. 安装rpm 包。此rpm 包实际为rpmbuild 构建工程
rpm -ivh kernel-alt-4.14.0-115.el7a.0.1.src.rpm
安装完成,rpm构建工程自动部署在
/root/rpmbuild/SPECS
/root/rpmbuild/SOURCES
6.rpmbuild 构建,会自动下载全量内核代码(包括补丁合入)
cd /root/rpmbuild/SPECS
rpmbuild -bp --target=$(uname -m) kernel-alt.spec
7. 构建完成后,可以获取到全量内核源码,路径为:
cd /root/rpmbuild/BUILD/kernel-alt-4.14.0-115.el7a/linux-4.14.0-115.el7.0.1.aarch64
8.内核编译
make -j 64
9. 此项可选:驱动安装
make modules_install
10. 此项可选:内核安装:
make install
11.此项可选: 重启,选择对应的内核