Bug 736188 - grubby --default-kernel returns empty
grubby --default-kernel returns empty
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: grubby (Show other bugs)
18
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Peter Jones
Fedora Extras Quality Assurance
:
Depends On:
Blocks: 808021
  Show dependency treegraph
 
Reported: 2011-09-06 19:05 EDT by Orion Poplawski
Modified: 2013-08-05 20:18 EDT (History)
8 users (show)

See Also:
Fixed In Version: grubby-8.28-1.fc19
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 808021 (view as bug list)
Environment:
Last Closed: 2013-08-05 20:18:57 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
grub2.cfg (6.00 KB, text/plain)
2013-08-01 12:02 EDT, Orion Poplawski
no flags Details
grubenv (1.00 KB, text/plain)
2013-08-01 12:03 EDT, Orion Poplawski
no flags Details

  None (edit)
Description Orion Poplawski 2011-09-06 19:05:32 EDT
Description of problem:

[root@vmrawhide ~]# grubby --default-kernel
[root@vmrawhide ~]# rpm -q grubby
grubby-8.1-1.fc16.x86_64
Comment 1 Orion Poplawski 2011-09-30 13:16:22 EDT
Looks like it can't handle:

if [ -s $prefix/grubenv ]; then
  load_env
fi
set default="${saved_entry}"

saved_entry is set in /boot/grub2/grubenv, e.g.:

# cat /boot/grub2/grubenv 
# GRUB Environment Block
saved_entry=Fedora Linux, with Linux 3.1.0-0.rc8.git0.0.fc16.i686
#####################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################

This looks like fun.
Comment 2 Orion Poplawski 2011-11-09 13:00:31 EST
At least this goes away after the first kernel update and we get:

set default="0"
Comment 3 Mads Kiilerich 2011-11-25 11:24:53 EST
Bug 732058 is the same issue from another perspective.
Comment 4 Nicolas Chauvet (kwizart) 2012-01-02 15:30:11 EST
I've hit this bug.
I'm using grubby --default-kernel as RPM %post section which return void.
As this case is not handled by my script, it fails. (xorg-x11-drv-nvidia FYI).

The installation was done with the update repository enabled from x86_64 DVD
default installation (as of 20111230).
Comment 5 Julian Sikorski 2012-04-08 04:18:22 EDT
This is a big problem for those of us, blasphemers, who dual-boot but want to have Windows starting by default.
I have followed the directions posted here:
http://fedoraproject.org/wiki/GRUB_2
It works, but only until a kernel is installed or erased. Grubby then thinks it knows better, and overwrites
set default="${saved_entry}"
with
set default="0"
This is very annoying - I have set this on my dad's computer, but he is not enough savvy to run grub2-mkconfig every time a new kernel update comes out (which also backfires since it removes nouveau.modeset=0 and rd.driver.blacklist=nouveau, but this is a different bug).
Comment 6 Mads Kiilerich 2012-04-09 13:39:05 EDT
Julian, the problem you (and comment 2) mention might be related to the core issue reported here, but it is different and better tracked on for example bug 768106.
Comment 7 Julian Sikorski 2012-04-09 16:28:07 EDT
Mads, thanks for the info. I've CCed myself on that bug.
Comment 8 Mark Chappell 2012-11-23 09:48:59 EST
Bumping the Fedora version number so this doesn't get auto-closed
Comment 9 Orion Poplawski 2013-07-03 14:04:35 EDT
Still present in F19.
Comment 10 Peter Jones 2013-07-30 13:41:18 EDT
Please try the build at http://koji.fedoraproject.org/koji/taskinfo?taskID=5680227 , grubby-8.27-1.fc20, which should fix this issue.
Comment 11 Peter Jones 2013-07-30 14:15:21 EDT
Sorry, going to wind up being http://koji.fedoraproject.org/koji/taskinfo?taskID=5680356 instead.
Comment 12 Fedora Update System 2013-07-31 11:09:33 EDT
grubby-8.27-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/grubby-8.27-1.fc19
Comment 13 Orion Poplawski 2013-07-31 11:25:45 EDT
Hmm, doesn't seem to work for me.  I did:

# grub2-mkconfig  > /etc/grub2.cfg
# grubby --default-kernel
#

Header is different now than before:

if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="${saved_entry}"
fi
Comment 14 Peter Jones 2013-08-01 11:35:31 EDT
Can you show me the actual before and after diff?
Comment 15 Peter Jones 2013-08-01 11:49:39 EDT
(and by show, I mean "attach")
Comment 16 Orion Poplawski 2013-08-01 12:02:21 EDT
Created attachment 781667 [details]
grub2.cfg
Comment 17 Orion Poplawski 2013-08-01 12:03:26 EDT
Created attachment 781668 [details]
grubenv

Note I'm running F19 now...
Comment 18 Peter Jones 2013-08-01 14:20:37 EDT
So, this actually seems to be correct behaviour - we're looking for the saved entry, and none of the stanzas match it, so we're not choosing any of them as the default.  Arguably it would be correct for us to fall back to assuming it's the first entry, since that's what grub2 is going to do.

The question this raises is how you got one string into grubenv and another string into grub.cfg's menuentry.
Comment 19 Orion Poplawski 2013-08-01 15:04:25 EDT
Well, it appears that /boot/grub2/grubenv has not been updated since install time.  I've been hacking grub2.cfg to be:

if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default=0
fi

To get grubby to work previously.  Perhaps that prevented grub2 from updating grubenv?  I'll try rebooting and see if that clears it up.

I agree that it may be reasonable to output the first kernel if that is what grub2 will boot.  Or output an error.
Comment 20 Fedora Update System 2013-08-01 23:40:37 EDT
Package grubby-8.27-1.fc19:
* should fix your issue,
* was pushed to the Fedora 19 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing grubby-8.27-1.fc19'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-13999/grubby-8.27-1.fc19
then log in and leave karma (feedback).
Comment 21 Orion Poplawski 2013-08-02 12:49:22 EDT
So simply rebooting didn't seem to help.  I ran:

# grub2-set-default 2

Which did:

# cat /boot/grub2/grubenv
# GRUB Environment Block
saved_entry=2
# grubby --default-kernel
#

So it looks like grubby no longer handles numbers?  Works with names:

# grub2-set-default 'Fedora, with Linux 3.9.9-302.fc19.x86_64'
# grubby --default-kernel
/boot/vmlinuz-3.9.9-302.fc19.x86_64
Comment 22 Fedora Update System 2013-08-02 15:35:33 EDT
grubby-8.28-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/grubby-8.28-1.fc19
Comment 23 Fedora Update System 2013-08-05 20:18:57 EDT
grubby-8.28-1.fc19 has been pushed to the Fedora 19 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.