注意:保持/磁盤空間>10G
- 1.安裝依賴:
yum install -y flex bison bc gcc gcc-c++ make ncurses-devel openssl-devel elfutils-libelf-devel
- 2.下載所需版本內(nèi)核
- 3.解壓內(nèi)核到/usr/src/kernels/
tar -xf linux-5.3.8.tar.xz -C /usr/src/kernels/
- 4.設(shè)置編譯參數(shù)(進(jìn)入解壓內(nèi)核目錄)
make menuconfig #進(jìn)入可視化配置
allyesconfig #全部功能開啟
allnoconfig #最基本參數(shù),可能無(wú)法啟動(dòng)
建議:或者使用當(dāng)前內(nèi)核參數(shù)(先找到當(dāng)前內(nèi)核版本),然后新增功能
cp /boot/config-3.10.0-957.el7.x86_64 /usr/src/kernels/linux-5.3.8/.config
- 5.編譯(很久,如果多核建議-j核數(shù))
make all
- 6.安裝
make modules_install #模塊安裝
make install
- 7.設(shè)置默認(rèn)的內(nèi)核啟動(dòng)
查看當(dāng)前所有g(shù)rub內(nèi)核
[root@localhost ~]# grep ^menu /boot/grub2/grub.cfg
menuentry 'CentOS Linux (5.3.8) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-957.el7.x86_64-advanced-05f0c1f9-bccb-4360-a10e-e1a2edbd96f8' {
menuentry 'CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-957.el7.x86_64-advanced-05f0c1f9-bccb-4360-a10e-e1a2edbd96f8' {
menuentry 'CentOS Linux (0-rescue-61f58926d3fc4d179772b874c54a4ac5) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-61f58926d3fc4d179772b874c54a4ac5-advanced-05f0c1f9-bccb-4360-a10e-e1a2edbd96f8' {
設(shè)置默認(rèn)內(nèi)核
#數(shù)字 0 1 2..... 依次是上面過(guò)濾出來(lái)的順序
grub2-set-default 0
查看當(dāng)前啟動(dòng)內(nèi)核
[root@localhost ~]# grub2-editenv list saved_entry=0
- 8.重啟驗(yàn)證內(nèi)核
[root@localhost ~]# uname -r 5.3.8
我的技術(shù)站
https://www.iyunw.cn/

u=2340320312,2290703801&fm=26&gp=0.jpg