{"id":242603,"date":"2022-05-19T08:38:35","date_gmt":"2022-05-19T00:38:35","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=242603"},"modified":"2022-05-14T14:40:27","modified_gmt":"2022-05-14T06:40:27","slug":"centos8-compile-kernel","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/centos8-compile-kernel.html","title":{"rendered":"Centos8\u7f16\u8bd1\u5b89\u88c5\u5185\u6838"},"content":{"rendered":"
\u9996\u5148\u4e0b\u8f7dkernel\uff0c5.x\u7248\u672c\u7684\u5185\u6838\uff0c\u4e0b\u8f7d\u5730\u5740\uff1a
\nhttps:\/\/mirrors.edge.kernel.org\/pub\/linux\/kernel\/v5.x\/<\/p>\n
\u7cfb\u7edf\u5b89\u88c5\u76f8\u5173\u5305\uff1a<\/p>\n
\r\n# yum install -y bc gcc make python3 ncurses-devel flex bison openssl-devel elfutils-libelf-devel\r\n<\/pre>\n\u5c06\u5185\u6838\u89e3\u538b<\/p>\n
[root@localhost ~]# tar xvf linux-5.10.60.tar.xz\r\n[root@localhost linux-5.10.60]# cd linux-5.10.60\r\n<\/pre>\n\u4f7f\u7528\u73b0\u6709\u7684config\u6587\u4ef6<\/p>\n
[root@localhost linux-5.10.60]# cp -p \/boot\/config-4.18.0-305.3.1.el8.x86_64 .config\r\n<\/pre>\n\u4f7f\u7528\u8001\u7684\u914d\u7f6e\u53c2\u6570<\/p>\n
[root@localhost linux-5.10.60]# sh -c 'yes \"\"| make oldconfig'\r\n<\/pre>\nMake\u7f16\u8bd1\uff0c\u4f7f\u7528nproc\u547d\u4ee4\u8868\u793a\u4f7f\u7528\u6240\u6709cpu\u7ebf\u7a0b\uff1a<\/p>\n
[root@localhost linux-5.10.60]# make -j $(nproc)\r\n<\/pre>\nMake \u62a5\u9519\uff1a<\/p>\n
make[1]: *** No rule to make target 'certs\/rhel.pem', needed by 'certs\/x509_certificate_list'. Stop.\r\n<\/pre>\n
\n\u548c\u8fd9\u4e2a\u62a5\u9519Failed to generate BTF for vmlinux
\n
\n\u7f16\u8f91.config\u914d\u7f6e\u6587\u4ef6\uff0c\u5c06\u4e0b\u9762\u4e24\u884c\u6ce8\u91ca\u6389<\/p>\n#CONFIG_SYSTEM_TRUSTED_KEYS=\"certs\/rhel.pem\"\r\n#CONFIG_DEBUG_INFO_BTF=y<\/pre>\n
\n
\n\u7136\u540e\u518d\u6b21\u6267\u884cmake -j $(nproc)<\/p>\n[root@localhost linux-5.10.60]# make -j $(nproc)<\/pre>\n
\n\u6a21\u5757\u5b89\u88c5\uff0c\u628a\u7f16\u8bd1\u597d\u7684\u6a21\u5757\u62f7\u8d1d\u5230\u7cfb\u7edf\u76ee\u5f55\u4e0b<\/p>\n[root@localhost linux-5.10.60]# make modules_install<\/pre>\n
\n\u5b89\u88c5\u4e8c\u8fdb\u5236\u5185\u6838\u955c\u50cf, \u751f\u6210\u5e76\u5b89\u88c5boot\u521d\u59cb\u5316\u6587\u4ef6\u7cfb\u7edf\u6620\u50cf\u6587\u4ef6<\/p>\n[root@localhost linux-5.10.60]# make install<\/pre>\n
\n\u73b0\u5728\u53ef\u4ee5\u67e5\u770b\/lib\/modules\u76ee\u5f55\u4e0b\u9762\u591a\u51fa\u6765\u4e00\u4e2a5.10.60\u5185\u6838\u7684\u76ee\u5f55\u4e86<\/p>\n[root@localhost linux-5.10.60]# ll \/lib\/modules\r\ntotal 8\r\ndrwxr-xr-x. 6 root root 4096 Apr 11 14:38 4.18.0-305.3.1.el8.x86_64\r\ndrwxr-xr-x. 3 root root 4096 Apr 11 15:48 5.10.60<\/pre>\n
\n\u66f4\u65b0\u4e00\u4e0bgrub\u542f\u52a8\u9879<\/p>\n[root@localhost linux-5.10.60]# grub2-mkconfig -o \/boot\/grub2\/grub.cfg<\/pre>\n\u67e5\u770b\u9ed8\u8ba4\u542f\u52a8\u9879\u662f\u5426\u662f5.10.60<\/p>\n
[root@localhost linux-5.10.60]# grubby --default-kernel\r\n[root@localhost linux-5.10.60]# grubby --default-index<\/pre>\n
\n\u67e5\u770b\u6240\u6709\u542f\u52a8\u9879\uff1a<\/p>\n[root@localhost linux-5.10.60]# grubby --info=ALL<\/pre>\n
\n\u53ef\u4f7f\u7528grubby \u2013set-default \u6765\u8bbe\u7f6e\u9ed8\u8ba4\u542f\u52a8\u9879\u3002
\n\u8bbe\u7f6e\u5b8c\u6210\u4e4b\u540e\uff0c\u53ef\u4ee5\u91cd\u542f\u7cfb\u7edf\uff0c\u67e5\u770b\u662f\u5426\u53ef\u4ee5\u8fdb\u5165\u7cfb\u7edf\u4e86\u3002
\n
\n<\/p>\n","protected":false},"excerpt":{"rendered":"\u9996\u5148\u4e0b\u8f7dkernel\uff0c5.x\u7248\u672c\u7684\u5185\u6838\uff0c\u4e0b\u8f7d\u5730\u5740\uff1a https:\/\/mirrors.edge.kernel.o […]<\/p>\n","protected":false},"author":309,"featured_media":242604,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-242603","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/242603","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/309"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=242603"}],"version-history":[{"count":1,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/242603\/revisions"}],"predecessor-version":[{"id":242617,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/242603\/revisions\/242617"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/242604"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=242603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=242603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=242603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}