srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 1 | GPT fdisk (aka gdisk) |
| 2 | by Roderick W. Smith, rodsmith@rodsbooks.com |
| 3 | |
| 4 | Introduction |
| 5 | ------------ |
| 6 | |
| 7 | This software is intended as a (somewhat) fdisk-workalike program for |
| 8 | GPT-partitioned disks. Although libparted and programs that use it (GNU |
| 9 | Parted, gparted, etc.) provide the ability to handle GPT disks, they have |
srs5694 | 3c0af38 | 2010-01-15 19:19:18 -0500 | [diff] [blame] | 10 | certain limitations that gdisk overcomes. Specific advantages of gdisk and |
| 11 | sgdisk include: |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 12 | |
| 13 | * The ability to convert MBR-partitioned disks in-place to GPT format, |
| 14 | without losing data |
| 15 | |
srs5694 | 221e087 | 2009-08-29 15:00:31 -0400 | [diff] [blame] | 16 | * The ability to convert BSD disklabels in-place to create GPT |
| 17 | partitions, without losing data |
| 18 | |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 19 | * The ability to specify sector-exact partition sizes |
| 20 | |
| 21 | * More flexible specification of filesystem type code GUIDs, which |
| 22 | GNU Parted tends to corrupt (particularly for FAT partitions) |
| 23 | |
| 24 | * Clear identification of the number of unallocated sectors on a |
| 25 | disk |
| 26 | |
| 27 | * A user interface that's familiar to long-time users of Linux |
srs5694 | 3c0af38 | 2010-01-15 19:19:18 -0500 | [diff] [blame] | 28 | fdisk (gdisk only) |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 29 | |
| 30 | * The MBR boot loader code is left alone (GNU Parted tends to |
| 31 | wipe it out with every change) |
| 32 | |
srs5694 | 221e087 | 2009-08-29 15:00:31 -0400 | [diff] [blame] | 33 | * The ability to create a hybrid MBR, which permits GPT-unaware |
| 34 | OSes to access up to three GPT partitions on the disk |
| 35 | |
srs5694 | 3c0af38 | 2010-01-15 19:19:18 -0500 | [diff] [blame] | 36 | Of course, GPT fdisk isn't without its limitations. Most notably, it lacks |
| 37 | the filesystem awareness and filesystem-related features of GNU Parted. You |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 38 | can't resize a partition's filesystem or create a partition with a |
| 39 | filesystem already in place with gdisk, for instance. There's no GUI |
| 40 | version of gdisk. |
| 41 | |
srs5694 | 3c0af38 | 2010-01-15 19:19:18 -0500 | [diff] [blame] | 42 | The GPT fdisk package provides two program files: the interactive text-mode |
| 43 | gdisk and the command-line-driven sgdisk. The former is intended for use in |
| 44 | manually partitioning disks or changing partitioning details; the latter is |
| 45 | intended for use in scripts to help automate tasks such as disk cloning or |
| 46 | preparing multiple disks for Linux installation. |
| 47 | |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 48 | Installing |
| 49 | ---------- |
| 50 | |
srs5694 | 3c0af38 | 2010-01-15 19:19:18 -0500 | [diff] [blame] | 51 | To compile GPT fdisk, you must have appropriate development tools |
| 52 | installed, most notably the GNU Compiler Collection (GCC) and its g++ |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 53 | compiler for C++. In addition, note these requirements: |
| 54 | |
| 55 | * On Linux, FreeBSD, and OS X, libuuid must be installed. This is the |
| 56 | standard for Linux and OS X, although you may need to install a package |
| 57 | called uuid-dev or something similar to get the headers. On FreeBSD, the |
| 58 | e2fsprogs-libuuid port must be installed. |
| 59 | |
| 60 | * The sgdisk program also requires the popt library and its development |
| 61 | files (headers). Most Linux distributions install popt by default, but |
| 62 | you may need to install a package called popt-dev, popt-devel, or |
| 63 | something similar to obtain the header files. Mac OS users can find a |
| 64 | version of popt for Mac OS from http://popt.darwinports.com; however, |
| 65 | you'll first need to install DarwinPorts (instructions exist on the |
| 66 | preceding page). Alternatively, you can compile gdisk alone, without |
| 67 | sgdisk; gdisk doesn't require popt. |
srs5694 | ba00fed | 2010-01-12 18:18:36 -0500 | [diff] [blame] | 68 | |
| 69 | When all the necessary development tools and libraries are installed, you |
| 70 | can uncompress the package and type "make" at the command prompt in the |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 71 | resulting directory. (You may need to type "make -f Makefile.mac" on Mac OS |
srs5694 | 55d9261 | 2010-03-07 22:16:07 -0500 | [diff] [blame] | 72 | X or "make -f Makefile.mingw" to compile using MinGW for Windows.) You may |
| 73 | also need to add header (include) directories or library directories by |
| 74 | setting the CXXFLAGS environment variable or by editing the Makefile. The |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 75 | result should be program files called gdisk and sgdisk. Typing "make gdisk" |
| 76 | or "make sgdisk" will compile only the requested programs. You can use |
| 77 | these programs in place or copy the files to a suitable directory, such as |
| 78 | /usr/local/sbin. You can copy the man pages (gdisk.8 and sgdisk.8) to |
| 79 | /usr/local/man/man8 to make them available. |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 80 | |
| 81 | Caveats |
| 82 | ------- |
| 83 | |
srs5694 | 5d58fe0 | 2010-01-03 20:57:08 -0500 | [diff] [blame] | 84 | THIS SOFTWARE IS BETA SOFTWARE! IF IT WIPES OUT YOUR HARD DISK OR EATS YOUR |
| 85 | CAT, DON'T BLAME ME! To date, I've tested the software on several USB flash |
| 86 | drives, a handful of PATA and SATA hard disks, and several virtual disks in |
| 87 | a QEMU environment. I believe all data-corruption bugs to be squashed, but |
| 88 | I know full well that the odds of my missing something are high. This is |
| 89 | particularly true for large drives; my only direct testing with such disks |
| 90 | is with virtual QEMU disks. I've received user reports of success with |
| 91 | RAID arrays over 2TiB in size, though. |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 92 | |
| 93 | My main development platform is a system running the 64-bit version of |
srs5694 | 55d9261 | 2010-03-07 22:16:07 -0500 | [diff] [blame] | 94 | Gentoo Linux (previously Ubuntu 8.04). I've also tested on 64-bit OpenSuSE, |
| 95 | 32-bit Fedora 10, 32-bit Fedora 11, 32-bit Ubuntu 6.10, 64-bit Ubunut 9.10, |
| 96 | 32-bit PowerPC Debian Linux, 32-bit Intel-based Mac OS X 10.5 and 10.6, and |
| 97 | 64-bit FreeBSD 7.1. Problems relating to 64-bit integers on the 32-bit |
| 98 | Linux have been common during development and may crop up in the future. |
| 99 | The Mac OS X, FreeBSD, and big-endian (PowerPC) support are new. |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 100 | |
| 101 | Redistribution |
| 102 | -------------- |
| 103 | |
| 104 | This program is licensed under terms of the GNU GPL (see the file COPYING). |
| 105 | |
| 106 | Acknowledgements |
| 107 | ---------------- |
| 108 | |
| 109 | This code is mostly my own; however, I've used three functions from two |
| 110 | other GPLed programs: |
| 111 | |
| 112 | - The code used to generate CRCs is taken from the efone program by |
| 113 | Krzysztof Dabrowski and ElysiuM deeZine. (See the crc32.h and |
| 114 | crc32.cc source code files.) |
| 115 | |
| 116 | - A function to find the disk size is taken from Linux fdisk by |
| 117 | A. V. Le Blanc. |
| 118 | |
| 119 | Additional code contributors include: |
| 120 | |
| 121 | - Yves Blusseau (1otnwmz02@sneakemail.com) |
| 122 | |
srs5694 | 7f244ba | 2009-08-18 14:22:12 -0400 | [diff] [blame] | 123 | - David Hubbard (david.c.hubbard@gmail.com) |