grub: BIOS installation
4.4 BIOS installation
=====================
MBR
===
The partition table format traditionally used on PC BIOS platforms is
called the Master Boot Record (MBR) format; this is the format that
allows up to four primary partitions and additional logical partitions.
With this partition table format, there are two ways to install GRUB: it
can be embedded in the area between the MBR and the first partition
(called by various names, such as the "boot track", "MBR gap", or
"embedding area", and which is usually at least 1000 KiB), or the core
image can be installed in a file system and a list of the blocks that
make it up can be stored in the first sector of that partition.
Modern tools usually leave MBR gap of at least 1023 KiB. This amount
is sufficient to cover most configurations. Hence this value is
recommended by the GRUB team.
Historically many tools left only 31 KiB of space. This is not
enough to parse reliably difficult structures like Btrfs, ZFS, RAID or
LVM, or to use difficult disk access methods like ahci. Hence GRUB will
warn if attempted to install into small MBR gap except in a small number
of configurations that were grandfathered. The grandfathered config
must:
* use biosdisk as disk access module for '/boot' * not use any
additional partition maps to access '/boot' * '/boot' must be on one of
following filesystems: * AFFS, AFS, BFS, cpio, newc, odc, ext2/3/4, FAT,
exFAT, F2FS, HFS, uncompressed HFS+, ISO9660, JFS, Minix, Minix2,
Minix3, NILFS2, NTFS, ReiserFS, ROMFS, SFS, tar, UDF, UFS1, UFS2, XFS
MBR gap has few technical problems. There is no way to reserve space
in the embedding area with complete safety, and some proprietary
software is known to use it to make it difficult for users to work
around licensing restrictions. GRUB works it around by detecting
sectors by other software and avoiding them and protecting its own
sectors using Reed-Solomon encoding.
GRUB team recommends having MBR gap of at least 1000 KiB
Should it be not possible GRUB has support for a fallback solution
which is heavily recommended against. Installing to a filesystem means
that GRUB is vulnerable to its blocks being moved around by filesystem
features such as tail packing, or even by aggressive fsck
implementations, so this approach is quite fragile; and this approach
can only be used if the '/boot' filesystem is on the same disk that the
BIOS boots from, so that GRUB does not have to rely on guessing BIOS
drive numbers.
The GRUB development team generally recommends embedding GRUB before
the first partition, unless you have special requirements. You must
ensure that the first partition starts at least 1000 KiB (2000 sectors)
from the start of the disk; on modern disks, it is often a performance
advantage to align partitions on larger boundaries anyway, so the first
partition might start 1 MiB from the start of the disk.
GPT
===
Some newer systems use the GUID Partition Table (GPT) format. This was
specified as part of the Extensible Firmware Interface (EFI), but it can
also be used on BIOS platforms if system software supports it; for
example, GRUB and GNU/Linux can be used in this configuration. With
this format, it is possible to reserve a whole partition for GRUB,
called the BIOS Boot Partition. GRUB can then be embedded into that
partition without the risk of being overwritten by other software and
without being contained in a filesystem which might move its blocks
around.
When creating a BIOS Boot Partition on a GPT system, you should make
sure that it is at least 31 KiB in size. (GPT-formatted disks are not
usually particularly small, so we recommend that you make it larger than
the bare minimum, such as 1 MiB, to allow plenty of room for growth.)
You must also make sure that it has the proper partition type. Using
GNU Parted, you can set this using a command such as the following:
# parted /dev/DISK set PARTITION-NUMBER bios_grub on
If you are using gdisk, set the partition type to '0xEF02'. With
partitioning programs that require setting the GUID directly, it should
be '21686148-6449-6e6f-744e656564454649'.
*Caution:* Be very careful which partition you select! When GRUB
finds a BIOS Boot Partition during installation, it will automatically
overwrite part of it. Make sure that the partition does not contain any
other data.