Bug 16059 - default entry set by drakboot isn't enforced by grub2
Summary: default entry set by drakboot isn't enforced by grub2
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: Installer (show other bugs)
Version: Cauldron
Hardware: x86_64 Linux
Priority: Normal major
Target Milestone: ---
Assignee: Thierry Vignaud
QA Contact:
URL:
Whiteboard:
Keywords: NEEDINFO, PATCH
Depends on:
Blocks: 416
  Show dependency treegraph
 
Reported: 2015-05-30 11:19 CEST by papoteur
Modified: 2016-06-06 10:46 CEST (History)
2 users (show)

See Also:
Source RPM: grub2, drakxtools
CVE:
Status comment:


Attachments
set default grub2 entry in /etc/default/grub (2.06 KB, patch)
2015-06-05 14:58 CEST, Thierry Vignaud
Details | Diff
grub.cfg diff (696 bytes, patch)
2015-06-05 15:06 CEST, Thierry Vignaud
Details | Diff

Description papoteur 2015-05-30 11:19:40 CEST
Description of problem:
Installation with DVD-x86_64 pre-final-round 3 on UEFI laptop.
Bootloader from summary at installation step.
Ask for installation in sdax, (/ of the new installation).
Ask to have already installed Mageia 4 as default entry.
After reboot, the default entry is the first line, i.e. the new installation, not my Mageia 4.
The Mageia 4 system has no more bootloader to configure.
Restart Mageia 5
Go to MCC, configure the bootloader. It is in /dev/sda.
The default option is Mageia 4 ! Write the configuration.
At reboot, the default entry is always the first line.


Reproducible: 

Steps to Reproduce:
Manuel Hiebel 2015-05-30 12:44:42 CEST

Assignee: bugsquad => thierry.vignaud

Comment 1 Thierry Vignaud 2015-05-30 18:36:42 CEST
Please attach your /root/drakx/report.bug.xz & the file resulting from running:
journalctl|egrep 'drakboot|os-prober|grub'>/tmp/journal.txt

Keywords: (none) => NEEDINFO

Comment 2 papoteur 2015-05-30 19:21:23 CEST
For report.bug, it is already here: 
https://bugs.mageia.org/attachment.cgi?id=6668
I must reboot to access the journal entries.
Comment 3 papoteur 2015-05-30 19:45:48 CEST
Journal is short and haven't such entries.
Papoteur
Samuel Verschelde 2015-05-30 23:47:28 CEST

Summary: MCC doesn't set the default entry as selected for grub2 => drakboot doesn't apply user-selected default entry when using grub2
Severity: normal => major

Comment 4 Thierry Vignaud 2015-05-31 00:18:51 CEST
If journal is short then you didn't run "drakboot --boot"...

As for drakx, we did run the following command:
"grub2-set-default Mageia 4 (4) (sur /dev/sda5)"
which means we respect your choice.
So that would be a grub2 bug.

What happens if you manually run the following command?
grub2-set-default "Mageia 4 (4) (sur /dev/sda5)"

CC: (none) => zen25000
Blocks: (none) => 416
Source RPM: (none) => grub2

Comment 5 papoteur 2015-05-31 09:47:38 CEST
Before I run this command, I checkeddd the file /boot/grub2/grubenv.
Its content is:
# GRUB Environment Block
saved_entry=Mageia 4 (4) (sur /dev/sda5)
##########################################

The command grub2-set-default "Mageia 4 (4) (sur /dev/sda5)" gives no message when executed. Yet I will reboot to see if something is changed a boot.
Comment 6 papoteur 2015-05-31 09:52:26 CEST
s/a boot/at boot
There is no changes, the default entry is always the first line.
Comment 7 Thierry Vignaud 2015-06-02 09:27:14 CEST
Barry:
grub.cfg contains "menuentry 'Mageia 4 (4) (sur /dev/sda5)' ..." (from os-prober).
However, depsite grub2-set-default "Mageia 4 (4) (sur /dev/sda5)" having altered  /boot/grub2/grubenv, this is not respected by grub2 on booting

Assignee: thierry.vignaud => zen25000
Summary: drakboot doesn't apply user-selected default entry when using grub2 => default entry set by drakboot isn't enforced by grub2

Comment 8 Barry Jackson 2015-06-03 00:28:44 CEST
(In reply to Thierry Vignaud from comment #7)
> Barry:
> grub.cfg contains "menuentry 'Mageia 4 (4) (sur /dev/sda5)' ..." (from
> os-prober).
> However, depsite grub2-set-default "Mageia 4 (4) (sur /dev/sda5)" having
> altered  /boot/grub2/grubenv, this is not respected by grub2 on booting

Is grub2-mkconfig -o /boot/grub2/grub.cfg OR update-grub
run afterwards?

I have always used a GRUB_DEFAULT= entry in /etc/default/grub
(followed by grub2-mkconfig) for that purpose.

e.g.:
GRUB_DEFAULT="Windows Vista (loader) (on /dev/sda2)"

I have never used or tested grub2-set-default.
Comment 9 Barry Jackson 2015-06-03 01:02:59 CEST
I can confirm that grub2-set-default does not seem to work, in fact I was not aware of it.

However I think it is more consistent to use the GRUB_DEFAULT variable in /etc/default/grub for this which does work correctly. (Keeping all configuration in one place)

I have just tested it in a clean Mga5 install and I also have a laptop that uses it with Mga5 with no problems.
Comment 10 Barry Jackson 2015-06-05 14:36:57 CEST
@thierry
I just noticed that you were not cc'd on this.

CC: (none) => thierry.vignaud

Comment 11 Thierry Vignaud 2015-06-05 14:58:38 CEST
That's easy to do (see attached patch).

However, grub2-set-default did worked at some stage, so there's some regression.
Also wouldn't GRUB_DEFAULT be overwritten if we boot another entry?
Wouldn't it be set back to GRUB_DEFAULT="saved"?
Comment 12 Thierry Vignaud 2015-06-05 14:58:40 CEST
Created attachment 6706 [details]
set default grub2 entry in /etc/default/grub

Anyway, it would me much simpler this way
Thierry Vignaud 2015-06-05 14:59:00 CEST

Keywords: (none) => PATCH

Comment 13 Thierry Vignaud 2015-06-05 15:06:31 CEST
Created attachment 6707 [details]
grub.cfg diff

though it didn't work in my case: grub2-mkconfig introduced a bogus if block that messed up the default entry...
grub2 then default to first entry ("Mageia")

grub2 needs serious fixing...
Comment 14 Barry Jackson 2015-06-05 16:26:21 CEST
(In reply to Thierry Vignaud from comment #11)
> That's easy to do (see attached patch).
> 
> However, grub2-set-default did worked at some stage, so there's some
> regression.
> Also wouldn't GRUB_DEFAULT be overwritten if we boot another entry?
> Wouldn't it be set back to GRUB_DEFAULT="saved"?

I have never seen that happen.
Comment 15 Barry Jackson 2015-06-05 16:42:30 CEST
I have just been reading the docs and it seems that grub2-set-default should only work if GRUB_DEFAULT="saved".

It will not be changed on each boot as long as we don't have GRUB_SAVEDEFAULT set.

I will try to test this later.
Comment 16 Barry Jackson 2015-06-05 23:49:13 CEST
Yes, that seems to work - so for the current use of grub2-set-default to work it needs to be combined with GRUB_DEFAULT="saved".
Comment 17 papoteur 2015-06-06 07:47:51 CEST
Hello,I confirm that 
grub2-set-default "Mageia 4 (4) (sur /dev/sda5)"
GRUB_DEFAULT="saved"
and update-grub
works to change the default entry.
Barry Jackson 2015-06-06 17:46:44 CEST

Assignee: zen25000 => thierry.vignaud
Source RPM: grub2 => drakxtools

Comment 18 Thierry Vignaud 2015-06-08 20:41:46 CEST
Barry, no it doesn't work everywhere.
It doesn't work at all on my test VM. See comment #13

Source RPM: drakxtools => grub2, drakxtools

Comment 19 Barry Jackson 2015-06-08 21:31:07 CEST
(In reply to Thierry Vignaud from comment #18)
> Barry, no it doesn't work everywhere.
> It doesn't work at all on my test VM. See comment #13

In comment 13 you were testing the use of just GRUB_DEFAULT not grub2-set-default.

Did you also test in VM using the same as papoteur in #17?
Comment 20 Barry Jackson 2015-06-08 22:09:59 CEST
@Thierry
I just tested in a fully updated Mga5 VM (PC-BIOS) and it worked fine.

Was your test in A UEFI system or PC-BIOS?
Comment 21 Barry Jackson 2015-12-24 15:14:03 CET
On the last kernel update in Cauldron I noticed this:

--------snip-----------

removing upgraded package kernel-server-latest-4.3.2-2.mga6.x86_64
      1/3: removing kernel-server-latest-4.3.2-2.mga6.x86_64
                                 #############################################
removing upgraded package kernel-desktop-latest-4.3.2-2.mga6.x86_64
      2/3: removing kernel-desktop-latest-4.3.2-2.mga6.x86_64
                                 #############################################
removing upgraded package cpupower-4.3.2-2.mga6.x86_64
      3/3: removing cpupower-4.3.2-2.mga6.x86_64
                                 #############################################
Creating: target|kernel|dracut args|basicmodules 
Usage: grub2-set-default [OPTION] MENU_ENTRY
Set the default boot menu entry for GRUB.
This requires setting GRUB_DEFAULT=saved in /etc/default/grub.

  -h, --help              print this message and exit
  -v, --version           print the version information and exit
  --boot-directory=DIR    expect GRUB images under the directory DIR//grub2
                          instead of the /boot/grub2 directory

MENU_ENTRY is a number, a menu item title or a menu item identifier.

Report bugs to <bug-grub@gnu.org>.
Creating: target|kernel|dracut args|basicmodules 
Usage: grub2-set-default [OPTION] MENU_ENTRY
Set the default boot menu entry for GRUB.
This requires setting GRUB_DEFAULT=saved in /etc/default/grub.

  -h, --help              print this message and exit
  -v, --version           print the version information and exit
  --boot-directory=DIR    expect GRUB images under the directory DIR//grub2
                          instead of the /boot/grub2 directory

MENU_ENTRY is a number, a menu item title or a menu item identifier.

Report bugs to <bug-grub@gnu.org>.
removing installed rpms (kernel-desktop-4.4.0-0.rc6.2.mga6-1-1.mga6.x86_64.rpm kernel-server-4.4.0-0.rc6.2.mga6-1-1.mga6.x86_64.rpm kernel-desktop-latest-4.4.0-0.rc6.2.mga6.x86_64.rpm kernel-server-latest-4.4.0-0.rc6.2.mga6.x86_64.rpm cpupower-4.4.0-0.rc6.2.mga6.x86_64.rpm) from /var/cache/urpmi/rpms

-------snip------------

[baz@jackodesktop ~]$ cat /etc/default/grub
GRUB_ENABLE_CRYPTODISK=y
GRUB_GFXPAYLOAD_LINUX=auto
GRUB_GFXMODE=1024x768x32
GRUB_TERMINAL_OUTPUT=gfxterm
GRUB_CMDLINE_LINUX_DEFAULT=" splash quiet noiswmd resume=UUID=d0402b80-ef19-4956-9064-abe20fe77dc0"
GRUB_DISABLE_OS_PROBER=false
GRUB_THEME=/boot/grub2/themes/maggy/theme.txt
GRUB_DISABLE_SUBMENU=n
GRUB_DISABLE_RECOVERY=false
GRUB_DISTRIBUTOR=Mageia
GRUB_TIMEOUT=10

Maybe this should only be run if GRUB_DEFAULT=saved
Thierry Vignaud 2016-05-31 11:09:49 CEST

See Also: (none) => https://bugs.mageia.org/show_bug.cgi?id=18560

Comment 22 Mageia Robot 2016-06-06 10:36:15 CEST
commit ad128f02d165f26d7eec3781952f108efb588c67
Author: Thierry Vignaud <tvignaud@...>
Date:   Fri May 27 16:38:51 2016 +0200

    grub2: set GRUB_DEFAULT + GRUB_SAVEDEFAULT
    
    else grub2-set-default won't work (mga#9627, mga#16059)
    but do not overwrite it if user has changed its value
---
 Commit Link:
   http://gitweb.mageia.org/software/drakx/commit/?id=ad128f02d165f26d7eec3781952f108efb588c67

 Bug links:
   Mageia
      https://bugs.mageia.org/9627
      https://bugs.mageia.org/16059
Comment 23 Thierry Vignaud 2016-06-06 10:46:16 CEST
Fixed in git

Status: NEW => RESOLVED
Resolution: (none) => FIXED


Note You need to log in before you can comment on or make changes to this bug.