• Home
Name Date Size #Lines LOC

..--

Android.bpD03-May-2024728 4036

COPYINGD03-May-202417.6 KiB341281

LICENSED03-May-202417.6 KiB341281

METADATAD03-May-2024417 1918

MODULE_LICENSE_GPLD03-May-20240

MakefileD03-May-20241.5 KiB4728

Makefile.freebsdD03-May-20241.5 KiB4528

Makefile.macD03-May-20241.8 KiB5030

Makefile.mingwD03-May-20241.3 KiB4228

Makefile.mingw64D03-May-20241.3 KiB4228

NEWSD03-May-202457.2 KiB1,3771,020

NOTICED03-May-202417.6 KiB341281

OWNERSD03-May-2024154 54

READMED03-May-202413.2 KiB274220

README-efi.txtD03-May-20245.8 KiB133106

README.WindowsD03-May-20246.9 KiB137110

android_popt.ccD03-May-20243.6 KiB12787

attributes.ccD03-May-20247.4 KiB229158

attributes.hD03-May-20241.2 KiB4228

basicmbr.ccD03-May-202458.8 KiB1,6731,224

basicmbr.hD03-May-20245.1 KiB155109

bsd.ccD03-May-202411.4 KiB335229

bsd.hD03-May-20243.7 KiB9550

cgdisk.8D03-May-202415.7 KiB396326

cgdisk.ccD03-May-20242.5 KiB8050

crc32.ccD03-May-20241.6 KiB7338

crc32.hD03-May-2024610 214

current.specD03-May-20242.5 KiB8666

diskio-unix.ccD03-May-202415.8 KiB500354

diskio-windows.ccD03-May-202410.6 KiB344239

diskio.ccD03-May-20242.1 KiB9363

diskio.hD03-May-20242 KiB8756

fixparts.8D03-May-202410.5 KiB283225

fixparts.ccD03-May-20243.6 KiB11582

gdisk.8D03-May-202428.3 KiB700596

gdisk.ccD03-May-20242 KiB7056

gdisk_test.shD03-May-20248 KiB403244

gpt.ccD03-May-2024101.5 KiB2,6281,919

gpt.hD03-May-20247.9 KiB217163

gptcl.ccD03-May-202424.2 KiB600530

gptcl.hD03-May-20241.8 KiB5627

gptcurses.ccD03-May-202426.4 KiB824659

gptcurses.hD03-May-20244.3 KiB13790

gptpart.ccD03-May-202414.1 KiB466348

gptpart.hD03-May-20243.7 KiB10361

gpttext.ccD03-May-202435.4 KiB969740

gpttext.hD03-May-20242.5 KiB7437

guid.ccD03-May-20247.3 KiB220139

guid.hD03-May-20241.6 KiB6838

mbr.ccD03-May-20246 KiB165105

mbr.hD03-May-20241.2 KiB4421

mbrpart.ccD03-May-202411.3 KiB362246

mbrpart.hD03-May-20243.9 KiB11471

parttypes.ccD03-May-202428.8 KiB569412

parttypes.hD03-May-20241.9 KiB6843

popt.hD03-May-20241.8 KiB7139

sgdisk.8D03-May-202426.8 KiB620529

sgdisk.ccD03-May-20242.7 KiB10070

support.ccD03-May-202412.2 KiB364254

support.hD03-May-20242.4 KiB8756

uninstall-fixpartsD03-May-2024593 2513

uninstall-gdiskD03-May-2024817 3321

README

1GPT fdisk (aka gdisk, cgdisk, and sgdisk) and FixParts
2by Roderick W. Smith, rodsmith@rodsbooks.com
3
4Introduction
5------------
6
7This package includes the source code for four related disk partitioning
8programs:
9
10- gdisk -- This program is modeled after Linux fdisk, but it operates on
11  GUID Partition Table (GPT) disks rather than the Master Boot Record (MBR)
12  disks that fdisk modifies. As such, gdisk is an interactive text-mode
13  tool for manipulating partitions, but it does nothing to the contents of
14  those partitions (usually filesystems, but sometimes swap space or other
15  data).
16
17- cgdisk -- This program is modeled after Linux cfdisk, but it operates on
18  GPT disks rather than the MBR disks that cfdisk modifies. As such, cgdisk
19  is a curses-based text-mode tool for manipulating partitions, which is to
20  say that it uses an interface that relies on arrow keys and a dynamic
21  display rather than the command letters and a scrolling display like
22  gdisk uses.
23
24- sgdisk -- This program is conceptually similar to the Linux sfdisk and
25  FreeBSD gpt programs, but its operational details differ. It enables
26  manipulation of GPT disks using command-line options, so it's suitable
27  for use in scripts or by experts to perform specific tasks that might
28  take several commands in gdisk to accomplish.
29
30- fixparts -- This program, unlike the preceding three, operates on MBR
31  disks. It's intended to fix certain problems that can be created by
32  various utilities. Specifically, it can fix mis-sized extended partitions
33  and primary partitions located in the middle of extended partitions. It
34  also enables changing primary vs. logical partition status (within limits
35  of what's legal in the MBR scheme) and making a few other minor changes.
36  It does NOT support creating new partitions; for that, you should use
37  fdisk, parted, or some other tool.
38
39More details about the abilities of these tools follows.
40
41All four programs rely on the same set of underlying code base; they differ
42only in their control interfaces (defined in gdisk.cc, cgdisk.cc,
43sgdisk.cc, and fixparts.cc, respectively) and in which support code they
44use.
45
46GPT fdisk (gdisk, cgdisk, and sgdisk) Details
47---------------------------------------------
48
49The gdisk program is intended as a (somewhat) fdisk-workalike program for
50GPT-partitioned disks, cgdisk is similarly a workalike for fdisk, and
51sgdisk provides most of gdisk's functionality in a more script-friendly
52program. Although libparted and programs that use it (GNU Parted, gparted,
53etc.) provide the ability to handle GPT disks, they have certain
54limitations that gdisk overcomes. Specific advantages of gdisk, cgdisk, and
55sgdisk include:
56
57* The ability to convert MBR-partitioned disks in-place to GPT format,
58  without losing data
59
60* The ability to convert BSD disklabels in-place to create GPT
61  partitions, without losing data
62
63* The ability to convert from GPT format to MBR format without data loss
64  (gdisk and sgdisk only)
65
66* More flexible specification of filesystem type code GUIDs, which
67  GNU Parted tends to corrupt
68
69* Clear identification of the number of unallocated sectors on a
70  disk
71
72* A user interface that's familiar to long-time users of Linux
73  fdisk and cfdisk (gdisk and cgdisk only)
74
75* The MBR boot loader code is left alone
76
77* The ability to create a hybrid MBR, which permits GPT-unaware OSes to
78  access up to three GPT partitions on the disk (gdisk and sgdisk only)
79
80Of course, GPT fdisk isn't without its limitations. Most notably, it lacks
81the filesystem awareness and filesystem-related features of GParted. You
82can't resize a partition's filesystem or create a partition with a
83filesystem already in place with gdisk, for instance. There's no GUI
84version of gdisk.
85
86The GPT fdisk package provides three program files: the interactive
87text-mode gdisk, the curses-based interactive cgdisk, and the
88command-line-driven sgdisk. The first two are intended for use in manually
89partitioning disks or changing partitioning details; sgdisk is intended for
90use in scripts to help automate tasks such as disk cloning or preparing
91multiple disks for Linux installation.
92
93FixParts Details
94----------------
95
96This program's creation was motivated by cries for help I've seen in online
97forums from users who have found their partition tables to be corrupted by
98various buggy partitioning tools. Although most OSes can handle the
99afflicted disks fine, libparted-based tools (GParted, parted, most Linux
100installers, etc.) tend to flake out when presented with these disks.
101Typically, the symptom is a disk that appears to hold no partitions;
102however, sometimes the libparted tool presents partitions other than those
103that the OS sees.
104
105I've observed four causes of these symptoms, three of which FixParts can
106correct:
107
108* Old GPT data -- If a disk is used as a GPT disk and then re-used as an
109  MBR disk, the GPT data may be incompletely erased. This happens if the
110  disk is repartitioned with fdisk or the Microsoft Windows installer, for
111  instance. (Tools based on libparted correctly remove the old GPT data
112  when converting from GPT to MBR format.) FixParts checks for this problem
113  when it starts and offers to correct it. If you opt to erase the GPT
114  data, this erasure occurs immediately, unlike other changes the program
115  makes.
116
117* Mis-sized extended partitions -- Some tools create an extended partition
118  that's too large, typically ending after the last sector of the disk.
119  FixParts automatically corrects this problem (if you use the 'w' option
120  to save the partition table).
121
122* Primary partitions inside an extended partition -- Some utilities create
123  or move primary partitions to within the range covered by the extended
124  partition. FixParts can usually correct this problem by turning the
125  primary partition into a logical partition or by changing one or more
126  other logical partitions into primaries. Such corrections aren't always
127  possible, though, at least not without deleting or resizing other
128  partitions.
129
130* Leftover RAID data -- If a disk is used in a RAID array and then re-used
131  as a non-RAID disk, some utilities can become confused and fail to see
132  the disk. FixParts can NOT correct this problem. You must destroy the old
133  RAID data, or possibly remove the dmraid package from the system, to fix
134  this problem.
135
136When run, FixParts presents an fdisk-like interface, enabling you to adjust
137partition types (primary, logical, or omitted), change type codes, change
138the bootable flag, and so on. Although you can delete a partition (by
139omitting it), you can't create new partitions with the program. If you're
140used to partitioning disks, particularly with Linux fdisk, two unusual
141features of FixParts require elaboration:
142
143* No extended partitions -- Internally, FixParts reads the partition table
144  and discards data on any extended partition(s) it finds. When you save
145  the partition table, the program generates a new extended partition. This
146  design means that the program automatically corrects many problems
147  related to the extended partition. It also means that you'll see no
148  evidence of extended partitions in the FixParts user interface, although
149  it keeps track of the requirements and prevents you from creating illegal
150  layouts, such as a primary between two logicals.
151
152* Partition numbering -- In most Linux tools, partitions 1-4 are primaries
153  and partitions 5 and up are logicals. Although a legal partition table
154  loaded into FixParts will initially conform to this convention, some
155  types of damaged table might not, and various changes you make can also
156  cause deviations. When FixParts writes the partition table, its numbering
157  will be altered to conform to the standard MBR conventions, but you
158  should use the explicit labeling of partitions as primary or logical
159  rather than the partition numbers to determine a partition's status.
160
161Installing
162----------
163
164To compile GPT fdisk, you must have appropriate development tools
165installed, most notably the GNU Compiler Collection (GCC) and its g++
166compiler for C++. I've also tested compilation with Clang, which seems to
167work; however, I've not done extensive testing of the resulting binaries,
168beyond checking a few basics. Under Windows, Microsoft Visual C++ 2008 can
169be used instead. In addition, note these requirements:
170
171* On Linux, FreeBSD, OS X, and Solaris, libuuid must be installed. This is
172  the standard for Linux and OS X, although you may need to install a
173  package called uuid-dev or something similar to get the headers. On
174  FreeBSD, the e2fsprogs-libuuid port must be installed.
175
176* The ICU library (http://site.icu-project.org), which provides support for
177  Unicode partition names, is optional on all platforms except Windows, on
178  which it's not supported. Using this library was required to get proper
179  UTF-16 partition name support in GPT fdisk versions prior to 0.8.9, but
180  as of that version it should not longer be required. Nonetheless, you can
181  use it if you're having problems with the new UTF-16 support. This
182  library is normally installed in Linux and OS X, but you may need to
183  install the development headers (libicu-dev or something similar in
184  Linux; or the libicu36-dev Fink package in OS X). To compile with ICU
185  support, you must modify the Makefile: Look for commented-out lines that
186  refer to USE_UTF16, -licuuc, -licudata, or -licucore. Uncomment them and
187  comment out the equivalents that lack these lines.
188
189* The cgdisk program requires the ncurses library and its development files
190  (headers). Most Linux distributions install ncurses by default, but you
191  may need to install a package called libncurses5-dev, ncurses-devel, or
192  something similar to obtain the header files. These files were installed
193  already on my Mac OS X development system; however, they may have been
194  installed as dependencies of other programs I've installed. If you're
195  having problems installing ncurses, you can compile gdisk and/or sgdisk
196  without cgdisk by specifying only the targets you want to compile to
197  make.
198
199* The sgdisk program requires the popt library and its development files
200  (headers). Most Linux distributions install popt by default, but you may
201  need to install a package called popt-dev, popt-devel, or something
202  similar to obtain the header files. Mac OS users can find a version of
203  popt for Mac OS from Darwin Ports (http://popt.darwinports.com), MacPorts
204  (https://trac.macports.org/browser/trunk/dports/devel/popt/Portfile), Fink
205  (http://www.finkproject.org), or brew (http://macappstore.org/popt/);
206  however, you'll first need to install the relevant environment
207  (instructions exist on the relevant projects' pages). Alternatively, you
208  can compile gdisk and/or cgdisk alone, without sgdisk; gdisk doesn't
209  require popt.
210
211When all the necessary development tools and libraries are installed, you
212can uncompress the package and type "make" at the command prompt in the
213resulting directory. (You may need to type "make -f Makefile.mac" on Mac OS
214X, "make -f Makefile.freebsd" on FreeBSD, "make -f Makefile.solaris" on
215Solaris, or "make -f Makefile.mingw" to compile using MinGW for Windows.)
216You may also need to add header (include) directories or library
217directories by setting the CXXFLAGS environment variable or by editing the
218Makefile. The result should be program files called gdisk, cgdisk, sgdisk,
219and fixparts. Typing "make gdisk", "make cgdisk", "make sgdisk", or "make
220fixparts" will compile only the requested programs. You can use these
221programs in place or copy the files to a suitable directory, such as
222/usr/local/sbin. You can copy the man pages (gdisk.8, cgdisk.8, sgdisk.8,
223and fixparts.8) to /usr/local/man/man8 to make them available.
224
225Caveats
226-------
227
228THIS SOFTWARE IS BETA SOFTWARE! IF IT WIPES OUT YOUR HARD DISK OR EATS YOUR
229CAT, DON'T BLAME ME! To date, I've tested the software on several USB flash
230drives, physical hard disks, and virtual disks in the QEMU and VirtualBox
231environments. Many others have now used the software on their computers, as
232well. I believe all data-corruption bugs to be squashed, but I know full well
233that the odds of my missing something are high. This is particularly true for
234large (over-2TiB) drives; my only direct testing with such disks is with
235virtual QEMU and VirtualBox disks. I've received user reports of success with
236RAID arrays over 2TiB in size, though.
237
238My main development platform is a system running the 64-bit version of
239Ubuntu Linux. I've also tested on several other 32- and 64-bit Linux
240distributions, Intel-based Mac OS X 10.6 and several later versions, 64-bit
241FreeBSD 7.1, and Windows 7 and 10.
242
243Redistribution
244--------------
245
246This program is licensed under terms of the GNU GPL (see the file COPYING).
247
248Acknowledgements
249----------------
250
251This code is mostly my own; however, I've used three functions from two
252other GPLed programs:
253
254- The code used to generate CRCs is taken from the efone program by
255  Krzysztof Dabrowski and ElysiuM deeZine. (See the crc32.h and
256  crc32.cc source code files.)
257
258- A function to find the disk size is taken from Linux fdisk by A. V. Le
259  Blanc. This code has subsequently been heavily modified.
260
261Additional code contributors include:
262
263- Yves Blusseau (1otnwmz02@sneakemail.com)
264
265- David Hubbard (david.c.hubbard@gmail.com)
266
267- Justin Maggard (justin.maggard@netgear.com)
268
269- Dwight Schauer (dschauer@ti.com)
270
271- Florian Zumbiehl (florz@florz.de)
272
273- Guillaume Delacour (contributed the gdisk_test.sh script)
274

README-efi.txt

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

README.Windows

1GPT fdisk (aka gdisk) and FixParts
2
3by Roderick W. Smith, rodsmith@rodsbooks.com
4
5******************************** IMPORTANT ********************************
6Most versions of Windows cannot boot from a GPT disk on BIOS-based
7computers, and most varieties prior to Vista cannot read GPT disks. GPT
8fdisk is a partition editor for GPT disks, and it will *AUTOMATICALLY
9CONVERT* MBR disks to GPT form. Therefore, you should **NOT** use GPT fdisk
10on a Windows system unless you fully understand what you're doing or are
11certain that your computer boots in EFI/UEFI mode! If you accidentally use
12GPT fdisk on a BIOS-mode boot disk, or perhaps even on a data disk, you may
13find recovery to be very difficult! Pre-installed Windows 8 and later
14systems almost always use GPT disks and boot in EFI/UEFI mode, but
15self-installed Windows 8 systems sometimes use BIOS mode. This caveat does
16not apply to FixParts, though; that tool works only on MBR disks.
17***************************************************************************
18
19Read the main README file for general information on the program, and read
20the gdisk.html or fixparts.html documents (the Linux man pages converted to
21HTML format) for detailed use information. My GPT fdisk Web page,
22http://www.rodsbooks.com/gdisk/, provides a more tutorial introduction to
23the software. I originally wrote GPT fdisk on Linux, and some Linux- and
24Unix-centric language remains in the documentation.
25
26Windows Use Notes
27-----------------
28
29The Windows version of GPT fdisk was added with version 0.6.2 of the
30package. The Windows binary package includes the gdisk.exe interactive
31text-mode program file but no equivalent to the sgdisk program that's
32available with Linux, FreeBSD, and OS X builds. In theory, an sgdisk.exe
33for Windows could be built if the popt library were installed. I've not
34attempted to do this myself, though. If you care to try, check
35http://gnuwin32.sourceforge.net/packages/popt.htm for information on popt
36for Windows.
37
38Beginning with version 0.8.10, I'm distributing both 32-bit and 64-bit
39binaries, which include the strings "32" or "64" in their names. The 32-bit
40binaries work fine on most versions of Windows, but some 64-bit
41installations of Windows 8 lack 32-bit support libraries and so may need
42the 64-bit binaries.
43
44The FixParts program (fixparts32.exe and fixparts64.exe) is new with GPT
45fdisk 0.7.0. As described in the main README file, this program fixes
46certain partition table problems that can be created by buggy partitioning
47software. Windows seems to be unfazed by most such problems, but I've not
48done an extensive survey of Windows partitioning tools on this score.
49
50To install the programs, copy the gdisk32.exe and fixparts32.exe (or
51gdisk64.exe and fixparts64.exe) program files to any directory on your
52path, such as C:\Windows. Alternatively, you can change to the program's
53directory or type its complete path whenever you use it.
54
55To use the programs, first launch a Command Prompt as the Administrator. To
56do this, locate the Command Prompt program icon, right-click it, and select
57"Run as Administrator." If you use a non-Administrator Command Prompt, you
58won't be able to edit hard disk partition tables, although you will be able
59to edit raw disk image files.
60
61The program requires a hard disk identifier as an option. You can specify
62this in either of two forms. The first way is as a number followed by a
63colon, as in:
64
65gdisk 0:
66
67Disks are numbered starting from 0, so the preceding command launches gdisk
68on the first disk. The second way to specify a disk device is via a
69harder-to-remember name:
70
71gdisk32 \\.\physicaldrive0
72
73This command is equivalent to the earlier one -- it edits the partition
74table on the first physical disk. Change the number at the end of the
75device name to change the disk edited.
76
77If you pass the "-l" option to gdisk.exe in addition to the disk
78identifier, the program displays the current partition table information
79and then exits. This use entails no risk to MBR disks, since the program
80never writes data back to the disk when used in this way.
81
82As noted above, editing the first disk with GPT fdisk is usually a Bad
83Idea. An exception would be if your system uses an Extensible Firmware
84Interface (EFI) and already boots from a GPT disk. It's safer to edit
85non-boot disks, which usually have numbers of 1 and above, but only if you
86run a version of Windows with GPT support. For more information on Windows'
87support of GPT, see Microsoft's Web page on the topic:
88
89http://www.microsoft.com/whdc/device/storage/GPT_FAQ.mspx
90
91The Windows binaries I've compiled do not support Unicode UTF-16LE GPT
92partition names. This feature was added to version 0.7.1 of the software
93for Linux, FreeBSD, and OS X, and with changes to some #ifndef lines in the
94source files, it can be compiled for Windows; however, it seems to do
95little good in Windows because of Command Prompt window and/or ICU library
96limitations. Thus, I've omitted this support in the interests of
97simplifying the binary distribution, since including it would mean
98distributing the ICU libraries.
99
100Source Code and Compilation Issues
101----------------------------------
102
103I have successfully compiled GPT fdisk using three different Windows
104compilers:
105
106- MinGW (http://www.mingw.org), and in particular its Linux-hosted
107  cross-compiler -- Under Ubuntu Linux, the Makefile.mingw and
108  Makefile.mingw64 files enable compilation of the software via MinGW.
109  (Type "make -f Makefile.mingw" to compile 32-bit binaries, and "make -f
110  Makefile.mingw64" to compile 64-bit binaries.) If you try to compile
111  using another compiler or even using MinGW under Windows or another Linux
112  variety, you may need to adjust the Makefile.mingw options.
113
114- Microsoft Visual C++ 2008 Express
115  (http://www.microsoft.com/express/Windows/) -- This compiler requires a
116  third-party stdint.h file (I used the one from
117  http://msinttypes.googlecode.com/svn/trunk/stdint.h), but it otherwise
118  works fine. A project is easily created by adding all the *.h files and
119  all the *.cc files except diskio-unix.cc, sgdisk.cc, and whichever
120  program file you intend to NOT build (gdisk.cc or fixparts.cc).
121
122- Microsoft Visual C++ 2010 Express -- This compiler works much like the
123  2008 version, although I didn't need to add a third-party stdint.h file.
124
125The MinGW compiler produces much larger executables than do the MS
126compilers. The resulting binaries seem to work equally well, but my testing
127has been minimal.
128
129I've also attempted to compile the code with OpenWatcom 1.8, but this
130attempt failed, mostly because the compiler can't yet handle iostream
131output on standard C++ strings. OpenWatcom also seems to have incorrectly
132set the value of UINT32_MAX as if uint32_t values were 64-bit integers.
133This alone won't cause the compile to fail, but it would create bugs.
134
135If you modify GPT fdisk to get it to compile under another compiler, I
136welcome submission of patches.
137