On Fri, Aug 12, 2016 at 1:44 PM, Dr.-Ing. Dieter Jurzitza <dieter.jurzitza@t-online.de> wrote:
Dear listmembers, I am trying to figure out how grub2 does know which kernel to boot. /boot/grub2/grub.cfg shows the names, basically I would like to modify -pv to -default, editiing /boot/grub2/grub.cfg would be a nobrainer, however, the next update would remove this. Can any nice guy here tell me where I would have to change something in order to get from linux-XXX-pv to linux-XXX-default? I did not see this in /etc/default/grub.cfg, nor in /etc/grub.d, but it must be denoted somewhere, isn't it?
It starts with /etc/default/grub GRUB_DEFAULT value. If it's 0 If it =0 then the resulting grub2-mkconfig produced grub.cfg contains: set default="0" If it =saved then the resulting grub.cfg contains: set default="${saved_entry}" If it's a number, it refers to the order of menu entries in the grub.cfg where the first entry is 0, the second entry is 1, etc. If it's saved, it's one of GRUB_SAVEDEFAULT, grub-set-default, or grub-reboot. If GRUB_SAVEDEFAULT=true then the grub.cfg contains commands to cause the chosen boot entry to be saved in grubenv so that it becomes the default at next boot. It's been a couple years since I tested this but for me it never worked. And grub-set-default will accept the ID string that appears after $menuentry_id_option for each menu entry. So that'd be something like: # grub2-set-default 'gnulinux-0-rescue-358f3fdc5df34832b44a6816f3b04881-advanced-dbf2e938-1f28-4e93-aa6c-1e193004931b' # hexdump -C /boot/efi/EFI/fedora/grubenv 00000000 23 20 47 52 55 42 20 45 6e 76 69 72 6f 6e 6d 65 |# GRUB Environme| 00000010 6e 74 20 42 6c 6f 63 6b 0a 73 61 76 65 64 5f 65 |nt Block.saved_e| 00000020 6e 74 72 79 3d 67 6e 75 6c 69 6e 75 78 2d 30 2d |ntry=gnulinux-0-| 00000030 72 65 73 63 75 65 2d 33 35 38 66 33 66 64 63 35 |rescue-358f3fdc5| 00000040 64 66 33 34 38 33 32 62 34 34 61 36 38 31 36 66 |df34832b44a6816f| 00000050 33 62 30 34 38 38 31 2d 61 64 76 61 6e 63 65 64 |3b04881-advanced| 00000060 2d 64 62 66 32 65 39 33 38 2d 31 66 32 38 2d 34 |-dbf2e938-1f28-4| 00000070 65 39 33 2d 61 61 36 63 2d 31 65 31 39 33 30 30 |e93-aa6c-1e19300| 00000080 34 39 33 31 62 0a 23 23 23 23 23 23 23 23 23 23 |4931b.##########| 00000090 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 |################| * 00000400 # So you can see that string was written to the grubenv where it gets picked up by grub because the grub.cfg contains: if [ -s $prefix/grubenv ]; then load_env fi So anyway, there are a number of ways to make a particular entry the default. BIOS systems where /boot/grub2/grubenv is on Btrfs is a problem: https://lists.gnu.org/archive/html/grub-devel/2014-11/msg00010.html I don't know the various consequences of this or how openSUSE works around it; probably the best thing is to not use GRUB_DEFAULT=saved and set it to 0 instead, although that can't actually work out well if the user decides to manually install a lower versioned kernel to work around a bug, because then that most recently installed kernel won't be set as the default unless the user manually sets it as the default which is sort of a screwy workflow. Whatever installs the kernel package would need to have a way to set that kernel as the default. Asking the user to do that would be distinctly suboptimal. There's enough room in biosboot and the mbr gap to store grubenv, I'm not sure why it isn't there anyway seeing as it's just a blob that doesn't really need a file system to manage it. -- Chris Murphy -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org