1README for EFI version of GPT fdisk
2===================================
3
4GPT fdisk for EFI is a binary build of gdisk to run as a pre-boot EFI
5application. It's OS-independent and may be used to check or recover
6partition tables before installing or booting an OS. It may be used to
7overcome boot problems caused by partition table damage or to prepare a
8partition table prior to installing an OS.
9
10Installing GPT fdisk for EFI
11----------------------------
12
13The contents of this archive are:
14
15- COPYING -- The GNU GPL
16- gdisk.html -- The gdisk man page, in HTML form
17- gdisk_x64.efi -- The gdisk binary, built for EFI (x86-64 CPU)
18- NEWS -- The GPT fdisk changelog
19- README-efi.txt -- This file
20- refind.cer -- The rEFInd public key, .cer (DER) form
21- refind.crt -- The rEFInd public key, .crt form
22
23The gdisk_x64.efi binary included here is built using the UEFI GPT fdisk
24library (https://sourceforge.net/p/uefigptfdisk/), which is a beta-level
25partial C++ library for UEFI. To use it, you must copy it to your EFI
26System Partition (ESP) or some other EFI-accessible location. Under Linux,
27the ESP is usually one of the first two or three partitions on /dev/sda.
28Under OS X, it's usually the first partition on /dev/disk0 (that is,
29/dev/disk0s1). Under Windows, you can mount it to S: by typing "mountvol S:
30/S" in an Administrator command prompt. In any of these cases, the
31recommended location for gdisk_x64.efi is the EFI/tools directory on the
32ESP. In that location, my rEFInd boot manager will detect the gdisk binary
33and create a menu option to launch it. If you don't use rEFInd, you can
34launch the program using an EFI shell, register it as a boot program with
35your firmware, or configure your boot manager (GRUB, gummiboot, etc.) to
36launch it. Note that boot LOADERS, such as SYSLINUX and ELILO, can't launch
37gdisk.
38
39Alternatively, you can create a USB flash drive that will launch gdisk when
40you boot from it. To do so, create a FAT filesystem on a partition on a USB
41flash drive and copy gdisk_x64.efi to it as EFI/BOOT/bootx64.efi. (You'll
42need to create the EFI/BOOT directory.) Some systems may require the FAT
43filesystem to be flagged as an ESP (with a type code of EF00 in gdisk). You
44can use your firmware's built-in boot manager to boot from the USB flash
45drive. Some such boot managers present two options for booting USB flash
46drives. If yours does this, select the option that includes the string
47"UEFI" in the description.
48
49The gdisk_x64.efi binary is signed with the rEFInd Secure Boot key. Thus,
50if you're launching a rEFInd that I've compiled and distributed myself,
51gdisk should launch, too. If you're *NOT* running rEFInd but ARE using
52Shim, you'll need to add the refind.cer file to your MOK list by using the
53MokManager utility. If you're using Secure Boot and you've signed rEFInd
54yourself, you'll need to sign gdisk_x64.efi yourself, too. Note that the
55rEFInd PPA distributes unsigned binaries and signs them with a local key
56stored in /etc/refind/keys. To copy and sign the gdisk_x64.efi binary, you
57should type (as root or using sudo):
58
59sbsign --key /etc/refind.d/keys/refind_local.key \
60  --cert /etc/refind.d/keys/refind.crt \
61  --output /boot/efi/EFI/tooks/gdisk_x64.efi ./gdisk_x64.efi
62
63This command assumes you have local rEFInd keys stored in the locations
64created by the rEFInd installation script. Substitute your own keys if
65you've built them in some other way. Some distributions don't provide the
66sbsign binary, so you may need to build it yourself. See the following page
67for details:
68
69https://git.kernel.org/cgit/linux/kernel/git/jejb/sbsigntools.git/
70
71Note that you do *NOT* need to sign gdisk if your computer doesn't use
72Secure Boot or if you've disabled this feature.
73
74Using gdisk for EFI
75-------------------
76
77The EFI version of gdisk is basically the same as using the Linux, OS X, or
78other OS versions. One exception is that you do not specify a disk device
79on the command line; gdisk for EFI instead displays a list of devices when
80you launch and enables you to select one, as in:
81
82List of hard disks found:
83 1: Disk EFI_HANDLE(3EB5DD98): 108423424 sectors, 51.7 GiB
84    Acpi(PNP0A03,0)/Pci(1|1)/Ata(Primary,Master)
85 2: Disk EFI_HANDLE(3EB58289): 105456768 sectors, 50.3 GiB
86    Acpi(PNP0A03,0)/Pci(D|0)?
87
88Disk number (1-2): 2
89
90Once you've selected your disk, it should operate in much the same way as
91any other version of gdisk. (See the next section, though!) Some programs,
92including my rEFInd boot manager, complain about the changed partition
93table, even if you've made no changes. If you run into problems using other
94programs or launching an OS immediately after running gdisk, reboot; that
95should cause the firmware to re-load its partition table.
96
97Caveats
98-------
99
100I've tested gdisk_x64.efi on several systems. It's worked fine for me on 4
101of 6 computers (5 of 7, counting VirtualBox). Two systems gave me problems,
102though:
103
104* gdisk presented a never-ending list of options (as if receiving a
105  never-ending string of "?" or other unrecognized command characters) on a
106  2014 MacBook Air.
107* A computer based on an Intel DG43NB motherboard rebooted as soon as I
108  launched gdisk.
109
110Both computers have relatively old EFIs. (Despite its newness, the Mac has
111a 1.10 EFI, as do all Macs, to the best of my knowledge.) Most of the
112computers that worked had 2.31 EFIs, although one had a 2.10 EFI.
113
114The bottom line is that I can't guarantee that this binary will work on all
115computers. It's conceivable that recompiling gdisk with the latest version
116of the UEFI GPT fdisk library will help. Also, I haven't compiled a 32-bit
117version, so if you have a 32-bit EFI, you'll have to compile it yourself or
118do without.
119
120References
121----------
122
123The following sites have useful additional information:
124
125UEFI GPT fdisk:
126https://sourceforge.net/projects/uefigptfdisk/
127
128sbsigntools git repository:
129https://git.kernel.org/cgit/linux/kernel/git/jejb/sbsigntools.git/
130
131rEFInd:
132http://www.rodsbooks.com/refind/
133