內核:4.18.0-147.8.1.el7.aarch64
實現過程:在鯤鵬arm服務器完成python
1.官網下載部分源碼rpm包kernel-alt-4.14.0-115.el7a.0.1.src.rpmlinux
2.編譯內核以前,必須安裝編譯內核基本工具鏈,如未安裝可能遇到以下問題:服務器
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`
安裝要求的工具鏈: yum install rpm-build redhat-rpm-config asciidoc hmaccalc perl-ExtUtils-Embed pesign xmlto yum install audit-libs-devel binutils-devel elfutils-devel elfutils-libelf-devel yum install ncurses-devel newt-devel numactl-devel pciutils-devel python-devel zlib-deve
3.編譯以前確保mockbuild用戶和mockbuild所屬的組有效ide
groupadd mockbuild radd mockbuild -g mockbuild
4.安裝rpm 包,此rpm 包實際爲rpmbuild 構建工程工具
rpm -ivh kernel-alt-4.14.0-115.el7a.0.1.src.rpm 安裝完成,rpm構建工程自動部署在 /root/rpmbuild/SPECS /root/rpmbuild/SOURCES
5.rpmbuild 構建,會自動下載全量內核代碼(包括補丁合入)測試
cd /root/rpmbuild/SPECS rpmbuild -bp --target=$(uname -m) kernel-alt.spe
6.構建完成後,能夠獲取到全量內核源碼ui
路徑爲: cd /root/rpmbuild/BUILD/kernel-alt-4.14.0-115.el7a/linux-4.14.0-115.el7.0.1.aarch64
7.進入編譯 make menuconfig也可直接更改.congfig3d
CONFIG_SLUB_DEBUG=y CONFIG_KASAN=y
make -j 64 make modules_install 驅動安裝(可選) Make install 內核安裝(可選) 選擇第一個,然後選擇M模塊編譯
9.編譯完成後查看/boot下會多出一個內核code
10.查詢本系統內有幾個內核xml
cat /etc/grub2-efi.cfg |grep menuentry 新編譯的內核會有顯示(若是未顯示就重啓,reboot)
11.設置更改後的內核爲首選項啓動並查詢是否更改
grub2-set-default "CentOS Linux (4.14.0) 7 (AltArch)"; grub2-editenv list
12.測試是否成功
Linux 內核的源碼中已經包含了針對 Kasan 的測試代碼,其位置在 lib/test_kasan.c。編譯內核或者單獨編譯 lib 模塊的時候,會生成 test_kasan.ko 模塊。當向內核插入該模塊的時候,就會執行測試代碼,編譯過就會生成.koInsmod test_kasan.ko
13.加載ko便可在dmesg中查詢或者直接輸出dmesg |grep kasan