grub-mkstandalone
Create standalone GRUB images (e.g., for ISOs)
SYNOPSIS
grub-mkstandalone [OPTION...] [OUTPUT_FILE]
PARAMETERS
--directory=DIR
Use DIR as the GRUB module directory.
--format=FORMAT
Generate an image of type FORMAT. Common formats are 'i386-pc' for BIOS systems or 'x86_64-efi' for UEFI systems.
--grub-mkimage=FILE
Specify the path to the grub-mkimage executable.
--modules=MODULE1,MODULE2,...
Include only the specified modules. Overrides the modules listed in grub.cfg.
--no- Grub-install
Do not run grub-install as part of the process.
--output=FILE
Write the output to FILE. Equivalent to specifying OUTPUT_FILE as the last argument.
--prefix=DIR
Set the GRUB prefix to DIR.
--install-modules=MODULE1,MODULE2,...
Install MODULES into prefix/i386-pc (or similar architecture directory, as appropriate). Useful for modules not explicitly specified in the configuration file.
--config=FILE
Use FILE as the configuration file. Defaults to grub.cfg if not specified.
--fonts=FONT1,FONT2,...
Include the specified fonts.
--locale=LOCALE1,LOCALE2,...
Include the specified locales.
--themes=THEME1,THEME2,...
Include the specified themes.
--compression=TYPE
Compress files using TYPE (gz, xz, lzo). Defaults to no compression if not provided.
DESCRIPTION
grub-mkstandalone is a command-line utility used to generate a bootable GRUB image that doesn't rely on the main system's filesystem after booting. This is crucial for creating rescue disks, embedded systems, or environments where the root filesystem is not immediately available or is read-only. The command essentially packages a minimal GRUB environment along with necessary modules, configuration, and potentially a kernel, into a single image file.
It operates by analyzing a GRUB configuration file (typically grub.cfg) and extracting the necessary modules and files. These are then combined with a minimal GRUB core image to produce the standalone image.
grub-mkstandalone facilitates the creation of very small and portable bootable images, especially beneficial when dealing with limited resources or where the system needs to operate independently from the main system's root filesystem after the initial boot sequence.
CAVEATS
The standalone image's size can become quite large if many modules, fonts, locales, or themes are included. Carefully select only the necessary components to keep the image size manageable. Debugging can be difficult, as the image must boot independently. The resulting image depends on the configuration provided, so ensure it accurately reflects the desired boot environment.
The resulting images are not automatically bootable in all environemnts. Extra steps might be necessary.
BOOTLOADERS
grub-mkstandalone is a key tool for creating custom bootloaders. By carefully crafting the grub.cfg and selecting modules, you can create a highly customized boot environment tailored to specific needs.
TROUBLESHOOTING
If the generated image fails to boot, check the following:
1. The grub.cfg file is correct and contains the necessary boot commands.
2. The specified modules are available in the GRUB module directory.
3. The boot device is configured correctly in the BIOS/UEFI.
4. The FORMAT option matches your hardware architecture (i.e. i386-pc for BIOS or x86_64-efi for UEFI).
EXAMPLE USAGE
Create a bootable ISO image:grub-mkstandalone --format=i386-pc --output=boot.iso --directory=/usr/lib/grub/i386-pc --modules='normal linux chain' --config=grub.cfg
SEE ALSO
grub-install(1), grub-mkimage(1), grub-mkconfig(8)