Bug 1469821

Summary: Update to RHEL 7 kickstart documentation option --leavebootorder
Product: Red Hat Enterprise Linux 7 Reporter: Devon <dshumake>
Component: doc-Installation_GuideAssignee: Lenka Kimlickova <lkimlick>
Status: CLOSED CURRENTRELEASE QA Contact: ecs-bugs
Severity: unspecified Docs Contact:
Priority: high    
Version: 7.4CC: mkolman, pbokoc, pjones, rhel-docs
Target Milestone: rcKeywords: Documentation
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-10-20 14:44:51 UTC Type: Bug
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: 1470091    

Description Devon 2017-07-11 22:03:16 UTC
Document URL: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Installation_Guide/sect-kickstart-syntax.html

Section Number and Name: 24.3.2 Kickstart Commands and Options

Describe the issue: A customer was requesting that the --leavebootorder be more clear that it does not leave the boot order exactly as is.

Suggestions for improvement: 

The customer would just like the docs to clearly state that the boot order is not left completely unchanged as they had expected. In the words of the customer:
"Suggestion:  The documentation about --leavebootorder is missing notes about how it interacts, or can be superseded by --driveorder.  The concept of what "leavebootorder" actually is intended to do should be clarified as well.  The fact that Anaconda always changes the bootorder (efi mode) and puts linux at the top should be clear too."

Additional information: 


From the findings on how --leavebootorder actually works

We were able to confirm that this is the default and expected behavior.

    # man efibootmgr

     An  OS  installer  would call efibootmgr -c.  This assumes that /boot/efi is your EFI System Partition, and is mounted at /dev/sda1.  This creates a new boot option, called "Linux", and puts it at the top of the boot order list.

I have noted that our internal documentation is misleading and as such I will open a bug to get the description of what the --leavebootorder option does.

##################################################

class EFIBase(object):

...

    def efibootmgr(self, *args, **kwargs):
        if flags.imageInstall or flags.dirInstall:
            log.info("Skipping efibootmgr for image/directory install.")
            return ""

        if "noefi" in flags.cmdline:
            log.info("Skipping efibootmgr for noefi")
            return ""

        if kwargs.pop("capture", False):
            exec_func = iutil.execWithCapture
        else:
            exec_func = iutil.execWithRedirect
        if "root" not in kwargs:
            kwargs["root"] = iutil.getSysroot()

        return exec_func("efibootmgr", list(args), **kwargs)

...

    def _add_single_efi_boot_target(self, partition):
        boot_disk = partition.disk
        boot_part_num = str(partition.parted_partition.number)

        rc = self.efibootmgr(
            "-c", "-w", "-L", productName.split("-")[0],  # pylint: disable=no-member
            "-d", boot_disk.path, "-p", boot_part_num,
            "-l", self.efi_dir_as_efifs_dir + self._efi_binary,  # pylint: disable=no-member
            root=iutil.getSysroot()
        )
        if rc:
            raise BootLoaderError("failed to set new efi boot target. This is most likely a kernel or firmware bug.")


...

    def install(self, args=None):
        if not flags.leavebootorder:
            self.remove_efi_boot_target()
        self.add_efi_boot_target()

##############################################

The --leavebootorder only prevents the installation from running the remove_efi_boot_target() which would have otherwise gone through all of the entries and used a command such as efibootmgr("-b", slot_id, "-B") to remove the other installed products such as old rhel installations. 

From the logs, we can see that the following command is run by the installer. 

    21:59:43,329 INFO program: Running... efibootmgr -c -w -L Red Hat Enterprise Linux -d /dev/nvme0n1 -p 1 -l \EFI\redhat\shim.efi

And this has the effect of adding the entry to the list and making it first in the boot order.

21:59:43,406 INFO program: BootOrder: 0009,000C,000C,000C,000C,000A,000B,000E,0000,0001,0002,0003,0004,0005,0006,0007,0008,000D
21:59:43,406 INFO program: Boot0000  Startup Menu
21:59:43,406 INFO program: Boot0001  System Information
21:59:43,406 INFO program: Boot0002  Bios Setup
21:59:43,406 INFO program: Boot0003  3rd Party Option ROM Management
21:59:43,406 INFO program: Boot0004  System Diagnostics
21:59:43,406 INFO program: Boot0005  System Diagnostics
21:59:43,407 INFO program: Boot0006  System Diagnostics
21:59:43,407 INFO program: Boot0007  System Diagnostics
21:59:43,407 INFO program: Boot0008  Boot Menu
21:59:43,407 INFO program: Boot000A* Red Hat Enterprise Linux
21:59:43,407 INFO program: Boot000B* IPV6 Network - Intel(R) Ethernet Connection (2) I218-LM
21:59:43,407 INFO program: Boot000C* IPV4 Network - Intel(R) Ethernet Connection (2) I218-LM
21:59:43,407 INFO program: Boot000D  Network Boot
21:59:43,407 INFO program: Boot000E* hp PLDS DVDROM DU8RESH
21:59:43,408 INFO program: Boot000F  USB:
21:59:43,408 INFO program: Boot0010* hp PLDS DVDROM DU8RESH
21:59:43,408 INFO program: Boot0011* hp PLDS DVDROM DU8RESH
21:59:43,408 INFO program: Boot0013* NVMe Drive
21:59:43,408 INFO program: Boot0009* Red Hat Enterprise Linux

This is caused by the _add_single_efi_boot_target() which will always be run to add the new install:

    def install(self, args=None):
        if not flags.leavebootorder:
            self.remove_efi_boot_target()
        self.add_efi_boot_target()

Thus, the --leavebootorder option is intended to leave previous OS installation's EFI boot entries. The installer will always add rhel as the first entry based on the above findings.