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.