• CentOS源码更新Linux最新内核


    • 查看当前的内核版本

    [root@linux home]# uname -a

    Linux linux 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

    • 下载最新的内核

    [root@linux home]# ll | grep linux

    -rw-r--r--. 1 root root 103047692 May 24 17:35 linux-4.16.11.tar.xz

    • 编译准备

    [root@linux boot]# ll -ahl /boot | grep config-$(uname -r)

    -rw-r--r--. 1 root root 138K Aug 23 2017 config-3.10.0-693.el7.x86_64

    [root@linux boot]# cp config-3.10.0-693.el7.x86_64 .config

    这个文件是配置文件

    需要拷贝出一个配置文件

    [root@linux linux-4.16.11]# make menuconfig

    选择要编译的模块,生成当前目录的配置文件

    • 开始编译

    [root@linux linux-4.16.11]# make -j 28

    编译完成

      OBJCOPY arch/x86/boot/setup.bin

      BUILD arch/x86/boot/bzImage

    Setup is 16860 bytes (padded to 16896 bytes).

    System is 6937 kB

    CRC 5dda9dcd

    Kernel: arch/x86/boot/bzImage is ready (#1)

    • 安装

    [root@linux linux-4.16.11]# make modules_install

    ...

      INSTALL sound/usb/snd-usbmidi-lib.ko

      INSTALL sound/usb/usx2y/snd-usb-us122l.ko

      INSTALL sound/usb/usx2y/snd-usb-usx2y.ko

      INSTALL virt/lib/irqbypass.ko

      DEPMOD 4.16.11

    [root@linux linux-4.16.11]# make install

    sh ./arch/x86/boot/install.sh 4.16.11 arch/x86/boot/bzImage \

     System.map "/boot"

    • 启动内核作为引导

    [root@linux linux-4.16.11]# grub2-mkconfig -o /boot/grub2/grub.cfg

    Generating grub configuration file ...

    Found linux image: /boot/vmlinuz-4.16.11

    Found initrd image: /boot/initramfs-4.16.11.img

    Found linux image: /boot/vmlinuz-3.10.0-862.3.2.el7.x86_64

    Found initrd image: /boot/initramfs-3.10.0-862.3.2.el7.x86_64.img

    Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64

    Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img

    Found linux image: /boot/vmlinuz-0-rescue-842357192c9244d09270f31a145fa5e1

    Found initrd image: /boot/initramfs-0-rescue-842357192c9244d09270f31a145fa5e1.img

    done

    [root@linux linux-4.16.11]# 

    • 失败分析

    这里没能启动成功

    是因为系统是Legacy时候才找这个启动配置

    UEFI模式的话是要去

    /boot/efi/EFI/centos

    下面找grub.cfg文件的

    这时候在efi shell下是无法拷贝的

    只能挂载镜像文件然后进入救援模式,然后找到挂载点的文件系统,进去之后把

    /boot/grub2/grub.cfg 拷贝到   /boot/efi/EFI/centos/grub.cfg

    另外启动的话,默认的还是以前的kernel,是保存在一个配置文件中

    可以通过修改下面这个文件修改saved为0

    vim /etc/default/grub/grub.cfg

    修改

    GRUB_DEFAULT=0

    表示GRUB初始化页面的第一个内核作为默认内核

    这样就可以正常启动了

    [root@localhost centos]# uname -a

    Linux localhost.localdomain 4.16.11 #1 SMP Thu May 24 19:35:11 CST 2018 x86_64 x86_64 x86_64 GNU/Linux

    [root@localhost centos]# 

    参考文献:

    https://linux.cn/article-9665-1.html

    https://linux.cn/article-8310-1.html

  • 相关阅读:
    springboot+java医院门诊挂号系统设计与实现ssm008
    【旅行商问题】基于遗传算法求解TSP问题(Matlab代码实现)
    python读取文件数据 青少年编程电子学会python编程等级考试三级真题解析2020年12月
    面试遇到算法题:实现LRU缓存
    【Java】Stream流水线实现
    新思路,4.9+氧化应激相关基因构建风险模型
    深度学习Day-14:RNN实现心脏病预测
    Java工厂设计模式
    逆向思维 脑经急转弯
    直播预告丨中高频多因子库存储的最佳实践
  • 原文地址:https://blog.csdn.net/weixin_72426331/article/details/127346032