CentOS 7.9 OS Kernel Update 3.10 to 4.19

date: 2024-01-18, 2024-01-26

原 OS Kernel 3.10

升级至 4.19

1.检查默认内核

  • 检查 vmlinuz 版本

    [root@localhost ~]# grubby --default-kernel
    /boot/vmlinuz-3.10.0-1160.105.1.el7.x86_64
    [root@localhost ~]#

  • 检查 Linux 内核版本

    [root@localhost ~]# uname -a
    Linux localhost.localdomain 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
    [root@localhost ~]#

2.配置 yum 源

  • 备份原 repo 源文件

    [root@localhost ~]# cd /etc/yum.repos.d/
    [root@localhost yum.repos.d]# mkdir bak;mv ./* bak
    mv: cannot move './bak' to a subdirectory of itself, 'bak/bak'
    [root@localhost yum.repos.d]# ll
    total 0
    drwxr-xr-x 2 root root 220 Jan 25 20:24 bak
    [root@localhost yum.repos.d]#

  • 下载阿里云 CentOS7 repo 源

    [root@localhost yum.repos.d]# curl -o CentOS-Ali.repo https://mirrors.aliyun.com/repo/Centos-7.repo
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    100 2523 100 2523 0 0 2789 0 --:--:-- --:--:-- --:--:-- 2787
    [root@localhost yum.repos.d]#
    [root@localhost yum.repos.d]# ll
    total 4
    drwxr-xr-x 2 root root 220 Jan 25 20:24 bak
    -rw-r--r-- 1 root root 2523 Jan 25 20:25 CentOS-Ali.repo
    [root@localhost yum.repos.d]#

  • 更新本地 repo 源

    [root@localhost yum.repos.d]# yum clean all
    [root@localhost yum.repos.d]# yum makecache fast
    Loaded plugins: fastestmirror
    Repository base is listed more than once in the configuration
    Repository updates is listed more than once in the configuration
    Repository extras is listed more than once in the configuration
    Repository centosplus is listed more than once in the configuration
    Loading mirror speeds from cached hostfile
    base | 3.6 kB 00:00:00
    centosplus | 2.9 kB 00:00:00
    extras | 2.9 kB 00:00:00
    updates | 2.9 kB 00:00:00
    Metadata Cache Created
    [root@localhost ~]#

  • 查看 repo 源

    [root@localhost ~]# yum repolist
    Loaded plugins: fastestmirror
    Repository base is listed more than once in the configuration
    Repository updates is listed more than once in the configuration
    Repository extras is listed more than once in the configuration
    Repository centosplus is listed more than once in the configuration
    Loading mirror speeds from cached hostfile
    repo id repo name status
    base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072
    centosplus/7/x86_64 CentOS-7 - Plus - mirrors.aliyun.com 277
    extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 518
    updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 5,558
    repolist: 16,425
    [root@localhost ~]#

3.下载内核离线包

复制代码
cd /opt
wget http://193.49.22.109/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-4.19.12-1.el7.elrepo.x86_64.rpm
wget http://193.49.22.109/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-devel-4.19.12-1.el7.elrepo.x86_64.rpm

4.安装内核

复制代码
[root@localhost ~]# cd /opt/
[root@localhost opt]# ll
total 59068
-rw-r--r-- 1 root root 47850944 Jan 18 11:22 kernel-ml-4.19.12-1.el7.elrepo.x86_64.rpm
-rw-r--r-- 1 root root 12632052 Jan 18 10:59 kernel-ml-devel-4.19.12-1.el7.elrepo.x86_64.rpm
[root@localhost opt]# yum install ./*.rpm -y
...
Installed:
  kernel-ml.x86_64 0:4.19.12-1.el7.elrepo                                                  kernel-ml-devel.x86_64 0:4.19.12-1.el7.elrepo

Dependency Installed:
  perl.x86_64 4:5.16.3-299.el7_9            perl-Carp.noarch 0:1.26-244.el7                perl-Encode.x86_64 0:2.51-7.el7                    perl-Exporter.noarch 0:5.68-3.el7
  perl-File-Path.noarch 0:2.09-2.el7        perl-File-Temp.noarch 0:0.23.01-3.el7          perl-Filter.x86_64 0:1.49-3.el7                    perl-Getopt-Long.noarch 0:2.40-3.el7
  perl-HTTP-Tiny.noarch 0:0.033-3.el7       perl-PathTools.x86_64 0:3.40-5.el7             perl-Pod-Escapes.noarch 1:1.04-299.el7_9           perl-Pod-Perldoc.noarch 0:3.20-4.el7
  perl-Pod-Simple.noarch 1:3.28-4.el7       perl-Pod-Usage.noarch 0:1.63-3.el7             perl-Scalar-List-Utils.x86_64 0:1.27-248.el7       perl-Socket.x86_64 0:2.010-5.el7
  perl-Storable.x86_64 0:2.45-3.el7         perl-Text-ParseWords.noarch 0:3.29-4.el7       perl-Time-HiRes.x86_64 4:1.9725-3.el7              perl-Time-Local.noarch 0:1.2300-2.el7
  perl-constant.noarch 0:1.27-2.el7         perl-libs.x86_64 4:5.16.3-299.el7_9            perl-macros.x86_64 4:5.16.3-299.el7_9              perl-parent.noarch 1:0.225-244.el7
  perl-podlators.noarch 0:2.5.1-3.el7       perl-threads.x86_64 0:1.87-4.el7               perl-threads-shared.x86_64 0:1.43-6.el7

Complete!
[root@localhost opt]#

5.更改内核启动顺序

复制代码
[root@localhost ~]# grub2-set-default 0
[root@localhost ~]# grub2-mkconfig -o /etc/grub2.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.19.12-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-4.19.12-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.105.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.105.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-cf7d56908f2b4b73bc25710041bda25d
Found initrd image: /boot/initramfs-0-rescue-cf7d56908f2b4b73bc25710041bda25d.img
done
[root@localhost ~]#
[root@localhost ~]# grubby --args="user_namespace.enable=1" --update-kernel="$(grubby --default-kernel)"
[root@localhost ~]#

6.检查内核版本

复制代码
[root@localhost ~]# grubby --default-kernel
/boot/vmlinuz-4.19.12-1.el7.elrepo.x86_64
[root@localhost ~]#

7.重启

复制代码
[root@localhost ~]# reboot

8.再次检查内核版本

复制代码
[root@localhost ~]# uname -a
Linux localhost.localdomain 4.19.12-1.el7.elrepo.x86_64 #1 SMP Fri Dec 21 11:06:36 EST 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]#

9.修改启动界面显示的内核顺序

  • 注释掉 3.10 内核

    [root@localhost ~]# vim /etc/grub2.cfg

    BEGIN /etc/grub.d/10_linux

    menuentry 'CentOS Linux (4.19.12-1.el7.elrepo.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted menuentry_id_option 'gnulinux-4.19.12-1.el7.elrepo.x86_64-advanced-5620e84e-0e87-41ad-9913-5292a8fd1d5e' { load_video set gfxpayload=keep insmod gzio insmod part_msdos insmod xfs set root='hd0,msdos1' if [ xfeature_platform_search_hint = xy ]; then
    search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 1556ccd1-3879-4b8e-8b23-80f8a473557f
    else
    search --no-floppy --fs-uuid --set=root 1556ccd1-3879-4b8e-8b23-80f8a473557f
    fi
    linux16 /vmlinuz-4.19.12-1.el7.elrepo.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rhgb quiet user_namespace.enable=1
    initrd16 /initramfs-4.19.12-1.el7.elrepo.x86_64.img
    }

    menuentry 'CentOS Linux (3.10.0-1160.105.1.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-1160.105.1.el7.x86_64-advanced-5620e84e-0e87-41ad-9913-5292a8fd1d5e' {

    load_video

    set gfxpayload=keep

    insmod gzio

    insmod part_msdos

    insmod xfs

    set root='hd0,msdos1'

    if [ x$feature_platform_search_hint = xy ]; then

    search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 1556ccd1-3879-4b8e-8b23-80f8a473557f

    else

    search --no-floppy --fs-uuid --set=root 1556ccd1-3879-4b8e-8b23-80f8a473557f

    fi

    linux16 /vmlinuz-3.10.0-1160.105.1.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rhgb quiet

    initrd16 /initramfs-3.10.0-1160.105.1.el7.x86_64.img

    }

    menuentry 'CentOS Linux (3.10.0-1160.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-1160.el7.x86_64-advanced-5620e84e-0e87-41ad-9913-5292a8fd1d5e' {

    load_video

    set gfxpayload=keep

    insmod gzio

    insmod part_msdos

    insmod xfs

    set root='hd0,msdos1'

    if [ x$feature_platform_search_hint = xy ]; then

    search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 1556ccd1-3879-4b8e-8b23-80f8a473557f

    else

    search --no-floppy --fs-uuid --set=root 1556ccd1-3879-4b8e-8b23-80f8a473557f

    fi

    linux16 /vmlinuz-3.10.0-1160.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rhgb quiet

    initrd16 /initramfs-3.10.0-1160.el7.x86_64.img

    }

    menuentry 'CentOS Linux (0-rescue-cf7d56908f2b4b73bc25710041bda25d) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted menuentry_id_option 'gnulinux-0-rescue-cf7d56908f2b4b73bc25710041bda25d-advanced-5620e84e-0e87-41ad-9913-5292a8fd1d5e' { load_video insmod gzio insmod part_msdos insmod xfs set root='hd0,msdos1' if [ xfeature_platform_search_hint = xy ]; then
    search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 1556ccd1-3879-4b8e-8b23-80f8a473557f
    else
    search --no-floppy --fs-uuid --set=root 1556ccd1-3879-4b8e-8b23-80f8a473557f
    fi
    linux16 /vmlinuz-0-rescue-cf7d56908f2b4b73bc25710041bda25d root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rhgb quiet
    initrd16 /initramfs-0-rescue-cf7d56908f2b4b73bc25710041bda25d.img
    }

    END /etc/grub.d/10_linux

  • 重启

    [root@localhost ~]# reboot


我们下期见,拜拜!

相关推荐
草莓熊Lotso3 小时前
【Redis 初阶】Set 类型深度解析:去重集合的运算能力与实战场景
linux·网络·数据库·windows·redis·tcp/ip·缓存
张文君3 小时前
ubuntu26.04坏道坏块分区隔离急速版260831-V0.12
linux·python
贝锐11 小时前
从国产化信创设备到商用安卓终端,向日葵如何帮助企业实现统一运维管理?
linux·运维·远程控制
Julien200413 小时前
调查和解决 SELinux 问题
linux·运维·服务器·网络·学习方法
小张同学a.15 小时前
Docker 容器实战 1—— docker 基础与镜像构建
linux·运维·docker·容器
Best-Wishes17 小时前
BurpSuite Pro教育版在linux系统中配置
linux·运维·服务器·网络安全·burpsuite
wuminyu17 小时前
深入剖析 Panama Off-heap 的性能损耗与开销
java·linux·c语言·jvm·c++
虎王物联17 小时前
RK3568嵌入式Linux跑Docker:内核配置排查到AIoT容器化的完整路径
linux·运维·docker·rk3568·aiot·嵌入式linux
GeW18 小时前
不只靠技术:RHCE考试的5个隐藏得分点
linux
老当益壮梁奶奶18 小时前
Linux软件编程学习笔记(八):进程间通信详解(1)
linux·c语言·笔记·学习·算法