前言
使用现有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对海光的支持
commit fec98069fb72fb656304a3e52265e0c2fc9adf87
Merge: 04ce7fae3d4e 995d5f64b62f
Author: Linus Torvalds <torvalds@>
Date: Tue Oct 23 16:16:40 2018 +0100
Merge branch 'x86-cpu-for-linus' of git:///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:///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