Booting large GPT disks without EFI

October 13, 2012 Technical, General

In recent times we’ve been dealing with systems with more and more diskspace. Our latest deployment has a full 30TB of usable capacity! However, this presents some interesting challenges when it comes to booting the operating system.

Disks larger than 2TB necessitate the use of GPT partition tables, and booting from GPT disks involves jumping through some hoops due to the way the BIOS and bootloaders work. You can dodge this bullet if you’re using a hardware RAID card, but that’s not always an option.

That’s the situation we found ourselves in the other day, with some shiny new multi-terabyte drives not attached to a hardware RAID controller. We’ll gloss over a lot of the details, but the short version is that we can’t put GRUB’s stage 1.5 in the usual location, after the MBR.

If you have a full-blown EFI system then this doesn’t affect you, but for the conceivable future we’re stuck with using a classic PC BIOS. Let’s go!

Using the BIOS Boot Partition

GPT provides a solution for just this situation, in the form of a BIOS Boot Partition (BBP). The BBP is an unformatted space in which the bootloader can stash helper code – in this case, the stage1.5 component of GRUB. This is an elegant solution because it formalises the “hands off” nature of the space, rather relying on the de facto arrangement that there’ll be a suitable unmolested gap between the MBR and the first defined partition.

Making use of a BBP is easy, you just need to set it up before installing GRUB. GRUB will detect the presence of the BBP and use that to hold stage1.5.

We’re using GNU Parted here. It’s not the nicest tool to use, but it’s reliably available and gets the job done. We’re also assuming the use of GRUB2, as it can read GPT tables. Some distros distribute a patched version of GRUB Legacy that can deal with GPT, but it’s not the optimal solution so we won’t cover it here.

  1. Fire up parted on the disk you’re preparing to use. You might do this from a rescue environment, or in a shell session from the OS installer.
    parted /dev/sda
  2. Create a fresh GPT table. It’ll automatically create a protective MBR for you in the process.
    mklabel gpt
  3. Create a small BBP and mark it accordingly
    # You can't start at 0MB because that would literally mean the first sector of the disk, where the MBR lives.
    # Starting at 1MB makes for tidy alignment.
    mkpart bbp 1MB 2MB
    # Mark it as a BBP, it receives a special GUID for that purpose
    set 1 bios_grub on
  4. Go ahead and create your other partitions now. A dedicated /boot partition isn’t needed, so you can create a monolithic partition and throw it at LVM if you desire.
    # Use the entire remainder of the disk.
    mkpart partitionName 2MB 100%
    # Perhaps you want two partitions, one for md-raid and one unraided
    mkpart system 2MB 10GB
    set 2 raid on
    mkpart data 10GB 100%
  5. View the partition table at any time to see what’s happening with your partitions.
  6. All changes are made synchronously, so you just quit once you’re done.
    # You can also switch to another disk without exiting parted
    select /dev/sdb

Now when you go to install GRUB (using grub-install /dev/sda or similar), it’ll detect the BBP and put stage1.5 in there.