UEFI Shell

From Omnia
Jump to navigation Jump to search

UEFI Shell

startup.nsh

Startup script

"Press ESX in 5 seconds to skip startup.nsh, any other key to continue.

Can be located on any UEFI partition, and even have multiples.

Shell Commands

VMware ESXi 5.0 UEFI Shell Commands

?             - Displays the EFI Shell command list or verbose command help
alias         - Displays, creates, or deletes EFI Shell aliases
attrib        - Displays or changes the attributes of files or directories
cd            - Displays or changes the current directory
cls           - Clears standard output and optionally changes background color
comp          - Compares the contents of two files
connect       - Connects one or more EFI drivers to a device
cp            - Copies one or more files or directories to another location
date          - Displays or changes the current system date
dblk          - Displays one or more blocks from a block device
devices       - Displays the list of devices managed by EFI drivers
devtree       - Displays the EFI Driver Model compliant device tree
dh            - Displays EFI handle information
disconnect    - Disconnects one or more EFI drivers from a device
dmem          - Displays the contents of memory
dmpstore      - Displays all EFI NVRAM variables
drivers       - Displays the EFI driver list
drvcfg        - Invokes the Driver Configuration Protocol
drvdiag       - Invokes the Driver Diagnostics Protocol
echo          - Controls batch file command echoing or displays a message
edit          - Full screen editor for ASCII or UNICODE files
eficompress   - Compress a file
efidecompress - Decompress a file
err           - Displays or changes the error level
exit          - Exits the EFI Shell environment
for           - Executes commands for each item in a set of items
goto          - Forces batch file execution to jump to specified location
guid          - Displays all registered EFI GUIDs
help          - Displays the EFI Shell command list or verbose command help
hexedit       - Full screen hex editor
if            - Executes commands in specified conditions
ifconfig      - Modifies the default IP address of UEFI network stack.
load          - Loads and optionally connects one or more EFI drivers
loadpcirom    - Loads a PCI Option ROM
ls            - Displays a list of files and subdirectories in a directory
map           - Displays or defines mappings
mem           - Displays the contents of memory
memmap        - Displays the memory map
mkdir         - Creates one or more directories
mm            - Displays or modifies MEM/MMIO/IO/PCI/PCIE address space
mode          - Displays or changes the console output device mode
mount         - Mounts a file system on a block device
mv            - Moves one or more files or directories to another location
openinfo      - Displays the protocols and agents associated with a handle
pause         - Prints a message and waits for keyboard input
pci           - Displays PCI device list or PCI function configuration space
ping          - Ping a target machine with UEFI network stack
reconnect     - Reconnects one or more EFI drivers to a device
reset         - Resets the system
rm            - Deletes one or more files or directories
sermode       - Sets serial port attributes
set           - Displays or modifies EFI Shell environment variables
shift         - Shifts batch file input parameter positions
smbiosview    - Displays SMBIOS information
stall         - Stalls the processor for the specified number of microseconds
telnetmgmt    - Change terminal type
time          - Displays or changes the current system time
timezone      - Displays or sets time zone information
touch         - Updates filename timestamp with current system date and time
type          - Displays file contents
unload        - Unloads a EFI driver
ver           - Displays EFI Firmware version information
vol           - Displays or changes a file system volume label

Shell Programming

MS DOS Batch Hell!

See DOS Batch Programming

Can use 'type' and 'edit' to see and edit scripts.

set myvar 1
set myvar "hello world"
echo %myvar%

Booting UEFI Shell

"Now you need to copy binary of EFI shell to that partition. You can find 64-bit binary of EFI shell in EFI Development Kit: {EDK}\Other\Maintained\Application\UefiShell\bin\x64\Shell_full.efi. Copy it to your FAT32 partition as \EFI\BOOT\BOOTX64.EFI." [1]

Executing UEFI Applications

  • Enter the application name at the command prompt
  • The EFI shell uses “path” environment variable
  • The EFI shell automatically adds “.efi”
  • If suffix is .nsh, it will execute shell commands inside of the .nsh file similar to .bat in DOS
path = fs0:>efitools;fs0:;.
test.efi
test

References:

Output Redirection

Redirect standard output to a Unicode file:

memmap 1> Foo.txt

Redirect standard output to an ASCII file:

memmap 1>a Foo.txt

Append a file using redirection of standard output

memmap 1>>a Foo.txt

Redirect standard error to a Unicode file

memmap 2> Foo.txt

Redirect standard error to an ASCII file

memmap 2>a Foo.txt

EFI Shell Commands

Shell Command Manual (pdf) - ftp://ftp.heanet.ie/mirrors/sourceforge/e/ef/efi-shell/documents/ShellCommandManual.pdf

              dmem         drivers
dh            dmpstore     devtree
help ?        err          devices
map           guid         connect
mount     
pci           disconnect
load          mm           openinfo
unload        reset        reconnect
loadbmp       stall        drvcfg
nshell        getmtc       drvdiag
ver           hexedit      loadpcirom
memmap        Setsize
bcfg          Set
Dblk
alias

References:

Internal EFI Shell Commands

Commands that are built into the shell environment and are not .efi applications that are loaded

Examples

help
dh
map
guid
alias
set
exit
Cd
type

References:

EFI Shell Commands

EFI Shell Commands

DOS like:

attrib
date
edit 
time
break
cls
mode
vol

Batch Commands:

(*.nsh files)
echo
exit
for
goto
if
Pause
Equivalent to *.bat files
Note: startup.nsh = autoexec.bat

Unix-like Shell Commands:

ls 
rm 
cp 
mv
mkdir 
type
alias
set
touch

References:

USB Boot Shell

diskpart
list disk
REM  # DO NOT SELECT DISK 0:
select disk 1
clean
convert gpt
create partition primary
list part
select partition 1
format fs=fat32 label="EFI_1" quick
REM # note: not required, but you can specify drive letter: "assign letter=s"
assign
exit

References:

Download UEFI Shell

Download Tianacore EFI Shell files (source) - http://sourceforge.net/projects/efi-shell/files/Releases/Official%20Releases/

  • EfiShell 1.06.zip (src)

SourceForge.net: ShellPkg - tianocore - http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=ShellPkg

Precompiled x86_64 UEFI Shell v2 binary (may not be up-to-date) - https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#Obtaining_UEFI_Shell]

Precompiled BIN - https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface [3]

Save as:

\EFI\BOOT\BOOTX64.EFI
\EFI\BOOT\Shellx64.efi  (on some servers)

Manually Boot a Windows Boot Partition

cd fs0:
cd boot
bootx64.efi

Add Boot Option in BIOS

Add Boot Option - give name

Path for boot option

  • should auto detect file system, select
  • File to Boot: \EFI\Boot\bootx64.efi

Old Itanium Shell

(from AppLabs project)

boot into EFI shell
uses standard EFI commands
F8
drivers
drvcfg 66
drvcfg -s 66 75
  select - 1 - set enabled, then all defaults
save
exit
map -r   #s ??
reset
# uses standard EFI commands
# use [shift]-[h] for backspace
drivers    # shows all available drivers
           # 65 should be "Intel(R) PRO/1000 3.3.08 EFI-32    e3308"
           # 66 should be "Hitachi Fibre channel Driver    ScsiBusFive"
drvcfg 66  # show you the driver handle and controller
           #

drvcfg -s 66 75 [enter]  # use drv and ctrl from previous
  select [enter]  # show and select an adapter to setup
  1 [enter]       # select the adapater
  set [enter]     # setup basic options
    y, 1 [enter]  # enable boot function
    [enter_rep.]  # then all defaults for the rest
  save [enter]    # save options
    y             # save
  exit [enter]    # exit drvcfg
                  # result: Drv[66]  Ctrl[75]  Lang[eng] - Options set.  Action Required is None
reconnect -r [enter]  # reconnect devices
                  # result: ReconnectController(0,0,0) : Status = Success
map -r            # show mapped devices
                  # result: Device mapping table...
#reset            # reboot HVM
exit              # exit back to boot menu

keywords

UEFI EFI