LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

grub-mkstandalone

Build a standalone GRUB image with a memdisk

TLDR

Build a UEFI image that embeds grub.cfg
$ grub-mkstandalone -O x86_64-efi -o [path/to/grub.efi] boot/grub/grub.cfg=[path/to/grub.cfg]
copy
Pre-load modules before the config runs
$ grub-mkstandalone -O x86_64-efi --modules "part_gpt ext2" -o [path/to/grub.efi] boot/grub/grub.cfg=[path/to/grub.cfg]
copy
Print verbose progress
$ grub-mkstandalone -v -O x86_64-efi -o [path/to/grub.efi] boot/grub/grub.cfg=[path/to/grub.cfg]
copy
Show help
$ grub-mkstandalone --help
copy

SYNOPSIS

grub-mkstandalone [OPTION]... [SOURCE]...

DESCRIPTION

grub-mkstandalone builds one GRUB 2 image that contains the modules it needs (and any files you graft in) inside a memdisk. The firmware can boot that single file without a separate /boot/grub tree. Typical uses are a USB stick, a custom UEFI application, and an image that must carry its own grub.cfg.The tool is a front end to grub-mkimage. Output is a format-specific binary such as an EFI application or a BIOS core image. It does not register the image with the firmware.

PARAMETERS

-O, --format FORMAT

Image format, for example x86_64-efi or i386-pc. --help lists the formats this build supports.
-o, --output FILE
Write the image to FILE. This option is required.
-d, --directory DIR
Read GRUB images and modules from DIR. The default is /usr/lib/grub/ followed by the platform name.
--modules MODULES
Pre-load these modules in the core image, before the memdisk is used.
--install-modules MODULES
Put only these modules and their dependencies in the memdisk. The default is every module.
--compress no|xz|gz|lzo
Compress files stored in the image.
--fonts FONTS
Fonts to install. The default is unicode.
--locales LOCALES
Locales to install. The default is all of them.
--themes THEMES
Themes to install. The default is starfield.
-k, --pubkey FILE
Embed FILE as a public key for signature checking.
-v, --verbose
Print verbose messages.
-?, --help
Show the full option list and exit.
-V, --version
Print the version and exit.
SOURCE
A file to place in the memdisk, written as a graft point: the path inside the image, an equals sign, and the file to embed. Example: boot/grub/grub.cfg=./grub.cfg.

INSTALL

sudo apt install grub-common
copy
sudo pacman -S grub
copy
sudo apk add grub
copy

CAVEATS

--output is mandatory. A graft path is the location inside the memdisk, not a second output file. The format must match the machine that will boot the image. Building from a GRUB install for a different platform requires --directory to point at that platform's modules.

SEE ALSO

RESOURCES

Copied to clipboard
Kai