Menu

How to reinitialize into UEFI via commandline?

2022-08-01
2022-09-01
  • BEEDELLROKEJULIANLOCKHART

    For "https://github.com/OpenRC/openrc/issues/539", I am attempting to ascertain whether a command exists that allows macOS to reinitialize into its UEFI. Is anybody able to assist me?

     
  • joevt

    joevt - 2022-08-02

    Macs don't have a UEFI BIOS user interface.
    You can use the bless command to change the default or next UEFI booter app. The booter app might be boot.efi for macOS, or it might be rEFInd or RefindPlus or OpenCore or grub which let you choose any booters that they find or know about.

    Before the UEFI booter app loads, you can hold the option key to get into the Startup Manager which just lets you choose what to boot next (and optionally change the default boot) similar to rEFInd or RefindPlus or OpenCore.

    I suppose it might be possible to use the bless command to force the Startup Manager to appear but the exact parameters may differ between Mac models.

     
    👍
    1
  • BEEDELLROKEJULIANLOCKHART

    Yeah, @joevt, then the Startup Manager is what I'm searing for. I just want an equivalent to the linked posts' content, not merely demonstrate what I want to via that post, but to also automate changing the UEFI interface. Thanks a lot.

    I have asked Apple more directly at "https://developer.apple.com/forums/thread/711532".

     

    Last edit: BEEDELLROKEJULIANLOCKHART 2022-08-02
  • BEEDELLROKEJULIANLOCKHART

    Yeah. I realize that what I'm describing sounds like malwarey, but might it be possible to imitate pressing that key at the subsequent boot by somehow instructing the computer to press that key when the mac next boots at the correct time?

     
  • joevt

    joevt - 2022-08-12

    I don't think emulating keys is a thing for EFI boot. All you can do is modify nvram variables (the BootOrder and Boot#### and BootNext EFI nvram varibales)

    For the EFI path to use in the Boot#### nvram variable: you have to figure out what firmware volume the Startup Manager is in (probably the same one used by the bless command for setting legacy BIOS Boot Camp boot - but I don't know if that code applies for newer Macs that don't support legacy BIOS Boot Camp boot - the newer Macs don't have a legacy BIOS Boot Camp EFI app but they should have a Startup Manager EFI app - but I don't know if the Startup Manager EFI app can be set as the default or next boot option on all Macs)

    rEFInd has code to get the legacy BIOS Boot Camp EFI path. It has a list of hard coded paths, but it will also try appending the Boot Camp file UUID to any firmware volume path that is used by a loaded image.

     
    👍
    1
  • BEEDELLROKEJULIANLOCKHART

    I was naive; obviously, tbe EFI supports automatic invocation of defined commands. I know not whether any computers except hackintoshes possess a startup.nsh for their EFI, but if I include reset –c -fwui in it, I should at least be able to boot into the EFI if a custom interface is installed, as "http://superuser.com/a/1595281/904401" demonstrates.

     

    Last edit: BEEDELLROKEJULIANLOCKHART 2022-09-01
    • joevt

      joevt - 2022-09-01

      Any EFI computer can have a EFI Shell installed. It is the EFI Shell that executes the commands in a startup.nsh script. Some PCs have EFI Shell built into their firmware. I've never tried reset –c -fwui on a Mac before. It probably doesn't do anything. I've already provided links to information on how to boot directly to Startup Manager. Just save to nvram Boot variables the EFI path of the Startup Manager app. Of course, the Startup Manager app only exists in EFI firmware of Macs.

       
      • BEEDELLROKEJULIANLOCKHART

        Yeah, I'll try to launch startup manager with what you state, and create some code to install a custom shell if none is available in order to one-click recreate a decent firmware environment.

         
  • dakanji

    dakanji - 2022-09-01

    You can use a startup.nsh file in Mac OS but as @joevt stated earlier ...

    Macs don't have a UEFI BIOS user interface

    You cannot boot into something that is not there to start with.

    EDIT:
    I missed the bit about custom interface.

    Not sure how you will pull off a custom interface to Mac firmware but if you do, I am sure a lot of people will be quite interested as I believe you will be first person to do so

     
    ❤️
    1

    Last edit: dakanji 2022-09-01
  • BEEDELLROKEJULIANLOCKHART

    Yeah, but I am primarily concerned with macOS rather than Macs. Apologies for the confusion. I suspect that macs shall necessitate some more low-level configuration. Considering that they ultimately contain an EFI, I should be able to install something similar to reFind and programmatically invoke it as https://developer.apple.com/forums/thread/711532?answerId=725918022 describes.

     
  • dakanji

    dakanji - 2022-09-01

    I am primarily concerned with macOS rather than Macs

    Mac firmware is only available on Macs. How do you intend to access Mac firmware on non-Macs which have their own totally different firmware?

    I presume you are aware that installing Mac OS (software) on another unit does not change the firmware on that unit to Mac firmware.

     

    Last edit: dakanji 2022-09-01
    • BEEDELLROKEJULIANLOCKHART

      Yes, what you have proposed is what I shall initially evaluate. When that is successful, I shall ascertain how much of a real mac I am able to programmatically modify, to either access any included EFI interface, or install one and subsequently access that, if none are available.

      I expect this to be feasible because ultimately macOS is BSD, which I am able to install utilities that provide this functionality into.

      And yes, I realize that installation of a new operating-system does not replace the firmware unless something has occurred horribly incorrectly.

       

      Last edit: BEEDELLROKEJULIANLOCKHART 2022-09-01

Log in to post a comment.