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
FILE...
One or more files to check. The command will classify each file as an image, a device, or unknown.
-h, --help
Displays a help message with usage information and exits.
-V, --version
Prints the grub-file version information and exits.
DESCRIPTION
The grub-file command is a utility from the GRUB bootloader suite. Its primary function is to determine if a given file path refers to a GRUB-recognized image file or a device. When executed, it analyzes the specified file(s) and outputs a classification: "image", "device", or "unknown". This classification is crucial for GRUB's internal operations and can be helpful for system administrators or developers working with GRUB components. It provides a quick way to verify the type of a file in the context of GRUB's expectations. The command exits with a specific status code (0 for image, 1 for device, 2 for unknown), making it suitable for scripting and automated checks.
CAVEATS
The classification ("image" or "device") provided by grub-file is specific to how GRUB recognizes these entities internally. A file classified as "image" is typically a GRUB core image, module, or other GRUB-specific binary, not a general disk image. Similarly, "device" refers to something GRUB treats as a bootable device or partition. This command does not parse general filesystem contents or determine if a file is a generic disk image (e.g., an ISO or raw disk dump).
EXIT STATUS CODES
grub-file provides specific exit status codes to indicate the result of its check, making it highly suitable for scripting and automated checks:
0: The FILE is an image.
1: The FILE is a device.
2: The FILE is unknown or an error occurred.
HISTORY
The grub-file command is an integral part of the GRUB 2 bootloader project. GRUB (Grand Unified Bootloader) is a free and open-source boot loader package, with GRUB 2 being its more powerful and flexible successor to the original GRUB Legacy. Utilities like grub-file were developed as part of GRUB 2's modular architecture to assist with development, debugging, and system administration, offering specific tools for managing and verifying GRUB's various components and images. Its specific role has remained consistent within the GRUB 2 ecosystem since its introduction.
SEE ALSO
grub-install(8), grub-mkconfig(8), grub-mkimage(1), grub-probe(8)