前言

使用现有centos的镜像,在海光机器上出现了无法运行的情况,grub引导后就只剩下光标一直在闪,无任何字符输出。这种情况大概率是因为Linux的内核无法运行在海光的CPU上所导致的。

已得知Linux内核在4.20版本后支持海光CPU,而在之前的版本中,则需要为内核打专门的patch,并编译内核。考虑到目前centos的软件源中并没有提供4.20版本以上的内核,而在其余开发环境中已有现成的5.15.11版本内核,故决定手动替换。

具体步骤

想要替换内核至5.15.11版本,至少需要从其他环境中复制如下文件:

  • /boot/vmlinuz-5.15.11-1.el7.x86_64
  • /boot/initramfs-5.15.11-1.el7.x86_64.img
  • /lib/modules/5.15.11-1.el7.x86_64/目录

随后更新grub配置,确认grub中包含新内核的引导:

grub2-mkconfig -o /boot/grub2/grub.cfg

如果initrd存在定制,那么还需要为新内核生成一个initrd:

dracut -v -f -N --kver 5.15.11-1.el7.x86_64

最后重启验证新内核是否能够正常运行。

附录

Linux对海光的支持

https://cdn.kernel.org/pub/linux/kernel/v4.x/ChangeLog-4.20

commit fec98069fb72fb656304a3e52265e0c2fc9adf87
Merge: 04ce7fae3d4e 995d5f64b62f
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date: Tue Oct 23 16:16:40 2018 +0100 Merge branch 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip Pull x86 cpu updates from Ingo Molnar:
"The main changes in this cycle were: - Add support for the "Dhyana" x86 CPUs by Hygon: these are licensed
based on the AMD Zen architecture, and are built and sold in China,
for domestic datacenter use. The code is pretty close to AMD
support, mostly with a few quirks and enumeration differences. (Pu
Wen) - Enable CPUID support on Cyrix 6x86/6x86L processors" * 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
tools/cpupower: Add Hygon Dhyana support
cpufreq: Add Hygon Dhyana support
ACPI: Add Hygon Dhyana support
x86/xen: Add Hygon Dhyana support to Xen
x86/kvm: Add Hygon Dhyana support to KVM
x86/mce: Add Hygon Dhyana support to the MCA infrastructure
x86/bugs: Add Hygon Dhyana to the respective mitigation machinery
x86/apic: Add Hygon Dhyana support
x86/pci, x86/amd_nb: Add Hygon Dhyana support to PCI and northbridge
x86/amd_nb: Check vendor in AMD-only functions
x86/alternative: Init ideal_nops for Hygon Dhyana
x86/events: Add Hygon Dhyana support to PMU infrastructure
x86/smpboot: Do not use BSP INIT delay and MWAIT to idle on Dhyana
x86/cpu/mtrr: Support TOP_MEM2 and get MTRR number
x86/cpu: Get cache info and setup cache cpumap for Hygon Dhyana
x86/cpu: Create Hygon Dhyana architecture support file
x86/CPU: Change query logic so CPUID is enabled before testing
x86/CPU: Use correct macros for Cyrix calls

内核rpm包中包含的文件

以内核版本4.18.0为例,首先使用rpm命令查询内核rpm包中包含有哪些文件,如下所示,rpm包中包含的文件有:

  • 内核文件:/boot/vmlinuz-4.18.0-348.7.1.el8_5.x86_64
  • initrd压缩包:/boot/initramfs-4.18.0-348.7.1.el8_5.x86_64.img
  • 内核编译文件(一般用不到):Module.symvers文件boot/symvers-4.18.0-348.7.1.el8_5.x86_64.gz、配置文件/boot/config-4.18.0-348.7.1.el8_5.x86_64、内核符号表/boot/System.map-4.18.0-348.7.1.el8_5.x86_64、内核完整性校验文件/boot/.vmlinuz-4.18.0-348.7.1.el8_5.x86_64.hmac等
  • 动态库加载配置文件:/etc/ld.so.conf.d/kernel-4.18.0-348.7.1.el8_5.x86_64.conf
  • 内核模块:/lib/modules/4.18.0-348.7.1.el8_5.x86_64/目录下的各种文件
  • 文档、签名、许可证等杂项:/usr/share/目录下的文件
# rpm -ql kernel-core-4.18.0-348.7.1.el8_5.x86_64
/boot/.vmlinuz-4.18.0-348.7.1.el8_5.x86_64.hmac
/boot/System.map-4.18.0-348.7.1.el8_5.x86_64
/boot/config-4.18.0-348.7.1.el8_5.x86_64
/boot/initramfs-4.18.0-348.7.1.el8_5.x86_64.img
/boot/symvers-4.18.0-348.7.1.el8_5.x86_64.gz
/boot/vmlinuz-4.18.0-348.7.1.el8_5.x86_64
/etc/ld.so.conf.d/kernel-4.18.0-348.7.1.el8_5.x86_64.conf
/lib/modules
/lib/modules/4.18.0-348.7.1.el8_5.x86_64
/lib/modules/4.18.0-348.7.1.el8_5.x86_64/.vmlinuz.hmac
/lib/modules/4.18.0-348.7.1.el8_5.x86_64/System.map
/lib/modules/4.18.0-348.7.1.el8_5.x86_64/bls.conf
/lib/modules/4.18.0-348.7.1.el8_5.x86_64/build
/lib/modules/4.18.0-348.7.1.el8_5.x86_64/config
/lib/modules/4.18.0-348.7.1.el8_5.x86_64/kernel
/lib/modules/4.18.0-348.7.1.el8_5.x86_64/kernel/arch
/lib/modules/4.18.0-348.7.1.el8_5.x86_64/kernel/arch/x86
/lib/modules/4.18.0-348.7.1.el8_5.x86_64/kernel/arch/x86/crypto
/lib/modules/4.18.0-348.7.1.el8_5.x86_64/kernel/arch/x86/crypto/blowfish-x86_64.ko.xz
/lib/modules/4.18.0-348.7.1.el8_5.x86_64/kernel/arch/x86/crypto/camellia-aesni-avx-x86_64.ko.xz
...
/usr/share/doc/kernel-keys/4.18.0-348.7.1.el8_5.x86_64
/usr/share/doc/kernel-keys/4.18.0-348.7.1.el8_5.x86_64/kernel-signing-ca-20140212.cer
/usr/share/doc/kernel-keys/4.18.0-348.7.1.el8_5.x86_64/kernel-signing-ca-20200609.cer
/usr/share/doc/kernel-keys/4.18.0-348.7.1.el8_5.x86_64/kernel-signing-ca.cer
/usr/share/licenses/kernel-core
/usr/share/licenses/kernel-core/COPYING-4.18.0

Linux内核替换的一种简单方法的更多相关文章

  1. linux内核空间与用户空间信息交互方法

    linux内核空间与用户空间信息交互方法     本文作者: 康华:计算机硕士,主要从事Linux操作系统内核.Linux技术标准.计算机安全.软件测试等领域的研究与开发工作,现就职于信息产业部软件与 ...

  2. 【转】 Linux内核中读写文件数据的方法--不错

    原文网址:http://blog.csdn.net/tommy_wxie/article/details/8193954 Linux内核中读写文件数据的方法  有时候需要在Linuxkernel--大 ...

  3. 使用strace工具故障排查的5种简单方法

    使用strace工具故障排查的5种简单方法 本文源自5 simple ways to troubleshoot using strace strace 是一个非常简单的工具,用来跟踪可执行程序的系统调 ...

  4. WPF编程 ,TextBlock 显示百分数值的一种简单方法。

    原文:WPF编程 ,TextBlock 显示百分数值的一种简单方法. 版权声明:我不生产代码,我只是代码的搬运工. https://blog.csdn.net/qq_43307934/article/ ...

  5. Linux内核配置编译及基本调试方法

    一.Linux内核配置编译 1. 交叉编译设置:make ARCH=arm CROSS_COMPILE=arm-linux- 注:也可以直接修改顶层Makefile ARCH ?= arm CROSS ...

  6. Linux 内核睡眠的几种方式

    译至:http://geeki.wordpress.com/2010/10/30/ways-of-sleeping-in-linux-kernel/ 在Linux中睡眠有2-3种不同的方法. 睡眠的第 ...

  7. Linux内核分析:完成一个简单的时间片轮转多道程序内核代码

    PS.贺邦   原创作品转载请注明出处  <Linux内核分析>MOOC课程    http://mooc.study.163.com/course/USTC-1000029000 1.m ...

  8. Honeywords项目——检查密码是否被破解的一种简单方法

    Honeywords项目使用一种简单的方法来改进hash后的密码的安全性——为每个账户维护一个额外的honeywords(假密码).如果有黑客拿到了密码的文件,然后试图用brute froce的方式破 ...

  9. Linux内核crash/Oops异常定位分析方法

    在内核开发的过程中,经常会碰到内核崩溃,比如空指针异常,内存访问越界.通常我们只能靠崩溃之后打印出的异常调用栈信息来定位crash的位置和原因.总结下分析的方法和步骤. 通常oops发生之后,会在串口 ...

随机推荐

  1. java.lang.UnsatisfiedLinkError报错

    是因为使用maven时,运行web项目时,在maven的依赖包没有打包到tomcat中(out目录中),所以要手动加上

  2. luogu P1488 肥猫的游戏

    肥猫的游戏 P1488 肥猫的游戏 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 题目描述 野猫与胖子,合起来简称肥猫,是一个班的同学,他们也都是数学高手,所以经常在一起讨论数学问 ...

  3. 【Android 逆向】ARM while 逆向

    #include <stdio.h> int dowhile(int n){ int i = 1; int s = 0; do{ s += i; }while(i++ < n); r ...

  4. Docker 完整版教程

    Docker 安装 一.安装前必读 在安装 Docker 之前,先说一下配置,我这里是Centos7 Linux 内核:官方建议 3.10 以上,3.8以上貌似也可. 注意:本文的命令使用的是 roo ...

  5. 洛谷P7112 行列式求值

    行列式求值 这是一个让你掉头发的模板题 行列式的定义 行列式 (\(\texttt{Determinant}\)) 是一个函数定义,取值是一个标量. 对一个 \(n\times n\) 的矩阵 \(A ...

  6. Kubernetes DevOps: Jenkins

    提到基于 Kubernete 的CI/CD,可以使用的工具有很多,比如 Jenkins.Gitlab CI 以及新兴的 drone 之类的,我们这里会使用大家最为熟悉的 Jenkins 来做 CI/C ...

  7. Elasticsearch:Elasticsearch HQ 介绍

  8. Logstash: 如何创建可维护和可重用的Logstash管道

  9. Beats:如何安装Packetbeat

  10. k8s控制器和Pod Template的关系

    Pod 本身并不能自愈(self-healing).如果一个 Pod 所在的 Node (节点)出现故障,或者调度程序自身出现故障,Pod 将被删除:同理,当因为节点资源不够或节点维护而驱逐 Pod ...