LinuxCommandLibrary

grub-mkrescue

Create bootable image from GRUB files

TLDR

Create a bootable ISO from the current directory and save it as grub.iso

$ grub-mkrescue --output [grub.iso] .
copy

Create an ISO using GRUB files from a custom directory
$ grub-mkrescue --directory [/usr/lib/grub/i386-pc] --output [grub.iso] [path/to/source]
copy

Use compression for GRUB files when building the image, setting no disables compression
$ grub-mkrescue --compress [no|xz|gz|lzo] --output [grub.iso] [path/to/source]
copy

Disable the GRUB command-line interface in the generated image
$ grub-mkrescue --disable-cli --output [grub.iso] [path/to/source]
copy

Preload specific GRUB modules into the image
$ grub-mkrescue --modules "[part_gpt iso9660]" --output [grub.iso] [path/to/source]
copy

Pass additional options directly to xorriso
$ grub-mkrescue --output [grub.iso] -- [-volid] [volume_name] [path/to/source]
copy

Display help
$ grub-mkrescue [[-?|--help]]
copy

Display version
$ grub-mkrescue --version
copy

SYNOPSIS

grub-mkrescue [OPTION...] [ISO_IMAGES...]

PARAMETERS

-d, --directory=DIR
    Use GRUB images and modules under DIR (default: /usr/lib/grub/<platform>)

-o, --output=FILE
    Set output ISO filename (default: boot.img)

--modules=MODULES
    Pre-load MODULES (comma-separated, repeatable)

--locales=LOCALES
    Include LOCALES (comma-separated, repeatable)

--fonts=FONTS
    Include FONTS (comma-separated, repeatable)

--themes=THEMES
    Include THEMES (comma-separated, repeatable)

--compress[=no|gz|xz]
    Compress GRUB files (default: no)

--xorriso=COMMAND
    Use alternative xorriso or mkisofs command

--romfs-dir=DIR
    Use DIR as ROMFS for El Torito boot images

--disk-modules
    Explicitly include disk modules (e.g., ahci, pata)

--device-map=FILE
    Use FILE as GRUB device map (default: /dev/null)

--help
    Display help and exit

--version
    Print version information and exit

DESCRIPTION

grub-mkrescue is a utility from the GRUB 2 bootloader suite designed to generate bootable ISO9660 images for rescue and recovery operations. It produces an El Torito-compliant CD-ROM image embedding the GRUB command-line rescue shell, along with optional filesystem images like other ISOs. This enables booting into GRUB to inspect filesystems, load modules, or chainload embedded images without a full OS install.

The tool assembles GRUB core images, modules, fonts, and themes from a specified directory (default: /usr/lib/grub/<platform>). It supports customization via preloading modules for specific hardware (e.g., disk drivers), languages, and compression to reduce image size. Internally, it relies on xorriso for ISO creation, allowing overrides.

Common use cases include creating standalone rescue CDs for system troubleshooting, embedding live OS ISOs for multi-boot media, or preparing images for USB drives (via dd). For example, it facilitates accessing /boot/grub/grub.cfg or repairing bootloaders on failing systems. Output images are directly burnable to CD or writable to USB, providing a portable GRUB environment with extensive module support for filesystems (ext4, NTFS, etc.), disks, and networks.

grub-mkrescue shines in minimal environments, requiring no running GRUB instance, and integrates seamlessly with GRUB's modular architecture for flexibility across architectures like x86, EFI, and ARM.

CAVEATS

Requires xorriso package; embedded ISOs must be filesystem images; large outputs may need sufficient RAM/disk space; platform-specific (e.g., i386-pc, x86_64-efi). Not for direct USB boot—use dd.

BASIC USAGE

grub-mkrescue -o rescue.iso
Generates minimal GRUB rescue ISO.

EMBED IMAGES

grub-mkrescue debian-live.iso -o multi-rescue.iso
Embeds Debian ISO into GRUB-bootable rescue image.

WITH MODULES

grub-mkrescue --modules="ext2 ntfs" -o custom.iso
Preloads filesystem modules for broad compatibility.

HISTORY

Introduced in GRUB 2.02 (2012) as evolution of GRUB2's image tools (development since 2005); enhanced in later versions for EFI/multi-arch support and compression options.

SEE ALSO

Copied to clipboard