UEFI Shell: Internal vs External Commands

The Unified Extensible Firmware Interface (UEFI) Shell provides an interactive pre-boot console for system diagnostics, hardware configuration, and firmware updates. Within this environment, commands are divided into two distinct categories: internal commands and external utility commands. While both types serve to manage the system and its environment, they differ fundamentally in where they reside, how they are executed, their reliance on storage media, and how easily they can be updated or customized.

Definition and Storage Location

  • Internal Commands: These are compiled directly into the UEFI Shell executable (Shell.efi). Because they are embedded within the shell’s binary image, they reside in memory alongside the shell interpreter itself.
  • External Utility Commands: These are standalone executable files with an .efi extension located on an accessible file system, such as an EFI System Partition (ESP), a USB drive, or a network share. They exist independently of the shell binary.

Execution Mechanism

  • Internal Commands: When you execute an internal command, the UEFI Shell processes it within its existing execution context. The shell does not invoke system image loaders; it simply parses the command arguments and jumps to the corresponding internal function. This results in near-instantaneous execution with minimal system overhead.
  • External Utility Commands: When an external command is invoked, the shell searches its current working directory and the directories defined in its PATH environment variable. Once located, the shell uses the UEFI Boot Service LoadImage() to load the executable into memory, followed by StartImage() to run it. Once the program terminates, control returns to the shell.

Availability and File System Dependency

  • Internal Commands: Because they are native to the shell, internal commands are universally available whenever the shell runs, even if no storage drives, file systems, or mappings (such as FS0:) are detected. Core operations—including managing aliases, viewing memory maps, altering shell environment variables, and navigating devices—can be performed under any circumstances.
  • External Utility Commands: These commands require an accessible and supported file system. If a system boots into a minimal UEFI Shell without access to the media hosting these .efi binaries, external commands cannot run.

Extensibility and Updates

  • Internal Commands: Modifying, fixing, or adding internal commands requires re-compiling the entire UEFI Shell source code (typically from the EDK II project) and flashing the updated firmware or replacing the main Shell.efi binary.
  • External Utility Commands: These provide modularity. Administrators and developers can write, test, and deploy standalone tools—such as hardware flashers, custom diagnostics, or boot configuration editors—simply by copying the .efi file to a drive without modifying the underlying shell.

Common Examples

  • Internal Command Examples: cd (change directory), ls or dir (list directory), set (manage environment variables), alias (create command shortcuts), exit (quit the shell), and help (display command syntax).
  • External Command Examples: bcfg.efi (manage boot configurations), dmpstore.efi (manage UEFI variables), edit.efi (full-screen text editor), and vendor-specific firmware flashing utilities.