grub-mkimage
Create GRUB images for booting
SYNOPSIS
grub-mkimage [OPTION...] -o OUTPUT_FILE -O FORMAT [MODULES...]
Common invocation example: grub-mkimage -d /usr/lib/grub/i386-pc -O i386-pc -o core.img biosdisk part_msdos normal multiboot
PARAMETERS
-o, --output=FILE
Specify the output file path for the generated GRUB image.
-d, --directory=DIR
Use GRUB images and modules found in the specified directory. Defaults to /usr/lib/grub/<platform>.
-p, --prefix=DIR
Set the GRUB root directory (prefix) where GRUB looks for its modules and configuration files at boot time.
-c, --config=FILE
Embed the content of the specified file as an early GRUB configuration script, executed before grub.cfg is loaded.
-O, --format=FORMAT
Specify the target platform and image format (e.g., i386-pc, x86_64-efi, arm64-efi). This is crucial for cross-platform compatibility.
-m, --memdisk=FILE
Embed the specified file as a memdisk (initial RAM disk) within the GRUB image.
-v, --verbose
Print verbose messages during image generation, useful for debugging.
-n, --dry-run
Perform a dry run; don't actually generate the image, but print the modules and files that would be included.
-C, --compression=(xz|none|auto)
Choose the compression algorithm for the core image. Options include xz, none, or auto.
--dtb=FILE
Embed a Device Tree Blob (DTB) file into the GRUB image, primarily for ARM-based systems.
DESCRIPTION
The grub-mkimage command is a crucial utility within the GRUB (GRand Unified Bootloader) suite, responsible for generating custom GRUB boot images. It takes various GRUB modules, configuration files, and architecture-specific settings to produce a bootable image (e.g., core.img for BIOS or bootx64.efi for UEFI systems). This command is highly flexible, allowing administrators to tailor GRUB's capabilities, embed specific drivers, cryptographic keys, or initial ramdisks directly into the boot image. While typically invoked indirectly by tools like grub-install, understanding its options is essential for advanced GRUB customization, troubleshooting boot issues, or creating specialized bootable media like rescue disks or network boot images. It ensures that the minimal set of GRUB modules required for initial boot is packaged efficiently for the target system's firmware and architecture.
CAVEATS
grub-mkimage is a low-level tool, and its direct use requires a good understanding of GRUB's architecture and the target system's boot process. Incorrect parameters, especially for --format, --directory, or --prefix, can result in unbootable images. Errors can be subtle and difficult to diagnose without using the --verbose option. It's often safer to rely on higher-level tools like grub-install unless specific customization is required.
HISTORY
grub-mkimage is an integral part of GRUB 2, which superseded the original GRUB (now often referred to as GRUB Legacy). GRUB 2 was developed to address limitations of GRUB Legacy, offering a more modular and flexible design. The mkimage utility was introduced as a core component of this new architecture, allowing dynamic assembly of bootable GRUB images tailored to various hardware platforms, firmware types (BIOS, UEFI, PowerPC, SPARC, etc.), and desired functionalities. Its development reflects the need for a highly adaptable bootloader in a diverse computing landscape, moving away from monolithic boot images to a more component-based approach.
SEE ALSO
grub-install(8), grub-mkconfig(8), grub-probe(8)