• 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

  • 相关阅读:
    【C语言】从扫雷玩家到开发者
    十个面试排序算法
    博客园主题美化(仅兼容 Markdown)
    【定语从句练习题】That 、who、whom、省略
    Python3 安装 Matplotlib 报错 pip 无法卸载 pillow 解决方案
    java多线程之——停止线程多种方式
    智能工作流:Spring AI高效批量化提示访问方案
    Kafka消息队列大数据实战教程-第三篇(Kafka分区和副本的创建)
    GPT-4并非世界模型,LeCun双手赞同!ACL力证LLM无法模拟真实世界
    含文档+PPT+源码等]精品基于SSM的图书管理系统[包运行成功]计算机Java毕业设计SSM项目源代码
  • 原文地址:https://blog.csdn.net/weixin_72426331/article/details/127346032