Bug 806172 - grub2-reboot/set-default doesn't work
grub2-reboot/set-default doesn't work
Status: CLOSED WONTFIX
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: grub2 (Show other bugs)
7.0
Unspecified Unspecified
medium Severity medium
: rc
: ---
Assigned To: Peter Jones
:
Depends On: 732058
Blocks:
  Show dependency treegraph
 
Reported: 2012-03-23 01:37 EDT by WANG Chao
Modified: 2015-02-08 16:42 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 732058
Environment:
Last Closed: 2013-08-19 03:01:05 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description WANG Chao 2012-03-23 01:37:14 EDT
+++ This bug was initially created as a clone of Bug #732058 +++

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

--- Additional comment from jskarvad@redhat.com on 2011-08-22 17:26:20 CST ---

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?

--- Additional comment from fedora-admin-xmlrpc@redhat.com on 2011-09-17 03:08:07 CST ---

This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

--- Additional comment from mads@kiilerich.com on 2011-10-25 04:31:10 CST ---

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.

--- Additional comment from mads@kiilerich.com on 2011-10-26 03:23:23 CST ---

I just noticed that anaconda runs grub2-set-default.

--- Additional comment from jskarvad@redhat.com on 2011-11-18 16:31:02 CST ---

*** Bug 753633 has been marked as a duplicate of this bug. ***

--- Additional comment from jskarvad@redhat.com on 2011-11-18 16:41:19 CST ---

(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.

--- Additional comment from a.vanloon@alexandervanloon.nl on 2011-11-27 21:14:30 CST ---

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?

--- Additional comment from mads@kiilerich.com on 2011-11-28 00:38:42 CST ---

Alexander, please file a new bug for the grubby component and attach your grub.cfg.

--- Additional comment from a.vanloon@alexandervanloon.nl on 2011-11-28 21:37:51 CST ---

Done, bug #757712.

--- Additional comment from mads@kiilerich.com on 2011-11-29 01:01:14 CST ---

*** Bug 757712 has been marked as a duplicate of this bug. ***

--- Additional comment from mads@kiilerich.com on 2011-12-09 18:58:25 CST ---

*** Bug 761055 has been marked as a duplicate of this bug. ***

--- Additional comment from Jmlevick@gmail.com on 2011-12-10 05:09:24 CST ---

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.

--- Additional comment from urilabob@gmail.com on 2011-12-10 10:44:23 CST ---

*** Bug 758627 has been marked as a duplicate of this bug. ***

--- Additional comment from urilabob@gmail.com on 2011-12-10 10:53:57 CST ---

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.

--- Additional comment from updates@fedoraproject.org on 2011-12-10 14:09:20 CST ---

grub2-1.99-13.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/grub2-1.99-13.fc16

--- Additional comment from mads@kiilerich.com on 2011-12-10 23:34:58 CST ---

(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.)

--- Additional comment from updates@fedoraproject.org on 2011-12-12 05:53:49 CST ---

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).

--- Additional comment from Jmlevick@gmail.com on 2011-12-14 08:12:46 CST ---

@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 ;)

--- Additional comment from updates@fedoraproject.org on 2011-12-31 06:56:05 CST ---

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.

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