CentOS 7 升级内核及修改默认启动内核
CentOS 7 的内核升级及修改默认启动的内核,操作备档
http://elrepo.org/tiki/HomePage
导入公钥:
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
To install ELRepo for RHEL-9:
To install ELRepo for RHEL-8:
To install ELRepo for RHEL-7, SL-7 or CentOS-7:
查看内核:
yum --disablerepo=* --enablerepo=elrepo-kernel list kernel*
安装内核:
yum --disablerepo=\* --enablerepo=elrepo-kernel install kernel-ml.x86_64
查看GRUB缺省启动顺序
# cat /etc/default/grub | grep GRUB_DEFAULT
GRUB_DEFAULT=saved
如果是saved,就是按照指定保存的内核启动,如果为数字(0/1/2等),就是/boot/grub2/grub.cfg中对应位置的内核,建议设置为saved。
查看当前使用的内核:
# grub2-editenv list
saved_entry=CentOS Linux (3.10.0-957.21.3.el7.x86_64) 7 (Core) with debugging
查看可以使用的内核:
# cat /boot/grub2/grub.cfg | grep 'menuentry '
menuentry 'CentOS Linux (5.18.1-1.el7.elrepo.x86_64) 7 (Core) with debugging' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-a1003f9f-2f89-4a7d-baea-d7e2d6b5088a' {
menuentry 'CentOS Linux (5.18.1-1.el7.elrepo.x86_64) 7 (Core)' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-a1003f9f-2f89-4a7d-baea-d7e2d6b5088a' {
menuentry 'CentOS Linux (3.10.0-957.21.3.el7.x86_64) 7 (Core) with debugging' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-a1003f9f-2f89-4a7d-baea-d7e2d6b5088a' {
menuentry 'CentOS Linux (3.10.0-957.21.3.el7.x86_64) 7 (Core)' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-a1003f9f-2f89-4a7d-baea-d7e2d6b5088a' {
设置默认启动的内核:
# grub2-set-default 'CentOS Linux (5.18.1-1.el7.elrepo.x86_64) 7 (Core) with debugging'
查看设置后的结果:
# grub2-editenv list
saved_entry=CentOS Linux (5.18.1-1.el7.elrepo.x86_64) 7 (Core)
重启生效。