EFI EXIT type chainloading failed

  • Moderator

    @chris_unit

    No on the undoing steps.

    the default refind is configured correctly for windows. What you need to do for the refind 2 configuration is to configure the refind2.conf file so that it ONLY looks for the second OS so it won’t see windows and try to boot it.


  • @george1421

    can you check my syntax in case that’s the issue

       private static $_exitTypes = array();
        /**
         * Initializes the boot menu class
         *
         * @return void
         */
        public function __construct()
        {
            parent::__construct();
            $grubChain = 'chain -ar ${boot-url}/service/ipxe/grub.exe '
                . '--config-file="%s"';
            $sanboot = 'sanboot --no-describe --drive 0x80';
            $refind = sprintf(
                'imgfetch ${boot-url}/service/ipxe/refind.conf%s'
                . 'chain -ar ${boot-url}/service/ipxe/refind_x64.efi',
                "\n"
            );
            $refindx2 = sprintf(
                 'imgfetch ${boot-url}/service/ipxe/refindx2.conf%s'
                 . 'chain -ar ${boot-url}/service/ipxe/refind_x64.efi',
                 "\n"
             );
            if (stripos($_REQUEST['arch'], 'i386') !== false) {
                //user i386 boot loaders instead
                $refind = sprintf(
                    'imgfetch ${boot-url}/service/ipxe/refind.conf%s'
                    . 'chain -ar ${boot-url}/service/ipxe/refind_ia32.efi',
                    "\n"
                );
            }
    
            if (stripos($_REQUEST['arch'], 'arm') !== false) {
                //use arm boot loaders instead
                $refind = 'chain -ar ${boot-url}/service/ipxe/refind_aa64.efi';
            }
    
            $grub = array(
                'basic' => sprintf(
                    $grubChain,
                    'rootnoverify (hd0);chainloader +1'
                ),
                '1cd' => sprintf(
                    $grubChain,
                    'cdrom --init;map --hook;root (cd0);chainloader (cd0)"'
                ),
                '1fw' => sprintf(
                    $grubChain,
                    'find --set-root /BOOTMGR;chainloader /BOOTMGR"'
                )
    

  • @george1421 yes we’re are trying to be uefi across the board

    so should we undo all the steps to create the for efix2 or is this still useable in a fully uefi system?

    i’m not sure why memdisk is getting involved. is that part of refind?

    the original refind option boots perfectly into windows, surely we’ve just created new option in fog which runs a duplicate config file which is identical to the original?

  • Moderator

    @chris_unit well I don’t think its an exit mode that is causing what is in your picture.

    Based on the error I’m going to guess at this.

    1. Your computer is a uefi based one since you are using refind.
    2. Memdisk is a bios based program that will not run on a uefi system.

    You have apposing conditions here so the error message is understandable. Exec format error. That’s unrelated to the hack a proposed below.


  • @george1421

    Hi there,

    this might be exactly what i’m looking for, creating two refind exit options, one to windows, one to ubuntu.

    I’ve followed your steps belo but i’m getting the following error when tryinig to use the newly created REFIND_EFIX2 option

    PXL_20211018_134852855.jpg


  • @george1421 Great, thank you

  • Moderator

    @eruthon said in EFI EXIT type chainloading failed:

    But if I understand correctly, wouldn’t editing only the original refind.conf file by adding Debian option solve the problem, too?

    I guess I have 2 points here.

    1. We created a second exit mode for refind in case the settings you have in the second refind conflict with efi exit booting for other hardware. If what you have in this second refind.conf file is acceptable for all of your computers on your campus then these edits are unnecessary. I didn’t know to what extent you would need to adjust the original refind.conf file (possibly we should have started there and then decided to go the hack path).
    2. The FOG programmers have to keep the configuration generic so that it works for the largest population of hardware. Most don’t want an additional menu after exiting from FOG. I personally would like to see a few extra UEFI exit modes included in the FOG base so for unique hardware this process you did could be used by picking an alternate refind.conf file.

    If updating the default refind.conf works for you and its good on all of your hardware, then just update the global UEFI exit mode in the FOG Configuration->FOG Settings panel.


  • Your guidance has been very helpful and spot on. It works exactly as I wanted: the grubx64.efi is now shown in rEFInd menu after “Booting…”

    But if I understand correctly, wouldn’t editing only the original refind.conf file by adding Debian option solve the problem, too? Maybe it could be added to the next release of FOG out of the box, because Ubuntu is already there.

  • Moderator

    @eruthon The system is working as designed but not like how you want it. I do have a few ideas to get to where you need. Its going to take a little code hacking but the changes are not significant.

    rEFInd should probably do what you need to point to grub.efi refind has a config file on the fog server that can be used to tweak how refind goes about finding the bootstrap file you want. The issue is with the default config file for refind its an all or nothing situation. I assume you might have other EFI systems that you would want to boot normal, but specific systems where you want to boot into the grub menu and not directly into windows (default action for how refind works). To do this we need to create a new refind.conf file with the settings we need to locate the grub.efi file, but leave the original one in place so the other efi systems boot normally.

    To give us a bit more flexibility we are going to modify just a few lines of code in the fog programming. Understand the next time FOG is upgraded you will loose these edits.

    On the fog server here are the steps to make a few adjustments. I use vi as my default editor (because I’m crazy) you can use whatever editor you want.

    cd /var/www/html/fog
    vi lib/fog/bootmenu.class.php
    

    Around line 131 you will see this section of code

             $refind = sprintf(
                'imgfetch ${boot-url}/service/ipxe/refind.conf%s'
                . 'chain -ar ${boot-url}/service/ipxe/refind_x64.efi',
                "\n"
             );
    

    Copy it and paste it just below as shown here

             $refind = sprintf(
                'imgfetch ${boot-url}/service/ipxe/refind.conf%s'
                . 'chain -ar ${boot-url}/service/ipxe/refind_x64.efi',
                "\n"
             );
             $refindx2 = sprintf(
                 'imgfetch ${boot-url}/service/ipxe/refindx2.conf%s'
                 . 'chain -ar ${boot-url}/service/ipxe/refind_x64.efi',
                 "\n"
             );
    

    On the inserted code change $refind = sprintf( to $refindx2 = sprintf(

    Around or after line 165 you will see this section of code. Insert 'refind_efix2' => $refindx2, just after 'refind_efi' => $refind, as below

             self::$_exitTypes = array(
                 'sanboot' => $sanboot,
                 'grub' => $grub['basic'],
                 'grub_first_hdd' => $grub['basic'],
                 'grub_first_cdrom' => $grub['1cd'],
                 'grub_first_found_windows' => $grub['1fw'],
                 'refind_efi' => $refind,
                 'refind_efix2' => $refindx2,
                 'exit' => 'exit',
             );
    
    

    Save and exit this file.

    Now edit this file

    vi lib/fog/service.class.php
    

    Around line 207 you will see this code. Insert 'refind_efix2', after 'refind_efi', as in the code below

             $types = array(
                 'sanboot',
                 'grub',
                 'grub_first_hdd',
                 'grub_first_cdrom',
                 'grub_first_found_windows',
                 'refind_efi',
                 'refind_efix2',
                 'exit',
             );
    

    What we’ve just done is added a new exit mode to FOG.

    Now we just need to clone the original FOG refind.conf file.

    cd service/ipxe/
    
    cp refind.conf refindx2.conf 
    
    

    Now you can edit the refindx2,conf file to make it look exactly where you grub boot efi boot strap is found. You can also exclude specific boot strap files (like windows).

    Finally in the FOG UI change the EFI exit mode for a test computer in the host definition to REFIND_EFIX2

    This is a bit of an advanced subject, but if you are loading grub to dual boot windows and linux you should have the skills needed for this specific hack.

350
Online

9.6k
Users

16.0k
Topics

147.9k
Posts