Grub2-install: “this GPT partition label contains no BIOS Boot Partition”

bootgrublvm2partitioning

There seems to be quite a bit of discussion about this but I can't find a simple answer.

When I try to install grub2 I get this error:

# grub2-install /dev/sda
Installing for i386-pc platform.
grub2-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
grub2-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
grub2-install: error: will not proceed with blocklists.

Here is the layout of /dev/sda:

Disk /dev/sda: 111.8 GiB, 120034123776 bytes, 234441648 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 7ECE06D0-9F0C-44FF-BCFB-142283172CCA

Device        Start       End   Sectors  Size Type
/dev/sda1      2048    411647    409600  200M Linux filesystem (/boot)
/dev/sda2    411648   4605951   4194304    2G Linux swap
/dev/sda3   4605952  46548991  41943040   20G Linux filesystem (/)
/dev/sda4  46548992 234441614 187892623 89.6G Linux LVM (/var)

Is there a simple way that I can get around this problem? I understand that I need to create a tiny partition at the beginning of the disk as a "BIOS Boot Partition". I suppose one option would be to move the swap to /dev/sda4 as a logical volume, and use /dev/sda2 as /boot.

Alternatively I could just go back to grub-legacy and not worry about that (is there really an advantage to upgrading to grub2 if it causes this much trouble?).

Thoughts?

Best Answer

You should first determine whether you want to use a BIOS/CSM/legacy-mode boot or an EFI/UEFI-mode boot. The former is the way that PCs have been booting since the 1980s, but it's an ugly and hackish system that will be going the way of the dodo before too long. Windows ties BIOS-mode booting to the MBR partition table, which you're not using (but could; your disk is nowhere near big enough to require GPT). Linux, FreeBSD, and most other modern OSes are more flexible, and support BIOS-mode booting from GPT; but there are sometimes firmware-created complications, and of course if you later decide to install Windows in a dual-boot setup you'll need to make changes or compromises.

EFI/UEFI-mode booting is less of a hack; but EFI implementations vary greatly in quality and the overall level of expertise and support on the Web for EFI is lower than that for BIOS. Windows ties use of GPT to EFI-mode booting, so if you expect to ever install Windows on your computer, EFI is definitely the way to go. Older computers are BIOS-only. EFI began to take off in the marketplace in mid-2011, so if your computer is older than that, you might not be able to use EFI.

If you go with BIOS-mode booting, you should create a BIOS Boot Partition on the disk. There's enough room at the start of your disk for this partition, but you'll need to set your sector alignment value to 1 (from the usual 2048) for this to work. I don't know offhand if this can be done with parted, but you can do it with gdisk. (Note that the space at the start of your disk is slightly under the recommended 1MiB size for a BIOS Boot Partition, but just by a few sectors. It will probably work fine, but might conceivably fail at some point in the future.) Alternatively, you can shrink any of your partitions by 1-2MiB to make room for the BIOS Boot Partition. This partition does not need to be the first partition on the disk, although that's the conventional location.

If you go with EFI/UEFI-mode booting, you must create an EFI System Partition (ESP). This partition must be FAT-formatted and must be significantly larger than a BIOS Boot Partition, so you'll have to resize something to create it. I recommend a size of 550MiB, although a tenth of that might work in a pinch.

To install GRUB, you should first be sure that you've installed the correct GRUB package. I'm not sure of naming in all distributions, but in Ubuntu, it would be grub-pc for BIOS/CSM/legacy mode and grub-efi-amd64 for EFI/UEFI mode. An EFI-mode installation will also require booting whatever you're using to install GRUB (a live CD/USB, presumably) in EFI mode. Doing this may require using your computer's built-in boot manager, which is typically accessed via a function key, but the details vary from one computer to another.

Related Question