linux Centos 修改系统默认启动内核

最近使用centos 7 进行了update的命令来做更新操作。导致docker中的容器无法进行访问,无奈之下进行重启操作。重启时服务器一直无法启动,最后无法重启,提交工单,对方工程师发现由于更新内核导致无法启动。

linux使用update命令会进行内核更新,我们需要修改默认启动内核解决这个问题。centos 7 采用的是grub2进引导程序。

一、查看具体内核数量:

cat /boot/grub2/grub.cfg |grep menuentry
[root@VM_0_9_centos ~]# 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 (3.10.0-957.10.1.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-862.el7.x86_64-advanced-21dbe030-aa71-4b3a-8610-3b942dd447fa' {
menuentry 'CentOS Linux (3.10.0-957.5.1.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-862.el7.x86_64-advanced-21dbe030-aa71-4b3a-8610-3b942dd447fa' {
menuentry 'CentOS Linux (3.10.0-862.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-862.el7.x86_64-advanced-21dbe030-aa71-4b3a-8610-3b942dd447fa' {
menuentry 'CentOS Linux (0-rescue-c28d40cbc8e3adcb4e32d9779a77b39e) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-c28d40cbc8e3adcb4e32d9779a77b39e-advanced-21dbe030-aa71-4b3a-8610-3b942dd447fa' {

二、设置默认启动内核

 grub2-set-default "CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)"

查看是否修改成功

[root@VM_0_9_centos ~]# grub2-editenv list
saved_entry=CentOS Linux (3.10.0-957.5.1.el7.x86_64) 7 (Core)

你可能感兴趣的:(linux Centos 修改系统默认启动内核)