Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] grub2 default kernel
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
ttre
n00b
n00b


Joined: 04 Aug 2016
Posts: 29

PostPosted: Sun Mar 19, 2017 9:44 am    Post subject: [SOLVED] grub2 default kernel Reply with quote

How to set up new kernel as default in grub2 ? I have total 2 kernels, one new and one older.

?


Last edited by ttre on Sun Mar 19, 2017 3:51 pm; edited 1 time in total
Back to top
View user's profile Send private message
apiaio
Apprentice
Apprentice


Joined: 04 Dec 2008
Posts: 211

PostPosted: Sun Mar 19, 2017 10:52 am    Post subject: Reply with quote

You can edit grub config file /etc/default/grub and in the line
Quote:
GRUB_DEFAULT= ...
set the default menu entry by menu position.
Back to top
View user's profile Send private message
ttre
n00b
n00b


Joined: 04 Aug 2016
Posts: 29

PostPosted: Sun Mar 19, 2017 11:25 am    Post subject: Reply with quote

apiaio wrote:
You can edit grub config file /etc/default/grub and in the line
Quote:
GRUB_DEFAULT= ...
set the default menu entry by menu position.


so I have

Code:
GRUB_DISTRIBUTOR="Gentoo"

# Default menu entry
GRUB_DEFAULT=1


I did :
Code:
grub-mkconfig -o /boot/grub/grub.cfg


after it it was done.

but still old kernel is loading.
Why ?
Back to top
View user's profile Send private message
guitou
Guru
Guru


Joined: 02 Oct 2003
Posts: 402
Location: France

PostPosted: Sun Mar 19, 2017 12:06 pm    Post subject: Reply with quote

Hello.
I might be telling bullshit, but I believe Grub default is to consider latest kernel as the default one to boot, then I guess best approach is to change ctime and/or mtime of kernel files in /boot (see touch command)

++
Gi)
Back to top
View user's profile Send private message
apiaio
Apprentice
Apprentice


Joined: 04 Dec 2008
Posts: 211

PostPosted: Sun Mar 19, 2017 12:28 pm    Post subject: Reply with quote

If the new kernel is the first one, you should use
Code:
   
GRUB_DISTRIBUTOR="Gentoo"

# Default menu entry
GRUB_DEFAULT=0
Back to top
View user's profile Send private message
ttre
n00b
n00b


Joined: 04 Aug 2016
Posts: 29

PostPosted: Sun Mar 19, 2017 12:55 pm    Post subject: Reply with quote

apiaio wrote:
If the new kernel is the first one, you should use
Code:
   
GRUB_DISTRIBUTOR="Gentoo"

# Default menu entry
GRUB_DEFAULT=0



The first one, but by data/time created kernel file or what?
Back to top
View user's profile Send private message
apiaio
Apprentice
Apprentice


Joined: 04 Dec 2008
Posts: 211

PostPosted: Sun Mar 19, 2017 1:39 pm    Post subject: Reply with quote

ttre wrote:

The first one, but by data/time created kernel file or what?

I do not understand this question.
The first line in menu entry is 0 no 1. Did you try
Code:
GRUB_DEFAULT=0
?
Back to top
View user's profile Send private message
ttre
n00b
n00b


Joined: 04 Aug 2016
Posts: 29

PostPosted: Sun Mar 19, 2017 2:37 pm    Post subject: Reply with quote

apiaio wrote:
ttre wrote:

The first one, but by data/time created kernel file or what?

I do not understand this question.
The first line in menu entry is 0 no 1. Did you try
Code:
GRUB_DEFAULT=0
?


Yes, tried 0 and 1.

and it changed nothing.

Here is my grub.cfg file.
Code:

# cat /boot/grub/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="0"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_gpt
insmod ext2
set root='hd0,gpt4'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4  f32681fc-c967-4245-a4cf-57a6157a4e28
else
  search --no-floppy --fs-uuid --set=root f32681fc-c967-4245-a4cf-57a6157a4e28
fi
    font="/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
fi
terminal_output gfxterm
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-f32681fc-c967-4245-a4cf-57a6157a4e28' {
   load_video
   if [ "x$grub_platform" = xefi ]; then
      set gfxpayload=keep
   fi
   insmod gzio
   insmod part_gpt
   insmod ext2
   set root='hd0,gpt2'
   if [ x$feature_platform_search_hint = xy ]; then
     search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  233dd17e-81c0-41af-bfaf-c5d198a77ca1
   else
     search --no-floppy --fs-uuid --set=root 233dd17e-81c0-41af-bfaf-c5d198a77ca1
   fi
   echo   'Loading Linux x86_64-4.4.6-gentoo ...'
   linux   /kernel-genkernel-x86_64-4.4.6-gentoo root=UUID=f32681fc-c967-4245-a4cf-57a6157a4e28 ro 
   echo   'Loading initial ramdisk ...'
   initrd   /initramfs-genkernel-x86_64-4.4.6-gentoo
}
submenu 'Advanced options for Gentoo GNU/Linux' $menuentry_id_option 'gnulinux-advanced-f32681fc-c967-4245-a4cf-57a6157a4e28' {
   menuentry 'Gentoo GNU/Linux, with Linux x86_64-4.4.6-gentoo' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-x86_64-4.4.6-gentoo-advanced-f32681fc-c967-4245-a4cf-57a6157a4e28' {
      load_video
      if [ "x$grub_platform" = xefi ]; then
         set gfxpayload=keep
      fi
      insmod gzio
      insmod part_gpt
      insmod ext2
      set root='hd0,gpt2'
      if [ x$feature_platform_search_hint = xy ]; then
        search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  233dd17e-81c0-41af-bfaf-c5d198a77ca1
      else
        search --no-floppy --fs-uuid --set=root 233dd17e-81c0-41af-bfaf-c5d198a77ca1
      fi
      echo   'Loading Linux x86_64-4.4.6-gentoo ...'
      linux   /kernel-genkernel-x86_64-4.4.6-gentoo root=UUID=f32681fc-c967-4245-a4cf-57a6157a4e28 ro 
      echo   'Loading initial ramdisk ...'
      initrd   /initramfs-genkernel-x86_64-4.4.6-gentoo
   }
   menuentry 'Gentoo GNU/Linux, with Linux x86_64-4.4.6-gentoo (recovery mode)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-x86_64-4.4.6-gentoo-recovery-f32681fc-c967-4245-a4cf-57a6157a4e28' {
      load_video
      if [ "x$grub_platform" = xefi ]; then
         set gfxpayload=keep
      fi
      insmod gzio
      insmod part_gpt
      insmod ext2
      set root='hd0,gpt2'
      if [ x$feature_platform_search_hint = xy ]; then
        search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  233dd17e-81c0-41af-bfaf-c5d198a77ca1
      else
        search --no-floppy --fs-uuid --set=root 233dd17e-81c0-41af-bfaf-c5d198a77ca1
      fi
      echo   'Loading Linux x86_64-4.4.6-gentoo ...'
      linux   /kernel-genkernel-x86_64-4.4.6-gentoo root=UUID=f32681fc-c967-4245-a4cf-57a6157a4e28 ro single
      echo   'Loading initial ramdisk ...'
      initrd   /initramfs-genkernel-x86_64-4.4.6-gentoo
   }
   menuentry 'Gentoo GNU/Linux, with Linux 4.9.6-gentoo-r1' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.9.6-gentoo-r1-advanced-f32681fc-c967-4245-a4cf-57a6157a4e28' {
      load_video
      if [ "x$grub_platform" = xefi ]; then
         set gfxpayload=keep
      fi
      insmod gzio
      insmod part_gpt
      insmod ext2
      set root='hd0,gpt2'
      if [ x$feature_platform_search_hint = xy ]; then
        search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  233dd17e-81c0-41af-bfaf-c5d198a77ca1
      else
        search --no-floppy --fs-uuid --set=root 233dd17e-81c0-41af-bfaf-c5d198a77ca1
      fi
      echo   'Loading Linux 4.9.6-gentoo-r1 ...'
      linux   /vmlinuz-4.9.6-gentoo-r1 root=UUID=f32681fc-c967-4245-a4cf-57a6157a4e28 ro 
      echo   'Loading initial ramdisk ...'
      initrd   /initramfs-genkernel-x86_64-4.9.6-gentoo-r1
   }
   menuentry 'Gentoo GNU/Linux, with Linux 4.9.6-gentoo-r1 (recovery mode)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.9.6-gentoo-r1-recovery-f32681fc-c967-4245-a4cf-57a6157a4e28' {
      load_video
      if [ "x$grub_platform" = xefi ]; then
         set gfxpayload=keep
      fi
      insmod gzio
      insmod part_gpt
      insmod ext2
      set root='hd0,gpt2'
      if [ x$feature_platform_search_hint = xy ]; then
        search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  233dd17e-81c0-41af-bfaf-c5d198a77ca1
      else
        search --no-floppy --fs-uuid --set=root 233dd17e-81c0-41af-bfaf-c5d198a77ca1
      fi
      echo   'Loading Linux 4.9.6-gentoo-r1 ...'
      linux   /vmlinuz-4.9.6-gentoo-r1 root=UUID=f32681fc-c967-4245-a4cf-57a6157a4e28 ro single
      echo   'Loading initial ramdisk ...'
      initrd   /initramfs-genkernel-x86_64-4.9.6-gentoo-r1
   }
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
Back to top
View user's profile Send private message
apiaio
Apprentice
Apprentice


Joined: 04 Dec 2008
Posts: 211

PostPosted: Sun Mar 19, 2017 3:16 pm    Post subject: Reply with quote

I can see, that on the first position is:
kernel-4.4.6
second
kernel-4.4.6 /recovery mode/
third
kernel-4.9.6
and finaly
kernel-4.9.6 /recovery mode/.
Such that the new kernel is on the third position.
Please try
Code:
GRUB_DEFAULT= 2
Back to top
View user's profile Send private message
ttre
n00b
n00b


Joined: 04 Aug 2016
Posts: 29

PostPosted: Sun Mar 19, 2017 3:32 pm    Post subject: Reply with quote

apiaio wrote:
I can see, that on the first position is:
kernel-4.4.6
second
kernel-4.4.6 /recovery mode/
third
kernel-4.9.6
and finaly
kernel-4.9.6 /recovery mode/.
Such that the new kernel is on the third position.
Please try
Code:
GRUB_DEFAULT= 2


2 is not working,
I thought the same way, but maybe it is matter that, all what You wrote is in:
subentry 'Advanced options for Gentoo GNU/Linux'
...
...
but how to write it right way.

1. Gentoo Linux
2. 'Advanced options for Gentoo GNU/Linux'
2.1 kernel-4.4.6
2.2 kernel-4.4.6 /recovery mode/
2.3 kernel-4.9.6
2.4 kernel-4.9.6 /recovery mode/.
Back to top
View user's profile Send private message
ttre
n00b
n00b


Joined: 04 Aug 2016
Posts: 29

PostPosted: Sun Mar 19, 2017 3:50 pm    Post subject: Reply with quote

ok, found it

GRUB_DEFAULT="1>2" works.

Thx all.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum