a1ive grub2 notes

Command list

[EXPRESSION]

Same as "test"

acpi [OPTIONS] FILE1 [FILE2…]

Load ACPI Table

Modern BIOS systems typically implement ACPI and define various tables to describe the interface between ACPI-compliant operating systems and firmware. In some cases, the tables provided by default apply only to certain operating systems, and it may be necessary to replace some of them.

In general, this command replaces the root system description pointer (RSDP) in the extended BIOS data area to point to the new table. If you use the –no-ebda option, only GRUB gets the new table, but GRUB's EFI emulation can use the new table.

  • --exclude = TABLE1, TABLE2, ..., -x do not load the list
  • --load-only = TABLE1, TABLE2, ..., -n load list
  • --v1, -1 import version 1 tables into the operating system
  • --v2, -2 Import version 2 and 3 tables into the operating system
  • --oemid = STRING, -o set OEMID of RSDP, XSDT and RSDT
  • --oemtable = STRING, -t set OEMTABLE ID for RSDP, XSDT and RSDT
  • --oemtablerev = n, -r set OEMTABLE version of RSDP, XSDT and RSDT
  • --oemtablecreator = STRING, -c Set OEMTABLE creator for RSDP, XSDT and RSDT.
  • --oemtablecreatorrev = n, -d Set the OEMTABLE creator version of RSDP, XSDT, and RSDT.
  • --no-ebda, -e Do not update EBDA. It can prevent some BIOS from crashing and has no effect on the OS that cannot receive RSDP from GRUB.
  • --slic, -s Load as SLIC, automatically modify OEMID and OEMTABLE ID.
  • --msdm display / load MSDM tables

appleloader CMDLINE

Apple legacy boot loader.

authenticate [userlist]

Check if the user is listed in the user list or in the value of the variable “superusers"

If Superuser is empty, this command returns true.

background_color COLOR

Set the background color of the active terminal

You can only change the background color when using "gfxterm". This command sets the color of the blank area without text. The text background color is controlled by the environment variables color_normal, color_highlight, menu_color_normal, menu_color_highlight.

background_image [OPTIONS] [FILE]

Set a background image for the active terminal

By default the image will be stretched to fill the entire screen (--mode = stretch)

Without parameters, the currently loaded background image will be deleted.

  • --mode = stretch / normal, -m set the background image mode to stretch or normal

backtrace

Print traceback information

badram ADDR1, MASK1 [, ADDR2, MASK2 [,…]]

Shield bad memory

This command tells the memory manager that the specified area of ​​RAM should be filtered out. As long as the loaded kernel gets its memory map from GRUB, it remains valid after the kernel is loaded. The kernels that support this feature usually include Linux, GNU Mach, FreeBSD kernel and Multiboot kernel.

The syntax is the same as that provided by Memtest86 +: a list of address / mask pairs. Given a page-aligned address and a base address / mask pair, if all bits of the page-aligned address enabled by the mask match the base address, it means that the page will be filtered.

blocklist FILE

Print the block list of the file

blscfg FILE

Import BootLoaderSpec (BLS) configuration

bls_import FILE

Same as "blscfg"

boot

Start the loaded operating system

btrfs-info DEVICE

Show device btrfs partition information

btrfs-mount-subvol DEVICE DIRECTORY SUBVOL

Set the btrfs device DIRECTORY directory as the mount point of the subvolume SUBVOL

btrfs-list-subvols [OPTIONS] DEVICE

Show all subvolumes on device DEVICE

  • --output = VARIABLE, -o save output as a variable
  • --path-only, -p only show the paths of subvolumes
  • --id-only, -i show only the ids of the subvolumes

btrfs-get-default-subvol [OPTIONS] DEVICE

Show default subvolume on device DEVICE

  • Same parameters as btrfs-list-subvols

cat [OPTIONS] FILE

Show text file content

  • --dos allow DOS format line breaks (CR-LF)
  • --set = VARIABLE, -s save the contents to a variable

chainloader [–force | –bpb] FILE [ADDR]

Start another bootloader, the default load address is 0x7c00

chainloader [OPTIONS] FILE CMDLINE

Launch EFI executable

Warning: Use this command may cause security issues

  • --alt, -a use GRUB 2's built-in EFI loader
  • --text, -t Convert to text mode before starting EFI
  • --boot, -b execute boot immediately

checktime minute hour day month day_of_week

Check whether the current time meets the requirements, if yes, returns 0, otherwise returns 1. The syntax is similar to cron under unix.

symbol significance Example
\ * Any value (note the asterisk escape) \ *
, List multiple values 10,20,30
- Range value 5-45
/ Step value 10/5

clear

Clear Screen

clear_menu

Clear the current menu

Warning: Be sure to disable before using this command ESC export grub_disable_esc = 1

cmosclean byte: bit

Clear the value of the CMOS bit: byte: bit

Only available on platforms that support CMOS.

cmosdump

Show raw CMOS data

cmostest byte: bit

Test the value of CMOS at byte: bit

If the bit is set, true (0) is returned, otherwise non-zero.

cmp FILE1 FILE2

Compare two files

If the two files have different sizes, the sizes are displayed separately. If the size is the same but the data is different, the first different position and data will be displayed. If they are identical, there is no output.

commandline

Enter the GRUB command line

configfile FILE

Load GRUB2 configuration file

crc32 FILE [VARIABLE]

Calculate the CRC32 check code of the file

cpuid [OPTIONS]

Checking CPU characteristics

Without parameters, the default parameter is -l. If the CPU supports this feature, it returns 0.

  • --long-mode, -l Check if the CPU supports 64-bit long mode
  • --pae, -p Check if the CPU supports physical address extension (PAE)

cryptomount DEVICE | -u UUID | -a | -b

Mount the encryption device (supports LUKS / geli), in some cases you need to enter the password interactively

  • --uuid, -u mount device by UUID
  • --all, -a mount all devices
  • --boot, -b mount all devices marked with "boot"

cutmem FROM [K | M | G] TO [K | M | G]

Delete all memory areas in the specified range

date [OPTIONS] [[year-] month-day] [hour: minute [: second]]

Show / set current time

  • --set = VARIABLE, -s save time to variable

decrement VARIABLE

Decrement the value of a variable by one

devicetree FILE

Load device tree blob (.dtb)

dd OPTIONS

Write file / string / hex to file

Warning: This command will cause the loss of data

  • --if = FILE, -i specify input file
  • --str ="STRING", -s specify input string
  • --hex = HEX, -h specify input hexadecimal number
  • --of = FILE, -o specify output file
  • --bs = BYTES, -b specify block size
  • --count = n, -c specify the number of blocks
  • --skip = n skip the first n blocks of input
  • --seek = n skip the first n blocks of output

--if=(proc) = 00 bytes (equivalent to /dev/zero).


distrust PUBKEY_ID

Remove PUBKEY_ID from the trust list

dp FILE / DEVICE

UEFI Device Path for output device or file

dump ADDR [SIZE]

Show memory contents

echo [OPTIONS] STRING…

Show string

If you do not add the -n option, it will automatically wrap. Backslash escaping supports the following sequences:

\\ \\ – backslash \ a – alarm (BEL) \ c – no trailing newline \ f – form feed

\ N – line feed \ r – ​​carriage return \ t – horizontal tab \ v – vertical tab

  • -n does not wrap
  • -e enable backslash escape parsing

efi-export-env VARIABLE

Save the GRUB variable to the EFI environment variable GRUB_ENV

Warning: Use this command to modify UEFI environment variables

efi-load-env

Read variables from the EFI environment variable GRUB_ENV

efiload [OPTIONS] FILE

Load UEFI driver

  • --nc, -n Load driver only, not connect

eval STRING ...

Concatenate arguments together using single space as separator and evaluate result as sequence of GRUB commands.

exit

Exit GRUB

export VARIABLE [= VALUE]

Set variables to global environment variables

expr [OPTIONS] EXPRESSION

Calculate mathematical expressions, support +-* \% operator

Warning: Division by zero results in unexpected situations such as crash or restart

  • --set = VARIABLE, -s save result to variable

fakebios

Create Legacy-BIOS-like structure for compatibility with existing systems

false

Returns false

file OPTIONS FILE

Check file type

  • --is-i386-xen-pae-domu
  • --is-x86_64-xen-domu
  • --is-x86-xen-dom0
  • --is-x86-multiboot
  • --is-x86-multiboot2
  • --is-arm-linux
  • --is-arm64-linux
  • --is-ia64-linux
  • --is-mips-linux
  • --is-mipsel-linux
  • --is-sparc64-linux
  • --is-powerpc-linux
  • --is-x86-linux
  • --is-x86-linux32
  • --is-x86-kfreebsd
  • --is-i386-kfreebsd
  • --is-x86_64-kfreebsd
  • --is-x86-knetbsd
  • --is-i386-knetbsd
  • --is-x86_64-knetbsd
  • --is-i386-efi
  • --is-x86_64-efi
  • --is-ia64-efi
  • --is-arm64-efi
  • --is-arm-efi
  • --is-riscv32-efi
  • --is-riscv64-efi
  • --is-hibernated-hiberfil
  • --is-x86_64-xnu
  • --is-i386-xnu
  • --is-xnu-hibr
  • --is-x86-bios-bootsector


fix_video

Fixed image display issues

fwsetup

Restart into UEFI firmware settings

getargs OPTIONS STRING VARIABLE

Get parameters from command line received from GRUB 2 EFI file

If the command is executed successfully (parameter / value exists), it returns 0.

  • --key, -k Get whether to set this parameter
  • --value, -v get the value of the parameter

getenv [OPTIONS] EFI_ENV VARIABLE

Get UEFI environment variables

  • --guid = GUID, -g Set the GUID of the variable to be queried. The default is a global variable.
  • --type = string / uint8 / hex, -t specifies that the variable type is string / 8 bit unsigned integer / hex data, default is hex data

getkey [-n] [VARIABLE]

Wait for the key and output the keyboard scan code

gettext STRING

Translate strings into the current language

The current language code is stored in the "lang" variable in the GRUB environment. Translation files in MO format are read from "locale_dir", usually / boot / grub / locale.

gptprio.next OPTIONS [DEVICE]

Select the next partition where the GPT disk will boot

  • --set-device = VARIABLE, -d save partition name to variable
  • --set-uuid = VARIABLE, -u save partition UUID to variable

gptrepair DEVICE

Check and repair the GPT partition table of the device

Warning: Use this command may cause data loss

gptsync DEVICE [PARTITION [+/- [TYPE]]]…

Modify the MBR compatible partition table of the GPT partition table hard disk

TYPE is the MBR partition type code. "+" Means activate the partition, "-" means deactivate the partition.

halt [–no-apm]

Shut down the computer

If you add the "--no-apm" parameter, the APM BIOS call will not be executed. Otherwise, the computer will be shut down using APM.

hashsum -h HASH [OPTIONS] [-c FILE [-p PREFIX]] [FILE1 [FILE2…]]

Calculate or check the hash value. If the hash check is successful, it returns 0.

  • --hash = HASH, -h Specify the hash value type, support 'adler32', 'crc64', 'crc32', 'crc32rfc1510', 'crc24rfc2440', 'md4', 'md5', 'ripemd160', 'sha1' , 'sha224', 'sha256', 'sha512', 'sha384', 'tiger192', 'tiger', 'tiger2', 'whirlpool'
  • --check = FILE, -c specify a hash list file (generated using md5sum under UNIX)
  • --prefix = PREFIX, -p specify file directory
  • --keep-going, -k Do not stop checking after the first error, stop checking without this
  • --uncompress, -u decompress files before verifying

hdparm [OPTIONS] DISK

Get / Set ATA Disk Parameters

  • --apm = n, -B Set advanced power management (APM), 1 = low, ..., 254 = high, 255 = off
  • --power, -C show power mode
  • --security-freeze, -F freeze ATA security settings until reset
  • --health, -H show SMART health status
  • --aam = n, -M set automatic noise management (AAM), 0 = off, 128 = quiet, ..., 254 = fast
  • --standby-timeout = n, -S Set the standby timeout, 0 = off, 1 = 5s, 2 = 10s, ..., 240 = 20m, 241 = 30m, ...
  • --standby, -y set to standby mode
  • --sleep, -Y set to sleep mode
  • --identify, -i display device identification and settings
  • --dumpid, -I display the original contents of the ATA IDENTIFY sector
  • --smart = n disable / enable SMART (0/1)
  • --quiet, -q do not display information

help [PATTERN…]

Show help information for built-in commands. Without parameters, all available commands are displayed.

hexdump [OPTIONS] FILE / DEVICE [VARIABLE]

Shows the hexadecimal data of a file or device. (mem) is a memory device.

  • --skip = n, -s skip the first n bytes
  • --length = n, -n set the number of bytes read
  • --quiet, -q do not display output

hiddenentry “TITLE" [OPTIONS] [arg…] {COMMAND;…}

Add hidden menu, only valid for gfxmenu

Same parameters as “menuentry"

inb [OPTIONS] PORT

Read 8-bit value from the port

  • -v = VARIABLE Write the read value to a variable

increment VARIABLE

Increment the value of a variable by one

ini_get [OPTIONS] FILE [SECTION:] KEY

Get data from ini file

  • --set = VARIABLE, -s save data to variables

initrd FILE ...

Load Linux initial memory disk, use after linux

initrd16 FILE…

Load Linux initial memory disk for use after linux16

initrdefi FILE

Load Linux initial memory disk for use after linuxefi

inl [OPTIONS] PORT

Read 32-bit value from the port with the same parameters as “inb"

insmod MODULE

Load GRUB2 module

inw [OPTIONS] PORT

Read 16-bit value from the port with the same parameters as “inb"

keymap FILE

Load keyboard layout

keystatus [OPTIONS]

If the Shift / Ctrl / Alt key is pressed, it returns 0

Only some platforms support the detection of the modifier key state. If no parameter is added, this command is used to detect whether the modifier state is supported.

  • --shift, -s detect the Shift key
  • --ctrl, -c detect Ctrl key
  • --alt, -a detect Alt key

kfreebsd [OPTIONS] FILE [CMDLINE]

Load FreeBSD Kernel

kfreebsd_loadenv FILE

Load FreeBSD environment variables

kfreebsd_module FILE [CMDLINE]

Load FreeBSD module

kfreebsd_module_elf FILE [CMDLINE]

Load FreeBSD Module (ELF)

knetbsd [OPTIONS] FILE [CMDLINE]

Load the NetBSD kernel

knetbsd_module FILE [CMDLINE]

Load NetBSD Module

knetbsd_module_elf FILE [CMDLINE]

Load NetBSD Module (ELF)

kopenbsd [OPTIONS] FILE [CMDLINE]

Load the OpenBSD kernel

kopenbsd_ramdisk FILE

Load OpenBSD memory disk

linuxefi FILE [CMDLINE]

Load the Linux kernel

list_env [OPTIONS]

List all variables in the environment block file

  • --file = FILE, -f specify file name, default file name is $ {prefix} / grubenv
  • --skip-sig, -s Skip signature checking of environment files

list_trusted

List a list of trusted keys

load_env [OPTIONS] [VARIABLE…]

Load variables from the environment block file with the same parameters as "list_env"

loadbios BIOS_DUMP [INT10_DUMP]

Load BIOS dump

loopback [OPTIONS] DEVICE FILE

Mount the file as a virtual disk

  • --delete, -d delete the specified virtual disk
  • --mem, -m Copy files to memory and mount, allowing write operations

ls [OPTIONS] [FILE…]

List device or file

Without parameters, all devices are listed. If the parameter is a device name enclosed in parentheses, the name of the device file system is printed. If the argument is a directory specified as an absolute file name, the contents of that directory are listed.

  • --long, -l show more detailed information
  • --human-readable, -h show file size in readable format (KB, MB…)
  • --all, -a list all files

lsacpi [OPTIONS]

Show ACPI information

  • --v1, -1 show version 1 ACPI table only

  • --v2, -2 Display only version 2 and version 3 ACPI tables

lspci [OPTIONS]

List PCI devices

  • --iospace, -i show I / O space

lsefi

Show EFI handle

lsefienv

List all EFI environment variables

lsefimmap

Show EFI memory map

lsefisystab

Show EFI system tables

lua [FILE]

Execute Lua script

map [OPTIONS] FILE

Create UEFI virtual disk and boot

  • --mem, -m load into memory
  • --pause, -p Pause to view information before starting
  • --type = CD / HD / FD, -t specify disk type as CD / HDD / Floppy
  • --disk, -d simulate the entire disk
  • --rw, -w Allow writing to virtual disk, only effective for memory disk
  • --nb, -n Do not start this virtual disk

md5sum arg ...

That is “hashsum –hash md5 arg…"

menuentry “TITLE" [OPTIONS] [arg…] {COMMAND;…}

Define the GRUB menu item, the menu name is TITLE

After the menu item is selected for execution, if --id is specified, the value of the environment variable chosen will be set to the value of --id. The commands in the braces will be executed. If the last command is successfully executed and the kernel has been loaded, the boot command will be automatically executed.

All parameters including TITLE (arg…) are passed as positional parameters, and TITLE is assigned to $ 1.

  • --class = STRING classify menu items, display icons by different categories
  • --users = UESR [, USER] lists the users allowed to execute this menu
  • --hotkey = KEY set hotkey
  • --source = STRING Use STRING as menu entry body.
  • --id = STRING Associates a unique identifier with a menu item. id cannot start with a number, only ASCII alphanumerics, underscores, and hyphens are supported
  • --unrestricted allow all users to execute this menu

Special Hotkeys:

  • backspace
  • tab
  • delete delete key
  • insert
  • esc exit
  • f1 ~ f12 function keys

moksbset

Temporarily disable shim security verification, you need to restart

Warning: Use this command to modify UEFI environment variables

Warning: Use this command may cause security issues

ntboot [OPTIONS] FILE

Start NT6 + VHD / VHDX / WIM

  • --gui, -g enable graphics startup information
  • --pause, -p Pause before starting
  • --vhd, -v specify file type as VHD / VHDX
  • --wim, -w specify file type as WIM
  • --win, -n Windows on boot disk
  • --efi = FILE, -e Specify the bootmgfw.efi path, default is /efi/microsoft/boot/bootmgfw.efi
  • --sdi = FILE, -s specify boot.sdi path, default is /boot/boot.sdi

outb PORT VALUE [MASK]

Write 8-bit value to the port

outl PORT VALUE [MASK]

Write a 32-bit value to the port

outw PORT VALUE [MASK]

Write a 16-bit value to the port

partnew OPTIONS DISK PARTNUM

Create a primary partition for the disk of the msdos partition table

Warning: Use this command may cause data loss

  • --active, -a activate the partition
  • --file = FILE, -f use file as partition content
  • --type = HEX, -t specifies the partition type, 0x00 is automatic, 0x10 is automatically hidden
  • --start = n, -s specify start address (unit is sector)
  • --length = n, -l specify length (unit is sector)

pcidump OPTIONS

Show raw dump of PCI configuration space

  • -d [vendor]: [device] Select devices by vendor and device ID
  • -s [bus]: [slot] [. func] selects a device based on its position on the bus

play FILE | TEMPO [PITCH1 DURATION1] [PITCH2 DURATION2]…

Use PC Speaker to play tunes

If the parameter is a file, the tune recorded by the file is played.

pop_env VARIABLE…

Pass the variables in the submenu to the previous menu

probe OPTIONS DEVICE

Test equipment information

  • --set = VARIABLE, -s set the return value to a variable
  • --driver, -d detect driver
  • --partmap, -p detect partition table type
  • --fs, -f detect file system type
  • --fs-uuid, -u detect file system UUID
  • --label, -l detect file system volume label
  • --partuuid, -g detect partition UUID (GPT partition table)
  • --bootable, -b detect if activated (msdos partition table)
  • --quiet, -q do not display an error

rand [OPTIONS] VARIABLE

Generate Pseudo-Random Numbers

  • --from = n, -f set the lower bound of random numbers
  • --to = n, -t set the upper bound of random numbers

rdmsr [OPTIONS] ADDR

Read a model-specific register at address ADDR.

Please note that on SMP systems, reading from a MSR that has a scope per hardware thread, implies that the value that is returned only applies to the particular cpu / core / thread that runs the command.

Also, if you specify a reserved or unimplemented MSR address, it will cause a general protection exception (which is not currently being handled) and the system will reboot.

  • -v VARIABLE save the value to a variable

read [VARIABLE]

Read a line of user input

read_byte [OPTIONS] ADDR

Read 8-bit value from ADDR

  • -v VARIABLE save the value to a variable

read_dword [OPTIONS] ADDR

Read 32-bit value from ADDR with the same parameters as “read_byte"

read_file FILE VARIABLE…

Read the file and set the contents of the file as variables line by line

read_word [OPTIONS] ADDR

Read 16-bit value from ADDR with the same parameters as “read_byte"

regexp [OPTIONS] 'REGEXP' “STRING"

Test whether the regular expression REGEXP matches the string STRING

Supported regular expressions are POSIX.2 extended regular expressions.

If the -set option is given, the first matching subexpression is stored in the variable var. Subexpressions are numbered starting from 1 with their opening parentheses. The number defaults to 1.

  • --set = [NUMBER:] [VARIABLE], -s save the nth matching string to a variable

save_env [OPTIONS] VARIABLE…

Save the variables from the GRUB environment to the environment block file with the same parameters as "load_env"

sbpolicy [OPTIONS]

Install security policies that bypass Secure Boot

Warning: Use this command may cause security issues

  • --install, -i install security policy
  • --uninstall, -u uninstall security policy
  • --status, -s show security policy status

search OPTIONS STRING

Search Disk

  • --file, -f search by file
  • --label, -l Search by file system volume label
  • --fs-uuid, -u Search by file system UUID
  • --part-label, -L Search by partition volume label
  • --part-uuid, g Search by partition UUID (GPT)
  • --disk-uuid, U Search by disk UUID (GPT)
  • --set = VARIABLE, -s save the first device found to a variable
  • --no-floppy, -n Do not detect floppy disks
  • --quiet, -q If there is no match, no error is displayed
  • --hint = HINT, -h specifies that the search starts from a device first, and if it ends with a comma, the subpartition will also be searched
  • --hint-ieee1275 = HINT If running under the IEEE1275 environment, specify to start searching from a device first
  • --hint-bios = HINT If running in BIOS environment, specify to search from a device first
  • --hint-baremetal = HINT If running in baremetal environment, specify to search from a device first
  • --hint-efi = HINT If running in EFI environment, specify to start searching from a device first
  • --hint-arc = HINT If running in ARC environment, specify to search from a device first