Google Summer of Code: GPT bootloader

July 01, 2009 posted by Mike M. Volokhov

About the project

The GUID Partition Table is a new standard for disk partitioning. The GPT layout provides a set of advanced partitioning features including, but not limited to:

  • modern logical block addressing (LBA)
  • 64-bit LBA pointers, allowing partitions up to 8 Zbytes in size, and even bigger
  • suitable for disks with sector size, other than 512 bytes
  • by default up to 128 partitions per disk
  • backup partition table.

The NetBSD already has support for GPT disks via dkwedges, but can't boot off a GPT partitioned disk. My GSoC project is to implement a GPT aware bootloader for the NetBSD operating system by extending its existing MBR/disklabel BIOS-based multistaged kernel loader.

Please note, although GPT comes from the EFI world and the loader somewhat mimics EFI bootstrap behavior, the project is not about writing a pure EFI loader. Instead, it will be based on BIOS interface and will technically look like an arbitrary MBR loader but with GPT parsing. Such an approach should allow the use of GPT partitioned disks on non-EFI systems as well. On EFI systems NetBSD can be bootstrapped via the Compatibility Support Module.

Current status

The project assumes development of MBR (or LBA0), Partition Boot Record, and adopting of 1st stage and 2nd stage loaders.

Currently, the MBR (LBA0) loader which parses GPT is in a beta stage. It implements the following features:

  • locating GPT headers by looking at LBA1 and the last LBA of boot disk
  • checking the GPT header for its signature and validating the CRC32
  • walking through the partition table looking for a bootable partition
  • reading the PBR from a bootable partition, testing its boot capability, and passing control to it if the test was successful.

Code cleanup and CRC32 calculation of GUID partition array (which wasn't included due to space constraints, but likely can be enabled after optimisation) are still required.

It was decided to store the primary loader on an EFI System Partition (which is FAT formatted by convention), and not use NetBSD partitions for bootstrapping. Such behavior will be similar to what EFI bootstrapping does, and the boot path will be as follows:

BIOS → LBA0 → PBR on EFI syspart → /boot → NetBSD kernel.

Fortunately, the "fatboot" (or bootxx_fat16) loader can do almost all of the required things in place of the PBR and 1st stage loader. The only missing thing is FAT lookup at an arbitrary offset on the disk (right now it assumes LBA0). It was easily implemented by having partition offset passed from GPT MBR or from any other loader through the ecx:ebx register pair. As we can't rely on all other loaders using this mechanism, the offset could be embedded into the PBR itself by installboot(8).

My current efforts are focused on getting gpt.S and fatboot.S (and corresponding management tools) in shape and ready to publish for beta testing. So the future work in terms of the GSoC project will include the following:

  • code cleanup for gpt.S (LBA0) and fatboot.S
  • review of bootloader installation tools and updating documentation
  • adding GPT support into boot(8)
  • more documentation updates and getting code in shape for CVS merge

Some additional information (including development schedule) can be found at the project home page at:



Post a Comment:
Comments are closed for this entry.