51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

Centos7内核升级修改默认启动内核

在yum的elrepo源中有ml和lt两种内核,其中ml(mainline)为最新版本的内核,lt(longterm)为长期支持的内核

本文基于elrepo源进行内核升级

1、导入公钥
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

|---|------------------------------------------------------------| | 1 | rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org |

2、安装ELRepo
yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm

|---|---------------------------------------------------------------------------| | 1 | yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm |

3、启用ELRepo源仓库
yum --disablerepo="*" --enablerepo="elrepo-kernel" list available

|---|--------------------------------------------------------------------| | 1 | yum --disablerepo="*" --enablerepo="elrepo-kernel" list available |

如果要安装最新的ml内核,则
yum --enablerepo=elrepo-kernel install kernel-ml

|---|--------------------------------------------------| | 1 | yum --enablerepo=elrepo-kernel install kernel-ml |

如果要安装最新的lt内核(我这里以lt内核为例),则
yum --enablerepo=elrepo-kernel install kernel-lt

|---|--------------------------------------------------| | 1 | yum --enablerepo=elrepo-kernel install kernel-lt |

注意:默认ELRepo只提供最新的版本,所以你这里想安装指定的版本是不行的。

如果想安装指定版本的内核,需要单独去下载rpm包进行安装。历史kernel下载地址:http://193.49.22.109/elrepo/kernel/el7/x86_64/RPMS/

4、修改默认系统启动内核

先查看所有可用内核
cat /boot/grub2/grub.cfg |grep ^menuentry

|---|---------------------------------------------| | 1 | cat /boot/grub2/grub.cfg |grep ^menuentry |


menuentry 'CentOS Linux (5.4.149-1.el7.elrepo.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-e4ae2b69-426f-4931-a1db-f2e0318d4166' { menuentry 'CentOS Linux (3.10.0-1160.6.1.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-e4ae2b69-426f-4931-a1db-f2e0318d4166' { 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-e4ae2b69-426f-4931-a1db-f2e0318d4166' { menuentry 'CentOS Linux (0-rescue-b00f797b60dc48d8a3fd9c7b96cd31a1) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-b00f797b60dc48d8a3fd9c7b96cd31a1-advanced-e4ae2b69-426f-4931-a1db-f2e0318d4166' {

|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 | menuentry 'CentOS Linux (5.4.149-1.el7.elrepo.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-e4ae2b69-426f-4931-a1db-f2e0318d4166' { menuentry 'CentOS Linux (3.10.0-1160.6.1.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-e4ae2b69-426f-4931-a1db-f2e0318d4166' { 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-e4ae2b69-426f-4931-a1db-f2e0318d4166' { menuentry 'CentOS Linux (0-rescue-b00f797b60dc48d8a3fd9c7b96cd31a1) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-b00f797b60dc48d8a3fd9c7b96cd31a1-advanced-e4ae2b69-426f-4931-a1db-f2e0318d4166' { |

修改默认启动内核
grub2-set-default 'CentOS Linux (5.4.149-1.el7.elrepo.x86_64) 7 (Core)'

|---|-------------------------------------------------------------------------| | 1 | grub2-set-default 'CentOS Linux (5.4.149-1.el7.elrepo.x86_64) 7 (Core)' |

5、查看内核修改结果
grub2-editenv list

|---|--------------------| | 1 | grub2-editenv list |

saved_entry=CentOS Linux (5.4.149-1.el7.elrepo.x86_64) 7 (Core)

6、重启系统使内核生效
reboot

|---|--------| | 1 | reboot |

赞(0)
未经允许不得转载:工具盒子 » Centos7内核升级修改默认启动内核