Skip to content

Instantly share code, notes, and snippets.

@girishrau
Last active October 13, 2017 13:43
Show Gist options
  • Save girishrau/fc7a1b75f675fe31c97defdf52ccdab7 to your computer and use it in GitHub Desktop.
Save girishrau/fc7a1b75f675fe31c97defdf52ccdab7 to your computer and use it in GitHub Desktop.
[Grub2] Change the default boot kernel #grub #linux
1. Generate the up to date grub configuration
$ grub2-mkconfig -o /boot/grub2/grub.cfg
2. Get the boot sequence of the kernels in the grub configuration
$ grep '^menuentry' /boot/grub2/grub.cfg
This will show the sequence in which the kernels are displayed
menuentry 'Oracle Linux Server (4.1.12-61.1.6.el7uek.x86_64 with Unbreakable Enterprise Kernel) 7.2' --class ol --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-4.1.12-61.1.6.el7uek.x86_64-advanced-7e585ba2-aa3d-4b3f-b447-b0fe12a1f076' {
menuentry 'Oracle Linux Server (3.10.0-327.el7.x86_64 with Linux) 7.2' --class ol --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-327.el7.x86_64-advanced-7e585ba2-aa3d-4b3f-b447-b0fe12a1f076' {
menuentry 'Oracle Linux Server (0-rescue-ef6d98a7dc3c439a98df9c2ceb1b7065 with Linux) 7.2' --class ol --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-ef6d98a7dc3c439a98df9c2ceb1b7065-advanced-7e585ba2-aa3d-4b3f-b447-b0fe12a1f076' {
3. The sequence is listed with index 0 being first. So for example from the above list, if you wanted Kernel 3.10 to be the default
then the index will be 1.
4. Set the default boot kernel using the index
$ grub2-set-default 1
Alternately, you could also use the full name of the kernel in the above command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment