68

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?

7 Answers 7

39

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.

5
  • Thanks for your very helpful answer. I got things working on a virtual machine with a bit of messing around. When I try to do this on my "production" machine (which has two hard drives) I have a number of problems: grub2-install grub-setup=/bin/true /dev/sda gives grub2-install: error: More than one install device?.. On my working VM the starting sector is marked as 32, but on the production machine its 2048. Don't know if this is relevant.
    – Robert S
    Apr 19, 2015 at 6:12
  • 3
    As Flow suggests in his answer the partition type of the BIOS Boot Partition must be set to 0x04 that is "BIOS boot" otherwise grub fails to install. This can be set for example with fdisk's "t" command. Dec 21, 2017 at 12:02
  • Is there a way to make grub 2 install without a bios boot partition? I only want to use UEFI. Mar 8, 2018 at 4:29
  • 2
    In an EFI-mode installation, GRUB 2 does not use a BIOS Boot Partition. If GRUB is asking for one, then chances are you've booted in BIOS mode, not in EFI mode. Check your boot options to be sure your CSM is disabled, as described on my Web page on the subject: rodsbooks.com/efi-bootloaders/csm-good-bad-ugly.html
    – Rod Smith
    Mar 12, 2018 at 2:28
  • 1
    I set my first partition to type 4, it started on sector 2048, I formatted it with mkfs.vfat, default options, and grub installed with no complaint (to sda, not sda1) and booted just fine on an ASROCK BIOS. Dec 21, 2021 at 21:08
24

You already have this tiny partition, so kk the first partition starts not with 1 but with 2048

/dev / sda1 2048 411647 409600 200M Linux file system (/boot)

You need to change the label type, from boot to bios_grub for example through parted:

parted /dev/sda
set 1 boot off
set 1 bios_grub on
q

Then again:

grub2-install /dev/sda
23

If you want to use GPT partitions with old-style BIOS boot mode, then you need to create a BIOS partition of a few megabytes (16MiB should be fine and future proof) on the device where you want to install grub with grub-install.

Use, e.g. fdisk to create the partition of type "BIOS boot" somewhere on your disk. Example output:

# fdisk -l /dev/sda
Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 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: 57E16A16-36B4-4445-A216-031EF6501415

Device        Start        End    Sectors   Size Type
/dev/sda1      2048    4196351    4194304     2G Linux RAID
/dev/sda2   4196352   35653631   31457280    15G Linux RAID
/dev/sda3  35653632   37750783    2097152     1G Linux swap
/dev/sda4  37750784   37816319      65536    32M BIOS boot
/dev/sda5  37816320 1953525134 1915708815 913.5G Linux LVM
1
  • 3
    Just a confirmation: you saved my setup ... I had installed Ubuntu 20.04 on a pair of old Barracudas configured to serve a single / filesystem on a mirroring LVM logical volume, without being aware of the requirement to have a separate BIOS boot partition when GPT partition is used. I just shaved 4 MB off the LVM logical volume and physical volume, resized the ext4 filesystem on it, created the BIOS boot partition at the end of both disks, marked them as such with gdisk, and grub-install /dev/sda; grub-install /dev/sdb now worked, allowing me to boot up the system. Jan 4, 2021 at 13:08
5

The boot partition has to be formatted fat32, for it to work

mkfs.vfat -F32 /dev/sdXY

Should fix it for you

Also the boot flag has to be on in parted:

set 1 boot on
1
  • 1
    mkfs.vfat is pointless, the BIOS boot partition has no filesystem. set 1 boot on is the only needed action.
    – rustyx
    Dec 24, 2020 at 1:20
2

I had this problem just now on an EFI-mode machine with a GPT disk (Ubuntu 18.04 Server), which one day decided to boot only as far as the GRUB shell on its own.

Somehow, grub-pc (for BIOS-mode / i386 machines) was installed and grub-efi was not. The fix was simple once the problem was identified:

# apt install grub-efi
# update-grub
# grub-install

Note that the first command uninstalled grub-pc.

2

I hit exactly this error when trying to rescue an unbootable system from a rescue USB image. The core issue was that my system was an x86_64 system, while the rescue image was i386 and these are not compatible enough for grub-install to work. The solution was to specify both the boot target, and where to get files from. In my case, I mounted my root partition to /mnt and then this worked: grub-install -d /mnt/usr/lib/grub/x86_64-efi --boot-directory=/mnt/boot /dev/sda

FYI, before doing this, I had also done a mount /dev/sda1 /mnt/boot/efi but I don't know if this mattered or not. The /dev/sda1 is where my EFI partition was, and /mnt/boot/efi is where grub looked for it.

4
  • Welcome to SuperUser! How is this answer better than the top answer? Dec 21, 2022 at 21:38
  • Because the top answer provides no useful information. It's misleading and sends you off on a wild goose-chase about BIOS partitions. That's why the question has more upvotes than the top answer.
    – Linas
    Dec 21, 2022 at 21:40
  • Very сonfusing and entangled answer. Please elaborate what do you call "my root partition" and "EFI partition"? Dec 13, 2023 at 16:34
  • the root partition is the partition that contains the root file system. The EFI partition is the partition that contains the EFI file system.
    – Linas
    Dec 14, 2023 at 23:28
0

My computer somehow got into this state when after every update (of kernel?) I couldn't boot and trying to fix it from a live "cd" (debian installer usb key & chroot) I got this error and googling took me here, so this might be helpful for someone else but its basically from the first answer here...

For me the problem seemed to be I had grub-pc installed but was probably using UEFI boot.

It helped when i uninstalled grub-pc and installed grub-efi-amd64

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .