Installed new Kernel and still booting with old one

CentOS boot into new kernel automatically 194 times1 answer1 follower
0
Mel Khamlichi 103 Rep. Avishek Kumar edited question

am  using Centos 7 ( updated with  latest packages  including new  kernel) .

and in  my boot  display  i see 3 kernels  .

How to setup  the  machine  to  boot from the  second kernel   or  the  original one

♥ Spread the love ♥
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
0
Avishek Kumar 449 Rep. Avishek Kumar edited answer

If you are tired of selecting the preferred kernel during boot at grub menu every time, you may set preferred kernel as default in grub.

Method 1
  1. List all the installed kernel
  2. $ rpm -qa kernel

    Sample Output

    kernel-3.10.0-327.36.3.el7.x86_64
    kernel-3.10.0-327.el7.x86_64
    
  3. List the current kernel in use
  4. $ uname -srm
    $ uname -r
    

    Sample Output

    Linux 3.10.0-327.36.3.el7.x86_64 x86_64
  5. Find the Label for the installed kernels
  6. # awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg

    Sample Output

    0 : CentOS Linux (3.10.0-327.36.3.el7.x86_64) 7 (Core)
    1 : CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)
    2 : CentOS Linux (0-rescue-4c5cea6578e644dc81b464977bc40bc2) 7 (Core)
    
  7. To set default a new kernel (use label name from the output of point number 3)
  8. # grub2-set-default "CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)"
  9. Ask grub to boot from the specified kernel at the next boot. This will not reboot your box now.
  10. # grub2-reboot "CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)"
  11. Changes to the settings are made effective as
  12. # grub2-mkconfig -o /boot/grub2/grub.cfg

    Sample Output

    Generating grub configuration file ...
    Found linux image: /boot/vmlinuz-3.10.0-327.36.3.el7.x86_64
    Found initrd image: /boot/initramfs-3.10.0-327.36.3.el7.x86_64.img
    Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64
    Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img
    Found linux image: /boot/vmlinuz-0-rescue-4c5cea6578e644dc81b464977bc40bc2
    Found initrd image: /boot/initramfs-0-rescue-4c5cea6578e644dc81b464977bc40bc2.img
    done
    

    On UEFI system, the command is

    grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
  13. Reboot you box and all done.
  14. # reboot
Method 2
  1. Find the Label for the installed kernels
  2. # awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg

    Sample Output

    0 : CentOS Linux (3.10.0-327.36.3.el7.x86_64) 7 (Core)
    1 : CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)
    2 : CentOS Linux (0-rescue-4c5cea6578e644dc81b464977bc40bc2) 7 (Core)
    

    Important! to notice that the first entry in above output is indexed as 0.

  3. To boot from kernel indexed as 1, you need to run
  4. # grub2-set-default 0
  5. List the value saved in /boot/grub2/grubenv, if set correctly
  6. # grub2-editenv list

    Sample Output

    saved_entry=0
  7. Reboot you box and all done.
  8. # reboot
♥ Spread the love ♥
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
×

Login