[opensuse] question on grub2 ...
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? Thank you very much, take care Dieter Jurzitza -- ----------------------------------------------------------- | \ /\_/\ | | ~x~ |/-----\ / \ /- \_/ ^^__ _ / _ ____ / <°°__ \- \_/ | |/ | | || || _| _| _| _| if you really want to see the pictures above - use some font with constant spacing like courier! :-) ----------------------------------------------------------- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Hi, See this: grub2-set-default --help I think it's self explanatory. The latest distros have TAB completion with grub2-set-default which makes the selection of the desired entry easier. Regards. ------------------------------------------------------------------------------ On Friday, 12 August, 2016 21:44:39 Dr.-Ing. Dieter Jurzitza 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? Thank you very much, take care
Dieter Jurzitza -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
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
13.08.2016 00:14, Chris Murphy пишет:
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:
You can also assign them to GRUB_DEFAULT as well. There is no difference in handling, as both end up setting "default" variable at boot time. Also if desired menu entry is in submenu, you should set full "path" including submenu name/ID. I.e. for submenu 'Дополнительные параметры для Ubuntu' $menuentry_id_option 'gnulinux-advanced-d06b07a3-04bf-46e1-8cae-5f2592c69192' { menuentry 'Ubuntu, с Linux 4.4.0-34-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-34-generic-advanced-d06b07a3-04bf-46e1-8cae-5f2592c69192' { to boot the very first menu item in this submenu use (this is one line in case it is wrapped) GRUB_DEFAULT='gnulinux-advanced-d06b07a3-04bf-46e1-8cae-5f2592c69192>gnulinux-4.4.0-34-generic-advanced-d06b07a3-04bf-46e1-8cae-5f2592c69192' Each level is separated by ">"; use ">>" to enter literal ">".
# 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;
Leap and Tumnleweed include patch to store environment block in unused space in the first 1MB. This probably won't work (reliably) on multidevice btrfs because grub does not offer any means currently to identify specific member of multi-device object (be it btrfs, LVM or MD) but multidevice btrfs is also not officially supported, at least for root.
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 for legacy layouts with 63 sectors gap.
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.
The problem is to find it. How you identify disk that has environment block in its MBR? /boot/grub/grubenv is stable handle which will be found always, as long as /boot/grub is not formatted. "MBR of boot disk" is not as you can install boot code on any number of disks and point all of them to the same /boot/grub. Also every platform has /boot/grub, but not every platform has MBR or space to store environment. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Dear listmembers, hello Andrei, Chris, Ico, honestly speaking I never ever expected so a simple thing to be implemented in such a complicated manner. Is it unusual to make another kernel the default choice - don't think so. Would a user want this - the answer (my answer ...) is "yes". But what I saw from your comments describes a complexity I never ever anticipated to be possible for a normal thinking person :-) Two variables - a string containing the name printed on boot and a number referring to the desired entry in the list - this would be understandable. I cannot remember this had had been so complicated in the "good old" (:-)) times when we were discussing lilo or grub (1). Anyway, thank you very very much for your detailled descriptions and your efforts - based on this I can proceed, have a nice and relaxing weekend, thanks again Dieter Jurzitza Am Samstag, 13. August 2016, 09:13:53 schrieb Andrei Borzenkov:
13.08.2016 00:14, Chris Murphy пишет:
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.
-- ----------------------------------------------------------- | \ /\_/\ | | ~x~ |/-----\ / \ /- \_/ ^^__ _ / _ ____ / <°°__ \- \_/ | |/ | | || || _| _| _| _| if you really want to see the pictures above - use some font with constant spacing like courier! :-) ----------------------------------------------------------- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (4)
-
Andrei Borzenkov
-
Chris Murphy
-
Dr.-Ing. Dieter Jurzitza
-
Ico Petrov