LinuxCommandLibrary

grub-bios-setup

Installs GRUB to a BIOS boot partition

TLDR

Set up a device to boot with GRUB

$ grub-bios-setup [/dev/sdX]
copy

Install even if problems are detected
$ grub-bios-setup [[-f|--force]] [/dev/sdX]
copy

Install GRUB in a specific directory
$ grub-bios-setup [[-d|--directory]] [/boot/grub] [/dev/sdX]
copy

SYNOPSIS

grub-bios-setup [OPTION...] [INSTALL_DEVICE]

PARAMETERS

--allow-floppy
    install boot loader on floppies even if not recognized

--allow-mbr-edit
    do not check if writing to MBR is safe

--boot-directory=DIR
    use images and modules under DIR/grub (default /boot/grub)

--bootloader-id=ID
    set bootloader identification (default GRUB)

--compress=NO/BZ2/GZIP/LZ/LZMA/XZ/ZSTD
    select compression method for GRUB files

--core-compress=NO/BZ2/GZIP/LZ/LZMA/XZ/ZSTD
    select compression for core image

--disk-module=MODULE
    add disk module to core image

--fonts=DIR
    use fonts from DIR

--grub-mkconfig=PROG
    use PROG for grub-mkconfig

--help
    display this message and exit

--install-modules=MODULES
    install MODULES (comma-separated)

--modules=MODULES
    pre-load MODULES for core image

--no-disk-module
    do not embed disk module

--no-firmware-detection
    do not probe firmware

--no-nvme
    do not probe NVMe drives

--recheck
    probe devices even if cached

--skip-fs-probe
    do not probe filesystems

--target=TARGET
    set GRUB target (e.g., i386-pc)

--themes=THEMES
    use themes from THEMES

--verbose
    print verbose messages

--version
    print version information

DESCRIPTION

grub-bios-setup is a low-level utility from the GRUB 2 bootloader suite designed to install the GRUB core image (stage 2) directly into the boot sector of a BIOS-compatible device, such as the Master Boot Record (MBR) of a hard disk. It is primarily used on legacy x86 PC systems with BIOS firmware, embedding the bootloader to chainload the full GRUB menu from /boot/grub.

This command handles filesystem probing, module embedding, and core image generation tailored for BIOS targets like i386-pc. It supports customization via options for compression, modules, themes, and more. While powerful for repairs or scripts, it is typically called internally by grub-install, which adds safety checks and multi-target support.

Key workflow: Run as root on the target disk (e.g., /dev/sda), then generate config with grub-mkconfig. Incorrect usage risks overwriting bootloaders on wrong devices, potentially causing unbootable systems. Ideal for manual installs, embedded systems, or troubleshooting dual-boots.

CAVEATS

Requires root privileges. Specify whole disk (e.g., /dev/sda), not partition. Risks data loss if wrong device targeted. Run grub-mkconfig -o /boot/grub/grub.cfg after install. Not for UEFI.

EXAMPLES

grub-bios-setup /dev/sda
Installs default GRUB core on first disk.

grub-bios-setup --target=i386-pc --bootloader-id="MYGRUB" --compress=xz /dev/sda
Custom ID and compression.

EXIT STATUS

0 on success, non-zero on error (e.g., device busy, probe failure).

HISTORY

Introduced in GRUB 2.02 (2012) as modular BIOS installer, replacing legacy stage1/stage2. Enhanced in GRUB 2.04+ for better module support, compression (XZ/Zstd), and NVMe probing. Now core to GRUB 2.12 (2024).

SEE ALSO

Copied to clipboard