blob: 908c40fdcd69724daaedb36e8fd57141905a6891 [file] [log] [blame]
srs569491544e12010-01-28 21:10:36 -05001GPT fdisk (aka gdisk)
2
3by Roderick W. Smith, rodsmith@rodsbooks.com
4
5******************************** IMPORTANT ********************************
6Most versions of Windows cannot boot from a GPT disk, and most varieties
7prior to Vista cannot read GPT disks. GPT fdisk is a partition editor for
8GPT disks, and it will *AUTOMATICALLY CONVERT* MBR disks to GPT form.
9Therefore, you should **NOT** use GPT fdisk on a Windows system unless you
10fully understand what you're doing! If you accidentally use GPT fdisk on
11your boot disk, or perhaps even on a data disk, you may find recovery to be
12very difficult!
13***************************************************************************
14
15Read the main README file for general information on the program, and read
16the gdisk.html document (the Linux man page converted to HTML format) for
17detailed use information. My GPT fdisk Web page,
18http://www.rodsbooks.com/gdisk/, provides a more tutorial introduction to
19the software.
20
21Windows Use Notes
22-----------------
23
24The Windows version of GPT fdisk was added with version 0.6.2 of the
25package. The Windows binary package includes the gdisk.exe interactive
26text-mode program file but no equivalent to the sgdisk program that's
27available with Linux, FreeBSD, and OS X builds. In theory, an sgdisk.exe
28for Windows could be built if the popt library were installed. I've not
29attempted to do this myself, though. If you care to try, check
30http://gnuwin32.sourceforge.net/packages/popt.htm for information on popt
31for Windows.
32
33To install the program, copy the gdisk.exe program file to any directory on
34your path, such as C:\Windows. Alternatively, you can change to the
35program's directory or type its complete path whenever you use it.
36
37To use the program, first launch a Command Prompt as the Administrator. To
38do this, locate the Command Prompt program icon, right-click it, and select
39"Run as Administrator." If you use a non-Administrator Command Prompt, you
40won't be able to edit hard disk partition tables, although you will be able
41to edit raw disk image files.
42
43The program requires a hard disk identifier as an option. You can specify
44this in either of two forms. The first way is as a number followed by a
45colon, as in:
46
47gdisk 0:
48
49Disks are numbered starting from 0, so the preceding command launches gdisk
50on the first disk. The second way to specify a disk device is via a
51harder-to-remember name:
52
53gdisk \\.\physicaldrive0
54
55This command is equivalent to the earlier one -- it edits the partition
56table on the first physical disk. Change the number at the end of the
57device name to change the disk edited.
58
59If you pass the "-l" option in addition to the disk identifier, the program
60displays the current partition table information and then exits. This use
61entails no risk to MBR disks, since the program never writes data back to
62the disk when used in this way.
63
64As noted above, editing the first disk with GPT fdisk is usually a Bad
65Idea. An exception would be if your system uses an Extensible Firmware
66Interface (EFI) and already boots from a GPT disk. It's safer to edit
67non-boot disks, which usually have numbers of 1 and above, but only if you
68run a version of Windows with GPT support. For more information on Windows'
69support of GPT, see Microsoft's Web page on the topic:
70
71http://www.microsoft.com/whdc/device/storage/GPT_FAQ.mspx
72
srs56946699b012010-02-04 00:55:30 -050073The GUIDs generated by the program to uniquely identify disks and
74partitions aren't "proper" GUIDs; they're purely random numbers. In
75practice, this has caused me no problems; however, it's conceivable that
76some disk utility will complain. The Unix versions of GPT fdisk generate
77proper GUIDs, as of version 0.6.3. Note that this limitation applies ONLY
78to the unique GUIDs for disks and partitions, not to the GUIDs used to
79identify partition type codes; those are standardized and are handled
80correctly by all versions of GPT fdisk.
81
srs569491544e12010-01-28 21:10:36 -050082Source Code and Compilation Issues
83----------------------------------
84
85As of version 0.6.2, I haven't been able to get the code to detect the disk
86sector size to work under Windows, so the Windows binary always assumes a
87512-byte sector size. If you use a disk with another sector size, you'll
88have to change this assumption in the source code (in diskio-windows.cc),
89use a version for another platform, or use a different partitioning tool
90altogether.
91
92I compiled gdisk.exe using MinGW (http://www.mingw.org), and in particular
srs569408bb0da2010-02-19 17:19:55 -050093its Linux-hosted cross-compiler. Under Ubuntu Linux, the Makefile.mingw
94file enables compilation of the software via MinGW. (Type "make -f
95Makefile.mingw" to compile the software.) If you try to compile using
96another compiler or even using MinGW under Windows or another Linux
97variety, you may need to adjust the Makefile.mingw options.
srs569491544e12010-01-28 21:10:36 -050098
srs569408bb0da2010-02-19 17:19:55 -050099I've also attempted to compile the code with OpenWatcom 1.8 and Microsoft
100Visual C++ 2008 Express. My OpenWatcom attempts failed, mostly because the
101compiler can't yet handle iostream output on standard C++ strings.
102OpenWatcom also seems to have incorrectly set the value of UINT32_MAX as if
103uint32_t values were 64-bit integers. This alone won't cause the compile to
104fail, but it would create bugs.
105
106My attemps with Visual C++ were much more successful; after tracking down
107and installing a stdint.h file (I used the one from
108http://msinttypes.googlecode.com/svn/trunk/stdint.h) and making a few other
109minor changes, the code compiled fine, and seems to run properly, although
110I've not tested it extensively. I created native projects for both
111OpenWatcom and Visual C++, ignoring the Makefile approach, but I'm not
112including the relevant project files in the source tarball, since they're
113easy enough to regenerate -- just include all the *.h files and all the
114*.cc files except diskio-unix.cc and sgdisk.cc, then build.
srs569491544e12010-01-28 21:10:36 -0500115
116If you modify GPT fdisk to get it to compile under another compiler, I
117welcome submission of patches.