EFI EXIT type chainloading failed
-
Re: IPXE exit not lauching BIOS UEFI next boot option
I have similar problems as the one above.
Is there a way to reconfigure settings for the EXIT method to boot Linux instead of Windows?
I want to boot grub as default, from there have grub configured to start Win10 (Windows Boot manager) as default (as Win10 doesn’t allow booting Linux from its Manager).
My UEFI boot order is:- UEFI IPv4 PXE
- Debian grubx64.efi
- Windows Boot Manager
If I choose:
- REFIND-EFI Exit Type, the PC boots into Win10 automatically
- EXIT Exit Type, the PXE boot says “Chainloading failed”
-
@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 belowself::$_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.
-
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.
-
@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.
- 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).
- 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.
-
@george1421 Great, thank you
-
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
-
@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.
- Your computer is a uefi based one since you are using refind.
- 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 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?
-
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"' )
-
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.
-
@chris_unit what you posted looks right, but also remember that its been several months since I tweaked the code. If I remember right there was another spot in the code that needs to be updated to use the variable you just created.
-
@george1421 i’ve attached the two files if that helps (added txt to the end of the file name to allow upload)
-
@chris_unit are you seeing a specific issue? If you have a coding issue the webui will become unresponsive. If the web ui is working without issue then you need to look into the config files to get them to do what you want.
note: I’m traveling for work at the moment so I’m going to be on and off for the next week.
-
@george1421 hi there
yes the issue is the photo i sent.
I’ve followed your below steps and with refind.conf being identical, refind_efix2 doesn’t work so it must be a syntax error as all we’ve done is create an identical button?
-
@george1421 i’m getting the following error when i try to use REFIND_EFIX2
-
@chris_unit I’m confused because the pictures you’ve posted mentioned memdisk. memdisk should not even be in the picture at the moment. memdisk is not compatible with uefi.
So lets try to debug this a bit more to see if its doing what we need. I want you to change in the FOG Configuration -> FOG Settings Expand all button. Now search for “uefi” you are looking for uefi exit mode or something like that. The default should be refind. Change that to the refind2 exit mode. Save the settings. Edit: also change the exit mode for bios to refind2 (that will give us the right results either way below)
Now I want you to go to this URL with a browser from a windows computer.
http://<fog_server_ip>/fog/service/ipxe/boot.php?mac=00:00:00:00:00:00
That will give you the text behind the iPXE boot menu. Copy that text and post it here. We might have to add an additional parameter to tell it the client is uefi. I don’t have access to a fog server to test at the moment. Lets see if FOG is giving us what we need in the ipxe menu. -
@george1421 said in EFI EXIT type chainloading failed:
http://<fog_server_ip>/fog/service/ipxe/boot.php?mac=00:00:00:00:00:00
Ok i’ve momentarily changed it to REFIND_EFIX2 and here’s the output of the menu
looks like it’s still set it to
sanboot --no-describe --drive 0x80 || goto MENU#!ipxe set fog-ip 192.168.80.3 set fog-webroot fog set boot-url http://${fog-ip}/${fog-webroot} cpuid --ext 29 && set arch x86_64 || set arch i386 goto get_console :console_set colour --rgb 0x00567a 1 || colour --rgb 0x00567a 2 || colour --rgb 0x00567a 4 || cpair --foreground 7 --background 2 2 || goto MENU :alt_console cpair --background 0 1 || cpair --background 1 2 || goto MENU :get_console console --picture http://192.168.80.3/fog/service/ipxe/bg.png --left 100 --right 80 && goto console_set || goto alt_console :MENU menu colour --rgb 0xff0000 0 || cpair --foreground 1 1 || cpair --foreground 0 3 || cpair --foreground 4 4 || item --gap Host is NOT registered! item --gap -- ------------------------------------- item fog.local Boot from hard disk item fog.memtest Run Memtest86+ item fog.reginput Perform Full Host Registration and Inventory item fog.reg Quick Registration and Inventory item fog.deployimage Deploy Image item fog.multijoin Join Multicast Session item fog.sysinfo Client System Information (Compatibility) item os.Ubuntu.Desktop.20.04 Ubuntu Desktop 20.04 item os.Flame2020.CentOS7.6 Flame2020 CentOS7.6 item os.GParted Gparted item os.Clonezilla Clonezilla item os.Ubuntu.Desktop.18.04 Ubuntu Desktop 18.04 item os.Flame2021.CentOS7.7 Testing CentOS 7.7 with Flame choose --default fog.local --timeout 3000 target && goto ${target} :fog.local sanboot --no-describe --drive 0x80 || goto MENU :fog.memtest kernel memdisk initrd=memtest.bin iso raw initrd memtest.bin boot || goto MENU :fog.reginput kernel bzImage32 loglevel=4 initrd=init_32.xz root=/dev/ram0 rw ramdisk_size=275000 web=http://192.168.80.3/fog/ consoleblank=0 rootfstype=ext4 storage=192.168.80.3:/images/ storageip=192.168.80.3 nvme_core.default_ps_max_latency_us=0 loglevel=4 mode=manreg imgfetch init_32.xz boot || goto MENU :fog.reg kernel bzImage32 loglevel=4 initrd=init_32.xz root=/dev/ram0 rw ramdisk_size=275000 web=http://192.168.80.3/fog/ consoleblank=0 rootfstype=ext4 storage=192.168.80.3:/images/ storageip=192.168.80.3 nvme_core.default_ps_max_latency_us=0 loglevel=4 mode=autoreg imgfetch init_32.xz boot || goto MENU :fog.deployimage login params param mac0 ${net0/mac} param arch ${arch} param username ${username} param password ${password} param qihost 1 isset ${net1/mac} && param mac1 ${net1/mac} || goto bootme isset ${net2/mac} && param mac2 ${net2/mac} || goto bootme param sysuuid ${uuid} :fog.multijoin login params param mac0 ${net0/mac} param arch ${arch} param username ${username} param password ${password} param sessionJoin 1 isset ${net1/mac} && param mac1 ${net1/mac} || goto bootme isset ${net2/mac} && param mac2 ${net2/mac} || goto bootme param sysuuid ${uuid} :fog.sysinfo kernel bzImage32 loglevel=4 initrd=init_32.xz root=/dev/ram0 rw ramdisk_size=275000 web=http://192.168.80.3/fog/ consoleblank=0 rootfstype=ext4 storage=192.168.80.3:/images/ storageip=192.168.80.3 nvme_core.default_ps_max_latency_us=0 loglevel=4 mode=sysinfo imgfetch init_32.xz boot || goto MENU :os.Ubuntu.Desktop.20.04 kernel tftp://${fog-ip}/os/ubuntu/Desk20.04/vmlinuz initrd tftp://${fog-ip}/os/ubuntu/Desk20.04/initrd imgargs vmlinuz initrd=initrd root=/dev/ram0 ramdisk_size=1800000 ip=dhcp url=http://${fog-ip}/ubuntu-20.04.2.0-desktop-amd64.iso ro boot || goto MENU param sysuuid ${uuid} :os.Flame2020.CentOS7.6 kernel tftp://${fog-ip}/os/autodesk/flame2020_CentOS7.6/vmlinuz initrd tftp://${fog-ip}/os/autodesk/flame2020_CentOS7.6/initrd.img imgargs vmlinuz initrd=/os/autodesk/flame2020_CentOS7.6/initrd.img inst.repo=nfs://pixit-v60-10g.ldn.unit.tv/mmfs1/data/anubis/.install/isos/flame2020_centos7.6 ks=nfs://pixit-v60-10g.ldn.unit.tv/mmfs1/data/anubis/.install/isos/flame2020_centos7.6/ks_820.cfg boot || goto MENU param sysuuid ${uuid} :os.GParted kernel tftp://${fog-ip}/os/gparted/vmlinuz initrd tftp://${fog-ip}/os/gparted/initrd.img imgargs vmlinuz initrd=initrd.img boot=live config components union=overlay username=user noswap noeject vga=788 fetch=http://${fog-ip}/gparted/filesystem.squashfs boot || goto MENU param sysuuid ${uuid} :os.Clonezilla kernel tftp://${fog-ip}/os/clonezilla/vmlinuz initrd tftp://${fog-ip}/os/clonezilla/initrd.img imgargs vmlinuz initrd=initrd.img boot=live username=user union=overlay config components quiet noswap edd=on nomodeset nodmraid keyboard-layouts=en locales=en_US.UTF-8 ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch=no net.ifnames=0 nosplash noprompt fetch=tftp://${fog-ip}/os/clonezilla/filesystem.squashfs ocs_repository="nfs4://pixit-v60-10g.ldn.unit.tv:/mmfs1/data/anubis/.install/.clonezilla/images/" ocs_live_run="ocs-live -s" boot || goto MENU param sysuuid ${uuid} :os.Ubuntu.Desktop.18.04 kernel tftp://${fog-ip}/os/ubuntu/Desk18.04/vmlinuz initrd tftp://${fog-ip}/os/ubuntu/Desk18.04/initrd imgargs vmlinuz initrd=initrd root=/dev/nfs boot=casper netboot=nfs nfsroot=${fog-ip}:/images/os/ubuntu/Desk18.04/ locale=en_US.UTF-8 keyboard-configuration/layoutcode=us mirror/country=US boot || goto MENU param sysuuid ${uuid} :os.Flame2021.CentOS7.7 kernel tftp://${fog-ip}/os/autodesk/flame2020_CentOS7.7/vmlinuz initrd tftp://${fog-ip}/os/autodesk/flame2020_CentOS7.7/initrd.img imgargs vmlinuz initrd=/os/autodesk/centos7.7/initrd.img inst.repo=nfs://pixit-v60-10g.ldn.unit.tv/mmfs1/data/anubis/.install/isos/flame2020_centos7.7 ks=nfs://pixit-v60-10g.ldn.unit.tv/mmfs1/data/anubis/.install/isos/flame2020_centos7.7/ks_820.cfg boot || goto MENU param sysuuid ${uuid} :bootme chain -ar http://192.168.80.3/fog/service/ipxe/boot.php##params || goto MENU autoboot
-
@chris_unit did you change both the uefi and bios global settings to refind2. That is what my edit in the previous post talked about. We need to pass an additional parameter with the mac address to get boot.php to send out the uefi exit mode. By setting both bios and uefi to refind (temporarily) it should send out the refind2 exit code. If it does then you have things programmed correctly.
-
@george1421 Hey there
Here’s the output from a windows client
#!ipxe set fog-ip 192.168.80.3 set fog-webroot fog set boot-url http://${fog-ip}/${fog-webroot} cpuid --ext 29 && set arch x86_64 || set arch i386 goto get_console :console_set colour --rgb 0x00567a 1 || colour --rgb 0x00567a 2 || colour --rgb 0x00567a 4 || cpair --foreground 7 --background 2 2 || goto MENU :alt_console cpair --background 0 1 || cpair --background 1 2 || goto MENU :get_console console --picture http://192.168.80.3/fog/service/ipxe/bg.png --left 100 --right 80 && goto console_set || goto alt_console :MENU menu colour --rgb 0xff0000 0 || cpair --foreground 1 1 || cpair --foreground 0 3 || cpair --foreground 4 4 || item --gap Host is NOT registered! item --gap -- ------------------------------------- item fog.local Boot from hard disk item fog.memtest Run Memtest86+ item fog.reginput Perform Full Host Registration and Inventory item fog.reg Quick Registration and Inventory item fog.deployimage Deploy Image item fog.multijoin Join Multicast Session item fog.sysinfo Client System Information (Compatibility) item os.Ubuntu.Desktop.20.04 Ubuntu Desktop 20.04 item os.Flame2020.CentOS7.6 Flame2020 CentOS7.6 item os.GParted Gparted item os.Clonezilla Clonezilla item os.Ubuntu.Desktop.18.04 Ubuntu Desktop 18.04 item os.Flame2021.CentOS7.7 Testing CentOS 7.7 with Flame choose --default fog.local --timeout 3000 target && goto ${target} :fog.local || goto MENU :fog.memtest kernel memdisk initrd=memtest.bin iso raw initrd memtest.bin boot || goto MENU :fog.reginput kernel bzImage32 loglevel=4 initrd=init_32.xz root=/dev/ram0 rw ramdisk_size=275000 web=http://192.168.80.3/fog/ consoleblank=0 rootfstype=ext4 storage=192.168.80.3:/images/ storageip=192.168.80.3 nvme_core.default_ps_max_latency_us=0 loglevel=4 mode=manreg imgfetch init_32.xz boot || goto MENU :fog.reg kernel bzImage32 loglevel=4 initrd=init_32.xz root=/dev/ram0 rw ramdisk_size=275000 web=http://192.168.80.3/fog/ consoleblank=0 rootfstype=ext4 storage=192.168.80.3:/images/ storageip=192.168.80.3 nvme_core.default_ps_max_latency_us=0 loglevel=4 mode=autoreg imgfetch init_32.xz boot || goto MENU :fog.deployimage login params param mac0 ${net0/mac} param arch ${arch} param username ${username} param password ${password} param qihost 1 isset ${net1/mac} && param mac1 ${net1/mac} || goto bootme isset ${net2/mac} && param mac2 ${net2/mac} || goto bootme param sysuuid ${uuid} :fog.multijoin login params param mac0 ${net0/mac} param arch ${arch} param username ${username} param password ${password} param sessionJoin 1 isset ${net1/mac} && param mac1 ${net1/mac} || goto bootme isset ${net2/mac} && param mac2 ${net2/mac} || goto bootme param sysuuid ${uuid} :fog.sysinfo kernel bzImage32 loglevel=4 initrd=init_32.xz root=/dev/ram0 rw ramdisk_size=275000 web=http://192.168.80.3/fog/ consoleblank=0 rootfstype=ext4 storage=192.168.80.3:/images/ storageip=192.168.80.3 nvme_core.default_ps_max_latency_us=0 loglevel=4 mode=sysinfo imgfetch init_32.xz boot || goto MENU :os.Ubuntu.Desktop.20.04 kernel tftp://${fog-ip}/os/ubuntu/Desk20.04/vmlinuz initrd tftp://${fog-ip}/os/ubuntu/Desk20.04/initrd imgargs vmlinuz initrd=initrd root=/dev/ram0 ramdisk_size=1800000 ip=dhcp url=http://${fog-ip}/ubuntu-20.04.2.0-desktop-amd64.iso ro boot || goto MENU param sysuuid ${uuid} :os.Flame2020.CentOS7.6 kernel tftp://${fog-ip}/os/autodesk/flame2020_CentOS7.6/vmlinuz initrd tftp://${fog-ip}/os/autodesk/flame2020_CentOS7.6/initrd.img imgargs vmlinuz initrd=/os/autodesk/flame2020_CentOS7.6/initrd.img inst.repo=nfs://pixit-v60-10g.ldn.unit.tv/mmfs1/data/anubis/.install/isos/flame2020_centos7.6 ks=nfs://pixit-v60-10g.ldn.unit.tv/mmfs1/data/anubis/.install/isos/flame2020_centos7.6/ks_820.cfg boot || goto MENU param sysuuid ${uuid} :os.GParted kernel tftp://${fog-ip}/os/gparted/vmlinuz initrd tftp://${fog-ip}/os/gparted/initrd.img imgargs vmlinuz initrd=initrd.img boot=live config components union=overlay username=user noswap noeject vga=788 fetch=http://${fog-ip}/gparted/filesystem.squashfs boot || goto MENU param sysuuid ${uuid} :os.Clonezilla kernel tftp://${fog-ip}/os/clonezilla/vmlinuz initrd tftp://${fog-ip}/os/clonezilla/initrd.img imgargs vmlinuz initrd=initrd.img boot=live username=user union=overlay config components quiet noswap edd=on nomodeset nodmraid keyboard-layouts=en locales=en_US.UTF-8 ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch=no net.ifnames=0 nosplash noprompt fetch=tftp://${fog-ip}/os/clonezilla/filesystem.squashfs ocs_repository="nfs4://pixit-v60-10g.ldn.unit.tv:/mmfs1/data/anubis/.install/.clonezilla/images/" ocs_live_run="ocs-live -s" boot || goto MENU param sysuuid ${uuid} :os.Ubuntu.Desktop.18.04 kernel tftp://${fog-ip}/os/ubuntu/Desk18.04/vmlinuz initrd tftp://${fog-ip}/os/ubuntu/Desk18.04/initrd imgargs vmlinuz initrd=initrd root=/dev/nfs boot=casper netboot=nfs nfsroot=${fog-ip}:/images/os/ubuntu/Desk18.04/ locale=en_US.UTF-8 keyboard-configuration/layoutcode=us mirror/country=US boot || goto MENU param sysuuid ${uuid} :os.Flame2021.CentOS7.7 kernel tftp://${fog-ip}/os/autodesk/flame2020_CentOS7.7/vmlinuz initrd tftp://${fog-ip}/os/autodesk/flame2020_CentOS7.7/initrd.img imgargs vmlinuz initrd=/os/autodesk/centos7.7/initrd.img inst.repo=nfs://pixit-v60-10g.ldn.unit.tv/mmfs1/data/anubis/.install/isos/flame2020_centos7.7 ks=nfs://pixit-v60-10g.ldn.unit.tv/mmfs1/data/anubis/.install/isos/flame2020_centos7.7/ks_820.cfg boot || goto MENU param sysuuid ${uuid} :bootme chain -ar http://192.168.80.3/fog/service/ipxe/boot.php##params || goto MENU autoboot
-
@chris_unit ok looking at the menu something is missing in the code. Looking at the ipxe menu I also see how memdisk is getting in the mix here. I’m still traveling so I don’t have access to my home test lab. I’ll have to look over the code you provided to see what bit is missing.