Customize uEFI Shell, compile the Shell on Ubuntu and test it on QEMU. (2 of 3)

Shell is an .efi uEFI excutable which gets executed by the uEFI core. The shell is a command interpretor which gives you a console to work on.

The Shell package alone can be compiled by modifying the Conf/target.txt

ACTIVE_PLATFORM       = ShellPkg/ShellPkg.dsc

The compiled .efi file will be:


Copy this file and place it in the “/EFI/boot/” directory of a FAT formatted pen drive and name it “bootx64.efi”. Select the boot efi shell from pen drive option in uEFI boot options and this Shell will come up.

There are two ways to test this compiled Shell with QEMU.

  1. Copy the Shell.efi in any one of the virtual drives by first mounting .disk file on a directory. When the QEMU comes up with it’s internal uEFI shell, we can navigate to the  file system containing the newly placed Shell.efi and execute it from there. Its like calling bash from bash shell.
  2. Recompile OVMF.fd. If you see the OvmfPkgX64.dsc, you will see that it includes all the libraries from the Shell package. So you can modify in Shell package source and recompile OVMF and copy the output as bios.bin and run QEMU to test it.


Let us modify the current uEFI Shell to show your name on startup, disable the map command displayed in the beginning, disable the uEFI Shell version  info displayed in the beginning and also disable the search for “startup.nsh”:

Open the file “ShellPkg/Application/Shell/Shell.c” and  comment the following lines:


The above will disable the mapping and the version info. Now its time to disable the script search and display your name:


You can use the API – RunCommand() with which you can run all the shell commands with parameters, so “echo” is the command here.

Now its time to compile the code.

Open “Conf/target.txt” and change:

ACTIVE_PLATFORM       = ShellPkg/ShellPkg.dsc

and hit build. Similarly build again with:

ACTIVE_PLATFORM       = OvmfPkg/OvmfPkgX64.dsc

Again copy the OVMF.fd file as bios .bin in the “qemu” directory and run qemu:


You can copy the respective Shell.efi and test it on a PC/Laptop with uEFI.

You can add custom commands and documentation to uEFI shell.

uEFI Shell has different profiles added to it, each profile has specific set of commands active. Overall lets discuss “ShellPkg/Library” directory which contains all commands segregated in Level 1,2,3, drivers, etc.

If we take the “echo” command- it’s function is declared in “UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.h” and is defined in “UefiShellLevel3CommandsLib/Echo.c”. You can add your custom commands either in any one of the files or have separate files for each command and place your documentation and help strings in .uni files.

If you are adding new files to the build you need entry in .dec, .dsc and .inf files. Github page of Tianocore has nice documentation on the Build process:

In the next post I am going to discuss about uEFI shell scripts.

Leave A Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.