How to mark a GPT Partition bootable under Linux

3

1

  • How to boot from a GPT Partition?
  • Is it like the MBR way that needs a partition that has the bootable flag on?
  • How to mark a GPT Partition bootable under Linux?

xpt

Posted 2019-07-21T21:26:02.983

Reputation: 5 548

Answers

2

How to boot from a GPT Partition?

Booting a Linux installation involves multiple stages and software components, including firmware initialization, execution of a boot loader, loading and startup of a Linux kernel image, and execution of various startup scripts and daemons. For each of these stages and components there are different variations and approaches; for example, GRUB, LILO, SYSLINUX or Loadlin can be used as boot loaders, while the startup scripts can be either traditional init-style, or the system configuration can be performed through modern alternatives such as systemd or Upstart.

Another popular program to use to boot with is rEFInd a UEFI boot manager capable of launching EFISTUB kernels.

The EFI (Extensible Firmware Interface) system partition or ESP is a partition on a data storage device (usually a hard disk drive or solid-state drive) that is used by computers adhering to the Unified Extensible Firmware Interface (UEFI). When a computer is booted, UEFI firmware loads files stored on the ESP to start installed operating systems and various utilities.

An ESP contains the boot loaders or kernel images for all installed operating systems

Is it like the MBR way that needs a partition that has the bootable flag on?

The boot flag is from ancient times, where you would indicate an MBR partition record as bootable, so you could indicate where the boot loader resided. So to answer your question no you don't have to flag a boot partition bootable.

The globally unique identifier (GUID) for the EFI system partition in the GUID Partition Table (GPT) scheme is C12A7328-F81F-11D2-BA4B-00A0C93EC93B, while its ID in the master boot record (MBR) partition-table scheme is 0xEF.

How to mark a GPT Partition bootable under Linux?

  • In gdisk, you set the type code to EF00. (gdisk uses two-byte type codes that expand out to the real type codes on the disk; "EF00" is just a mnemonic for "C12A7328-F81F-11D2-BA4B-00A0C93EC93B".)
  • In GParted or parted, you set the "boot flag." Note, however, that this works only on GPT disks; you cannot set the ESP type code on MBR disks with these programs. (This isn't normally a big deal, since EFI-based computers usually boot from GPT disks.)
  • In recent versions of Linux fdisk, you set the partition type by its number (1 for "EFI System" on GPT disks or 0xEF on MBR disks) or by entering the full type code on GPT disks.

Donald L Wilson

Posted 2019-07-21T21:26:02.983

Reputation: 56

Thanks for the most comprehensive answer. Follow up question to make it 100% clear, "In GParted or parted, you set the "boot flag"", does that means that there can be more than one "boot flag" set for the GPT Partitions? Moreover, can you show the output of sgdisk -p or fdisk -l of a GPT that has such "boot flag" set please? Thx – xpt – 2019-07-25T00:23:46.647

Found from the gdisk help: gdisk type code of EF00 stands for "EFI System", which doesn't look like "boot flag" to me (the "ef02", "BIOS boot partition" looks more so). Kindly to elaborate a bit please? (Temporarily flipped the accept flag in waiting for answer for these two follow up questions) – xpt – 2019-07-25T03:31:27.783

In Gparted the boot flag is used by some commercial operating system boot loaders.
The boot flag indicates the partition is active or bootable.
Only one partition on a disk device can be active.
The output from fdisk -l is: /dev/sda1 2048 1050623 1048576 512M EFI System
– Donald L Wilson – 2019-07-27T06:52:34.743

The boot flag "EF00" is just a mnemonic for or GUID partition type "C12A7328-F81F-11D2-BA4B-00A0C93EC93B" is the EFI system partition . "ef02" is the GUID 21686148-6449-6E6F-744E-656564454649 or BIOS boot partition. – Donald L Wilson – 2019-07-27T07:18:45.430

Thanks Donald. The supplementary answer is normally put within the answer instead of here in comments, BTW. – xpt – 2019-07-27T13:31:28.020

I wasn't real sure about that, I should probably remove my comments and add them into the above answer for others to be able to read? – Donald L Wilson – 2019-07-27T23:14:44.913

Yes please. That's the common practice here. Thanks. – xpt – 2019-07-29T01:51:09.773