Bug 732058 - grub2-reboot/set-default doesn't work
grub2-reboot/set-default doesn't work
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: grub2 (Show other bugs)
16
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Peter Jones
Fedora Extras Quality Assurance
:
: 753633 757712 758627 761055 (view as bug list)
Depends On:
Blocks: 806172
  Show dependency treegraph
 
Reported: 2011-08-19 12:08 EDT by Jaroslav Škarvada
Modified: 2012-05-20 07:10 EDT (History)
13 users (show)

See Also:
Fixed In Version: grub2-1.99-13.fc16
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 806172 (view as bug list)
Environment:
Last Closed: 2011-12-30 17:56:05 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Jaroslav Škarvada 2011-08-19 12:08:21 EDT
Description of problem:
With default setup, two kernel images, 'grub2-reboot 1' updates grubenv, but this settings is not honoured, kernel 0 is booted instead.

Version-Release number of selected component (if applicable):
grub2-1.99-0.2.fc16.x86_64

How reproducible:
Always

Steps to Reproduce:
1. setup 2 kernels
2. grub2-reboot 1
3. reboot
  
Actual results:
kernel 0 is booted

Expected results:
kernel 1 is booted once

Additional info:
Same with grub2-set-default
Comment 1 Jaroslav Škarvada 2011-08-22 05:26:20 EDT
My fault, it needs a bit grub2 config tweaking:
$ cat /etc/default/grub 
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true

Then it works OK. Could we go with it by default in Fedora? I need this functionality in pm-utils 01grub hook. I can also only document this requirement. Or is there any other possibility how to emulate the --once in grub2 with default config?
Comment 2 Fedora Admin XMLRPC Client 2011-09-16 15:08:07 EDT
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.
Comment 3 Mads Kiilerich 2011-10-24 16:31:10 EDT
Note that anaconda by default will overwrite /etc/default/grub with GRUB_DEFAULT=saved but no GRUB_SAVEDEFAULT.

grubby will however be invoked with --make-default and replace
  set default="${saved_entry}"
with
  set default="0"

I guess the best way to get "boot once" would be to create some /etc/grub.d/01_pm that set the default based on the boot environment variables in another way.

grub2-set-default is apparently a bad fit for Fedora where that usually is handled by grubby.
Comment 4 Mads Kiilerich 2011-10-25 15:23:23 EDT
I just noticed that anaconda runs grub2-set-default.
Comment 5 Jaroslav Škarvada 2011-11-18 03:31:02 EST
*** Bug 753633 has been marked as a duplicate of this bug. ***
Comment 6 Jaroslav Škarvada 2011-11-18 03:41:19 EST
(In reply to comment #3)
> I guess the best way to get "boot once" would be to create some
> /etc/grub.d/01_pm that set the default based on the boot environment variables
> in another way.
> 
I can reinvent the wheel and implement own /etc/grub.d/01_pm, but I think the boot once functionality should be there out of the box as was in previous fedoras. Other packages could also benefit from it, not only the pm-utils.
Comment 7 Alexander van Loon 2011-11-27 08:14:30 EST
What I just discovered after doing a fresh install of F16 is that it keeps booting the kernel which came with the installation, even after it installed a new kernel through the updates. Is my problem related to this bug or should I file a new bug?

I also don't understand why GRUB_DEFAULT is set to 'saved' (which I assume has something to do with this problem)? On my Kubuntu machine it is set to '0' so that the latest kernel is always booted, why does Fedora do it differently?
Comment 8 Mads Kiilerich 2011-11-27 11:38:42 EST
Alexander, please file a new bug for the grubby component and attach your grub.cfg.
Comment 9 Alexander van Loon 2011-11-28 08:37:51 EST
Done, bug #757712.
Comment 10 Mads Kiilerich 2011-11-28 12:01:14 EST
*** Bug 757712 has been marked as a duplicate of this bug. ***
Comment 11 Mads Kiilerich 2011-12-09 05:58:25 EST
*** Bug 761055 has been marked as a duplicate of this bug. ***
Comment 12 jmlevick 2011-12-09 16:09:24 EST
I have a workaround for this...

You have to add these two lines to your "/etc/default/grub" file:

GRUB_DEFAULT=0
GRUB_SAVEDEFAULT=true

(Maybe you already have "GRUB_DEFAULT" but with "saved" value, change it to 0, the other line I'll bet you don't have it by default in that file...) We can also change "GRUB_TIMEOUT" to 0 if we don't want to see the kernels list when booting.

Then, we have to run:

su -
grub2-mkconfig -o /boot/grub2/grub.cfg 

And that's it, You'll be always booting into the last kernel without any problems.

That fixed the bug for me, in my case, I noticed same thing than Alexander van Loon.
Comment 13 bob mckay 2011-12-09 21:44:23 EST
*** Bug 758627 has been marked as a duplicate of this bug. ***
Comment 14 bob mckay 2011-12-09 21:53:57 EST
I'd like to support Jaroslav's request, that
  $ cat /etc/default/grub 
  GRUB_DEFAULT=saved
  GRUB_SAVEDEFAULT=true
become the default. The problem with the current configuration is that grub2
works in an easy-to-understand way out-of-the-box, but making any change - just
changing kernel parameters, for example - requires running grub2-mkconfig,
which then changes the behaviour in completely unexpected ways (just look at
the number of bugs marked as duplicates of this one). Changing a kernel
parameter should not require a detailed understanding of grub2 and how it
differs from grub.
Comment 15 Fedora Update System 2011-12-10 01:09:20 EST
grub2-1.99-13.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/grub2-1.99-13.fc16
Comment 16 Mads Kiilerich 2011-12-10 10:34:58 EST
(In reply to comment #12)
> I have a workaround for this...

It is only a partial workaround. It will only work until the first time a new kernel is installed, as mentioned in comment 3. I don't know if that is by design or not.

A solution could be if new-kernel-pkg used grubby --default-kernel to see if it should use grubby --make-default or grub2-set-default. (That might require a fix for bug 736188 first.)
Comment 17 Fedora Update System 2011-12-11 16:53:49 EST
Package grub2-1.99-13.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing grub2-1.99-13.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2011-16975/grub2-1.99-13.fc16
then log in and leave karma (feedback).
Comment 18 jmlevick 2011-12-13 19:12:46 EST
@Mads Kiilerich: the workaround I posted is actually permanent I tested it in two different computers updating their kernels after applying the workaround... Anyway the update pushing is better ;)
Comment 19 Fedora Update System 2011-12-30 17:56:05 EST
grub2-1.99-13.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 20 Mads Kiilerich 2012-04-09 13:03:50 EDT
Are anybody here really sure that GRUB_SAVEDEFAULT=true is needed? I am sure it isn't.

GRUB_SAVEDEFAULT=true will just update 'grubenv' from the boot loader and do that any kernel that has been chosen manually in the menu will be used for the next boot too.

(GRUB_DEFAULT=saved should work even without GRUB_SAVEDEFAULT.)

Updating grubenv from grub will however only work if it is placed on a plain disk. It will not work if LVM or RAID is involved. Fedora can thus not rely on it and shouldn't try to use it by default ... and it doesn't, because anaconda (f17) overwrites the grub2 /etc/default/grub. The default in the grub2 rpm should however also not have this line.

A related and bigger problem might be that when grub2 on LVM or RAID can't update grubenv then the 'once' part of grub2-reboot doesn't work and grub2-reboot shouldn't be used.
Comment 21 Richard W.M. Jones 2012-04-16 06:39:59 EDT
Fedora 17: grub-set-default has no visible effect for me.

It always boots kernel 0, no matter what I set the default
to.

$ cat /etc/default/grub 
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Fedora"
GRUB_DEFAULT=saved
GRUB_CMDLINE_LINUX="rd.lvm.lv=vg_trick/lv_swap rd.md=0 rd.dm=0 SYSFONT=True rd.lvm.lv=vg_trick/lv_root  KEYTABLE=uk rd.luks=0 LANG=en_US.UTF-8 rhgb quiet"

$ cat /boot/grub2/grubenv 
# GRUB Environment Block
saved_entry=Fedora Linux, with Linux 3.3.1-3.fc17.x86_64
##############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################


(Note: correct kernel is selected in grubenv)

No combination of settings or grub2-mkconfig fixes this.  It appears
to always boot kernel 0 whatever.
Comment 22 Mads Kiilerich 2012-04-16 06:58:26 EDT
(In reply to comment #21)
> Fedora 17: grub-set-default has no visible effect for me.
> 
> It always boots kernel 0, no matter what I set the default
> to.

That sounds a lot like Bug 768106

> No combination of settings or grub2-mkconfig fixes this.  It appears
> to always boot kernel 0 whatever.

That is strange and makes it different from Bug 768106. Are you sure you are generating the right grub.cfg? Can you verify by making some manual changes to some title and reboot? How does your generated grub.cfg look like?

(Your issue seem to be different from what is discussed here - it would perhaps be better to file a new issue.)
Comment 23 Richard W.M. Jones 2012-04-16 07:23:25 EDT
I think I've worked this out.  It's because the menus are
nested in Fedora 17, so you have to set the default entry to:

Advanced options for Fedora Linux>Fedora Linux, with Linux 3.3.1-3.fc17.x86_64

(not just the part after the > sign).
Comment 24 Andrew Travneff 2012-05-20 07:10:52 EDT
Have same issue with Richard. Filed as #823253

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