Bug 736188

Summary: grubby --default-kernel returns empty
Product: [Fedora] Fedora Reporter: Orion Poplawski <orion>
Component: grubbyAssignee: Peter Jones <pjones>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 18CC: bcl, belegdol, kwizart, mads, mchappel, mwest, orion, pjones
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
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-06 00:18:57 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 808021    
Attachments:
Description Flags
grub2.cfg
none
grubenv none

Description Orion Poplawski 2011-09-06 23:05:32 UTC
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 17:16:22 UTC
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 18:00:31 UTC
At least this goes away after the first kernel update and we get:

set default="0"

Comment 3 Mads Kiilerich 2011-11-25 16:24:53 UTC
Bug 732058 is the same issue from another perspective.

Comment 4 Nicolas Chauvet (kwizart) 2012-01-02 20:30:11 UTC
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 08:18:22 UTC
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 17:39:05 UTC
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 20:28:07 UTC
Mads, thanks for the info. I've CCed myself on that bug.

Comment 8 Mark Chappell 2012-11-23 14:48:59 UTC
Bumping the Fedora version number so this doesn't get auto-closed

Comment 9 Orion Poplawski 2013-07-03 18:04:35 UTC
Still present in F19.

Comment 10 Peter Jones 2013-07-30 17:41:18 UTC
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 18:15:21 UTC
Sorry, going to wind up being http://koji.fedoraproject.org/koji/taskinfo?taskID=5680356 instead.

Comment 12 Fedora Update System 2013-07-31 15:09:33 UTC
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 15:25:45 UTC
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 15:35:31 UTC
Can you show me the actual before and after diff?

Comment 15 Peter Jones 2013-08-01 15:49:39 UTC
(and by show, I mean "attach")

Comment 16 Orion Poplawski 2013-08-01 16:02:21 UTC
Created attachment 781667 [details]
grub2.cfg

Comment 17 Orion Poplawski 2013-08-01 16:03:26 UTC
Created attachment 781668 [details]
grubenv

Note I'm running F19 now...

Comment 18 Peter Jones 2013-08-01 18:20:37 UTC
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 19:04:25 UTC
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-02 03:40:37 UTC
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 16:49:22 UTC
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 19:35:33 UTC
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-06 00:18:57 UTC
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.