Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 659062

Summary: grubby --default-kernel no longer works in anaconda environment
Product: Red Hat Enterprise Linux 6 Reporter: John Ruemker <jruemker>
Component: grubbyAssignee: Peter Jones <pjones>
Status: CLOSED DUPLICATE QA Contact: Release Test Team <release-test-team-automation>
Severity: medium Docs Contact:
Priority: low    
Version: 6.0CC: gasmith, myllynen, rdassen
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-01-27 16:03:38 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:

Description John Ruemker 2010-12-01 20:23:09 UTC
Description of problem: In RHEL 5, grubby --default-kernel could be used from the anaconda environment to print out the default kernel from grub.conf (for instance in a kickstart), and then use that as the basis for further configuration.  In RHEL 6, this is no longer possible.

  # grubby --default-kernel
  # 

It appears this is a result of the change to suitableImage, where in RHEL 5 it would:

    dev = nashGetPathBySpec(_nash_context, dev);
    if (!dev)
        return 0;

    i = stat(dev, &sb);
    if (i)
        return 0;

    stat("/", &sb2);

    if (sb.st_rdev != sb2.st_dev)
        return 0;

    return 1;

So it basically only cared that the device existed and it could stat it, and if so we moved on.  However in RHEL 6 it now tries to obtain the UUID of the block device:

    dev = getpathbyspec(dev);
    if (!dev)
        return 0;

    rootdev = findDiskForRoot();
    if (!rootdev)
        return 0;

    if (!getuuidbydev(rootdev) || !getuuidbydev(dev)) {
        free(rootdev);
        return 0;
    }

    if (strcmp(getuuidbydev(rootdev), getuuidbydev(dev))) {
        free(rootdev);
        return 0;
    }

    free(rootdev);

    return 1;

And cannot because it is /dev/root, so it bails out on the 3rd conditional above and which causes it to return without printing anything:

        if (!suitableImage(entry, bootPrefix, 0, flags)) return 0;

This is breaking my customer's kickstarts and causing them to have to find another way to determine what the default kernel is in grub.

Version-Release number of selected component (if applicable): grubby-7.0.15-2.el6.x86_64

How reproducible: Always (in anaconda)

Steps to Reproduce:
1. Install system 
2. Before rebooting, obtain a shell
3. Type

  # grubby --default-kernel
  
Actual results: Nothing printed

Expected results: It prints the configured default kernel

Additional info: gdb analysis showed where it is bailing out.

Comment 2 John Ruemker 2010-12-01 20:25:03 UTC
I forgot to mention this is in a chroot.