我们知道,centos 6.x是通过/etc/grub.conf就行内核启动顺序修改的,而且比较直观查看。但centos 7的系统和6就不一样了,是通过grub2为引导程序。下边简单说下centos 7的内核启动顺序如何修改。
1,首先查看当前系统有几个内核。比如:
1 2 3 4 5 6 7 8 9 10 11 12 |
[root@local ~]# cat /boot/grub2/grub.cfg |grep menuentry if [ x"${feature_menuentry_id}" = xy ]; then menuentry_id_option="--id" menuentry_id_option="" export menuentry_id_option menuentry 'CentOS Linux (4.18.7-1.el7.elrepo.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.el7.x86_64-advanced-45670b90-30b7-4e8e-90b0-986d83e21345' { menuentry 'CentOS Linux (4.18.6-1.el7.elrepo.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.el7.x86_64-advanced-45670b90-30b7-4e8e-90b0-986d83e21345' { menuentry 'CentOS Linux (4.18.5-1.el7.elrepo.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.el7.x86_64-advanced-45670b90-30b7-4e8e-90b0-986d83e21345' { menuentry 'CentOS Linux (3.10.0-862.11.6.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.el7.x86_64-advanced-45670b90-30b7-4e8e-90b0-986d83e21345' { menuentry 'CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.el7.x86_64-advanced-45670b90-30b7-4e8e-90b0-986d83e21345' { menuentry 'CentOS Linux (0-rescue-eb40493c64db490f836ebe78373ca0f2) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-eb40493c64db490f836ebe78373ca0f2-advanced-45670b90-30b7-4e8e-90b0-986d83e21345' { |
2,设置默认的启动内核。比如我们选择上边中的“CentOS Linux (4.18.7-1.el7.elrepo.x86_64) 7 (Core)”这个内核为默认启动。
1 |
[root@local ~]# grub2-set-default "CentOS Linux (4.18.7-1.el7.elrepo.x86_64) 7 (Core)" 配置默认内核 |
验证是否修改成功:
1 2 |
[root@local ~]# grub2-editenv list saved_entry=CentOS Linux (4.18.7-1.el7.elrepo.x86_64) 7 (Core) |
3,重启机器观察。
重启成功以后查看下机器的内核是不是该内核:
1 2 |
[root@local ~]# uname -r 4.18.5-1.el7.elrepo.x86_64 |