grub-file
Check if file is bootable by GRUB
TLDR
Check if a file is an ARM EFI image
Check if a file is an i386 EFI image
Check if a file is an x86_64 EFI image
Check if a file is an ARM image (Linux kernel)
Check if a file is an x86 image (Linux kernel)
Check if a file is an x86_64 XNU image (macOS kernel)
SYNOPSIS
grub-file [OPTION]... FILE
PARAMETERS
-h, --help
display this help message and exit
-v, --version
print version information and exit
--is-x86-multiboot
exit 0 if FILE is 32-bit x86 Multiboot image for PC BIOS
--is-x86-64-multiboot
exit 0 if FILE is 64-bit x86 Multiboot image for PC BIOS
-m, --is-grub-module
exit 0 if FILE is any type of GRUB module
--is-normal
exit 0 if FILE is a GRUB 'normal' module
DESCRIPTION
grub-file is a utility from the GRUB 2 bootloader package designed to analyze files and determine if they contain GRUB-specific image components, such as modules or Multiboot executables.
It inspects file headers, ELF sections, and embedded structures like modinfo to classify contents. Without check options, it outputs a concise string describing the type, e.g., ELF (x86_64) (normal) for a 64-bit normal module or Multiboot (x86) for compatible kernels.
With --is-* options, it acts as a boolean tester, exiting with 0 on match and non-zero otherwise. This makes it invaluable in build scripts, installers, or boot configuration tools to verify compatibility before loading images, avoiding runtime errors in GRUB environments.
Common use cases include checking Linux kernels for Multiboot support during custom distro creation or validating modules in GRUB's core.img. It supports x86, x86_64, and some EFI/embedded targets, but focuses on GRUB's parsing logic rather than generic file typing.
CAVEATS
Detects only GRUB-recognized formats; use file(1) for general MIME/type info. Does not modify files or load them into GRUB.
SCRIPT EXAMPLE
if grub-file --is-x86-multiboot /boot/vmlinuz; then
echo 'Kernel is Multiboot compatible.'
fi
OUTPUT EXAMPLES
grub-file --is-grub-module modfile.mod (exits 0)
grub-file /boot/vmlinuz
ELF (x86_64) (Multiboot)
HISTORY
Introduced in GRUB 2 (development from 2005, stable 2.00 in 2009) to replace GRUB Legacy tools, enhancing modular image verification for modern bootloaders.
SEE ALSO
grub-probe(1), grub-mkimage(1), grub-script-check(1), file(1)


