GPT disks in a BIOS world
Nov. 17th, 2011 10:14 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Starting with Fedora 16 we're installing using GPT disklabels by default, even on BIOS-based systems. This is worth noting because most BIOSes have absolutely no idea what GPT is, which you'd think would create some problems. And, unsurprisingly, it does. Shock. But let's have an overview.
GPT, or GUID Partition Table, is part of the UEFI specification. It defines a partition table format that allows up to 128 partitions per disk, with 64 bit start and end values allowing partitions up to 9.4ZB (assuming 512 byte blocks). This is great, because the existing MBR partitioning format only allows up to 2.2TB when using 512 byte blocks. But most BIOSes (and most older operating systems) don't understand GPT, so plugging in a GPT-partitioned disk would result in the system believing that the drive was uninitialised. This is avoided by specifying a protective MBR. This is a valid MBR partition table with a single partition covering the entire disk (or the first 2.2TB of the disk if it's larger than that) and the partition type set to 0xee ("GPT Protective"). GPT-unaware BIOSes and operating systems will see a partition they don't understand and simply ignore it.
But how do we boot a GPT-labelled disk with a protective MBR on a system that doesn't understand GPT? The key here is that BIOS is pretty dumb. Typically a BIOS will see a disk and just attempt to execute the code in the first sector. This MBR code knows how to do the rest of the boot, including parsing the partition table if necessary. The BIOS doesn't need to care at all.
Of course, some BIOSes choose to care. We've seen a small number of machines that, when exposed to a GPT disk, refuse to boot because they parse the MBR partition map and don't like what they see. This is typically accompanied by a message along the lines of "No operating system found". What we've found is that they're looking for a partition marked with the bootable flag, and if no partitions are marked bootable they assume that there's no OS. This is in contrast to the traditional use of the flag, which is merely a hint to the MBR as to which partition boot code it should execute.
So, should we set that flag? The UEFI specification specifically forbids it - table 15 states that the BootIndicator byte must be set to 0. Once again we're left in an unfortunate position where the specification and reality collide in an awkward way.
If this happens to you after a Fedora 16 install, you have two choices. The first is to reinstall with the "nogpt" boot argument. The installer will then set up a traditional MBR partition table. The second is to boot off a live CD and run fdisk against the boot disk. It'll give a bunch of scary warnings. Ignore them. Hit "a", then "1", then "w" to write it to disk. Things ought to work then. We'll figure out something better for F17.
GPT, or GUID Partition Table, is part of the UEFI specification. It defines a partition table format that allows up to 128 partitions per disk, with 64 bit start and end values allowing partitions up to 9.4ZB (assuming 512 byte blocks). This is great, because the existing MBR partitioning format only allows up to 2.2TB when using 512 byte blocks. But most BIOSes (and most older operating systems) don't understand GPT, so plugging in a GPT-partitioned disk would result in the system believing that the drive was uninitialised. This is avoided by specifying a protective MBR. This is a valid MBR partition table with a single partition covering the entire disk (or the first 2.2TB of the disk if it's larger than that) and the partition type set to 0xee ("GPT Protective"). GPT-unaware BIOSes and operating systems will see a partition they don't understand and simply ignore it.
But how do we boot a GPT-labelled disk with a protective MBR on a system that doesn't understand GPT? The key here is that BIOS is pretty dumb. Typically a BIOS will see a disk and just attempt to execute the code in the first sector. This MBR code knows how to do the rest of the boot, including parsing the partition table if necessary. The BIOS doesn't need to care at all.
Of course, some BIOSes choose to care. We've seen a small number of machines that, when exposed to a GPT disk, refuse to boot because they parse the MBR partition map and don't like what they see. This is typically accompanied by a message along the lines of "No operating system found". What we've found is that they're looking for a partition marked with the bootable flag, and if no partitions are marked bootable they assume that there's no OS. This is in contrast to the traditional use of the flag, which is merely a hint to the MBR as to which partition boot code it should execute.
So, should we set that flag? The UEFI specification specifically forbids it - table 15 states that the BootIndicator byte must be set to 0. Once again we're left in an unfortunate position where the specification and reality collide in an awkward way.
If this happens to you after a Fedora 16 install, you have two choices. The first is to reinstall with the "nogpt" boot argument. The installer will then set up a traditional MBR partition table. The second is to boot off a live CD and run fdisk against the boot disk. It'll give a bunch of scary warnings. Ignore them. Hit "a", then "1", then "w" to write it to disk. Things ought to work then. We'll figure out something better for F17.
or not
Date: 2011-11-17 05:07 pm (UTC)I recently switched it to fedora 16, but the installer refused to proceed with any partitions I made. I even tried making a biosboot partition. in the end I let it create a new disklabel, it made a msdos one, and then let me create partitions and install.
maybe F17 will be better.
no subject
Date: 2011-11-17 05:29 pm (UTC)no subject
Date: 2011-11-17 05:31 pm (UTC)no subject
Date: 2011-11-17 05:47 pm (UTC)no subject
Date: 2012-03-18 10:44 pm (UTC)I have managed to get 2 mbr partitions plus extra space, recognized by a booting windows 7 64bit, in the space seen as a single partition in the gpt table. I can not install linux in the empty space as there are already 4 partitions on disk as seen by the mbr (and I can not use an extended mbr patition for linux as it can not boot), and all I can currently try is to sync back the gpt from the mbr and go for a gtp-linux install. But given the support for this kind of setup by parted and other tools, I'm very reluctant...
no subject
Date: 2013-03-16 02:27 am (UTC)1) Because you are mirroring everything on the MBR, you can't have more than 4 bootable partitions. This sounds like plenty, but the bootable ones have to be the first four on the GPT, and Apple--don't ask me why--decided they need the first three (at least on my computer). So you can only dual boot, which is frustrating for those who want Linux, Mac, and Windows (like me).
2) A more specific problem: When I was booting Debian, on install I would have to sync the GPT with the MBR after partitioning so things were lined up, and then install GRUB to the MBR. Didn't realize why I was supposed to do this until I'd made Debian unbootable for the fourth time. Basically, the GPT was getting synced with the MBR after GRUB had been written to the MBR, which overwrote GRUB, and stopped me from booting Linux. This meant that if I wanted to keep Debian (and I'm assuming it would be the same with any Linux distro using GRUB as a boot loader) I had to avoid partitioning again, and avoid Mac updates as the next one included an EFI update (which I eventually installed and, of course, made Debian unbootable with).
So yeah. Doesn't work that well.
no subject
Date: 2011-11-17 05:38 pm (UTC)no subject
Date: 2011-11-17 05:42 pm (UTC)That's not to say that we won't end up doing something like that if the problems turn out to be insurmountable...
no subject
Date: 2011-11-18 11:46 am (UTC)which I assume means that if a chunk of you disk becomes unreadable, you have a much better chance of recovering some of the partitions.
and lots more partitions than msdos. sometimes its hndy to have more than 16 partitions on a disk.
no subject
Date: 2011-11-23 12:03 am (UTC)micro-bootable partition?
Date: 2011-11-18 02:44 am (UTC)Would a small partition (empty or /boot?) set bootable in the MBR help?
Re: micro-bootable partition?
Date: 2011-11-18 02:58 am (UTC)Re: micro-bootable partition?
Date: 2011-11-18 04:21 am (UTC)Change the spec?
Date: 2011-11-19 08:41 pm (UTC)Re: Change the spec?
Date: 2020-09-05 06:45 pm (UTC)UEFI 2.3.1B (the first new update since this post) states that behavior for that bit is undefined on legacy systems, the only requirement is for UEFI to ignore it.
Ignore the spec?
Date: 2011-11-27 09:14 pm (UTC)Re: Ignore the spec?
Date: 2011-11-27 09:23 pm (UTC)Re: Ignore the spec?
Date: 2012-01-04 06:49 am (UTC)