How to invoke a UEFI Shell (v2.2) on a Fusion Player virtual machine with Big Sur installed

big surcommand lineefivirtualizationvmware

I am using the current free version of VMware Fusion Player (Version 12.1.0). I have created a Big Sur virtual machine to do some testing, which involves modifying NVRAM variables. This version of VMware Fusion Player has a built-in EFI Shell (v1.0), which does not include the setvar command. This command would be useful for my testing. Currently, an UEFI Shell (v2.2) is available as a standalone download or as part of a package. This shell does contain the setvar command.

For example, archlinux-2021.03.01-x86_64.iso file can be downloaded from Arch Linux to the host Mac. If this ISO file is placed in the virtual optical drive of the client virtual machine, then the UEFI Shell (v2.2) file named shellx64.efi can be copied from the virtual optical drive.

I have been coping the shell file to the EFI volume created during the Big Sur install. I intended to involve the shell by using the built-in VMware Fusion Player Boot Manager by either adding a boot option or directly booting from the shell file. The problem is, when the shell is involved, no output is displayed. I know the shell is executing, because I can enter the exit command to terminate the shell. Also, I can have the shell execute a script where the output is redirect to a file. By viewing the contents of the file, I can verify the shell had executed.

Originally, I thought the problem was with the shell file. However, if I create a Linux virtual machine, then output is displayed when VMware Fusion Player Boot Manager invokes the shell by either adding a boot option or directly booting from the shell file. So I feel the problem lies in how VMware Fusion Player handles virtual machines built from the Install macOS Big Sur application.

My primary question is how to get the output to be displayed? I would also accept alternate methods to invoke the shell with output being displayed. Also, I desire for the invocation have zero delay and not execute the map –terse command.

Note: VMware Fusion Player currently reports the UEFI version as 2.31.

Host Stats Guest Stats
iMac (21.5-inch, Late 2013) Mac
macOS Catalina version 10.15.7 macOS Big Sur version 11.2
Memory: 16 GB Memory: 4 GB
Quad-Core Intel Core i5 2 processor cores
2.9 GHz 2.76 GHz
USB 3 (5 Gb/s) Samsung T7 SSD SATA HDD

Best Answer

I tested the following UEFI Shell v2.2 binaries. Many of these were suggested on Arch Linux wiki website "Unified Extensible Firmware Interface" under the section "Obtaining UEFI Shell". Some binaries required extra effort to extract from the downloaded file.

  • Arch Linux: The shellx64.efi file in the root directory of the mounted archlinux-2021.03.01-x86_64.iso file. See here for a list of websites where the ISO file can be downloaded.

  • TianoCore EDK2 package: The Shell.efi file.

  • EDK2 package from Arch Linux: The Shell_Full.efi and Shell.efi files in the usr/share/edk2-shell folder of the expanded edk2-shell-202011-1-any.pkg.tar.zst file, which can be downloaded from this website.

  • rEFInd CD-R image: The shellx64.efi file in the EFI/tools folder of the mounted refind-cd-0.12.0.iso file. This ISO can be created by expanding the refind-cd-0.12.0.zip file, which can be downloaded from this website.

  • OpenCore package: The OpenShell.efi file in the X64/EFI/OC/Tools folder of the expanded OpenCore-0.6.7-RELEASE.zip file, which can be downloaded from this website.

All of the above shell binaries, except for OpenCore, either had an faulty edit command or failed to display output when boot directly from the client firmware Boot Manager.

The shell binary from the OpenCore 0.6.7 release was chosen for use in this answer.

The steps to install the new UEFI shell are given below.

  1. Download an OpenCore package: Open the webpage containing this answer on the client. From this GitHub website, download the current release of the OpenCore package. Currently this is OpenCore-0.6.7-RELEASE.zip, which by default will become the OpenCore-0 folder in your Downloads folder on the client.

  2. Mount the EFI volume: On the client, open a Terminal application window and enter the command given below.

    sudo diskutil mount disk0s1
    
  3. Put the shell in the EFI volume: On the client, copy the ~/Downloads/OpenCore-0/X64/EFI/OC/Tools/OpenShell.efi file to the root folder on the EFI volume. Rename this file to shellx64.efi.

  4. Put the startup script in the EFI volume: This step is optional, however the script does create useful aliases and environment variables. Also, the display mode is set so the shell uses the entire console window.

    Open this webpage on the client, then save the script given below as an ASCII text file named startup.nsh in the root folder on the EFI volume.

    @echo -off
    mode 128 40
    set -v AppleEnv 7C436110-AB2A-4BBB-A880-FE41995C9F82
    if x%uefishellversion% == x then
        # Startup commands for EFI 1.0 shells
        alias -v cv "ver -s"
        alias -v ush "shellx64.efi -nomap -noversion -delay 0"
        if "x%StartupDelay%" == x then
            set StartupDelay 0
        endif
        cls
    else
        # Startup commands for UEFI 2.2 shells
        set -v ShellAlias 0053D9D6-2659-4599-A26B-EF4536E631A9
        set -v SEnv 158DEF5A-F656-419C-B027-7A3192C079D2
        alias -v csrutil "setvar csr-active-config -nv -rt -bs -guid %AppleEnv%"
        alias -v cv ver
        if "x%ShellOpt%" == x then
            setvar ShellOpt -nv -bs -guid %SEnv% =L"-nomap -noversion -delay 0" =0000
        endif
    endif
    cv
    
  5. Restart to firmware: Shutdown the client. On the host, open the Startup Disk pane of Settings for the client. Hold down the option key and select the Restart to firmware… button.

  6. Add boot option: From the client firmware menus, select Enter setup>Configure boot options>Add boot option, then select the EFI volume, as shown in the example below.

    Next, select the shellx64.efi file. For a description enter UEFI Shell. and for options data enter -nomap -delay 0. The results should appear as shown below.

    Next, select Commit changes and exit>Exit the Boot Maintenance Manager. The window should appear as shown below.

  7. Test the shell: Select UEFI Shell to boot to the UEFI shell. When finished, enter exit to return to the Boot Manager. If desired, select Shut down the system.