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