1
GPT fdisk (aka gdisk and sgdisk) and FixParts
1
GPT fdisk (aka gdisk, cgdisk, and sgdisk) and FixParts
2
2
by Roderick W. Smith, rodsmith@rodsbooks.com
7
This package includes the source code for three related disk partitioning
7
This package includes the source code for four related disk partitioning
10
10
- gdisk -- This program is modeled after Linux fdisk, but it operates on
14
14
those partitions (usually filesystems, but sometimes swap space or other
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
17
24
- sgdisk -- This program is conceptually similar to the Linux sfdisk and
18
25
FreeBSD gpt programs, but its operational details differ. It enables
19
26
manipulation of GPT disks using command-line options, so it's suitable
20
27
for use in scripts or by experts to perform specific tasks that might
21
28
take several commands in gdisk to accomplish.
23
- fixparts -- This program, unlike the preceding two, operates on MBR
30
- fixparts -- This program, unlike the preceding three, operates on MBR
24
31
disks. It's intended to fix certain problems that can be created by
25
32
various utilities. Specifically, it can fix mis-sized extended partitions
26
33
and primary partitions located in the middle of extended partitions. It
32
39
More details about the abilities of these tools follows.
34
All three programs rely on the same set of underlying code base; they
35
differ only in their control interfaces (defined in gdisk.cc, sgdisk.cc,
36
and fixparts.cc, respectively) and in which support code they use.
41
All four programs rely on the same set of underlying code base; they differ
42
only in their control interfaces (defined in gdisk.cc, cgdisk.cc,
43
sgdisk.cc, and fixparts.cc, respectively) and in which support code they
38
GPT fdisk (gdisk and sgdisk) Details
39
------------------------------------
46
GPT fdisk (gdisk, cgdisk, and sgdisk) Details
47
---------------------------------------------
41
49
The gdisk program is intended as a (somewhat) fdisk-workalike program for
42
GPT-partitioned disks, and sgdisk provides most of gdisk's functionality in
43
a more script-friendly program. Although libparted and programs that use it
44
(GNU Parted, gparted, etc.) provide the ability to handle GPT disks, they
45
have certain limitations that gdisk overcomes. Specific advantages of gdisk
50
GPT-partitioned disks, cgdisk is similarly a workalike for fdisk, and
51
sgdisk provides most of gdisk's functionality in a more script-friendly
52
program. Although libparted and programs that use it (GNU Parted, gparted,
53
etc.) provide the ability to handle GPT disks, they have certain
54
limitations that gdisk overcomes. Specific advantages of gdisk, cgdisk, and
48
57
* The ability to convert MBR-partitioned disks in-place to GPT format,
49
58
without losing data
62
72
* A user interface that's familiar to long-time users of Linux
73
fdisk and cfdisk (gdisk and cgdisk only)
65
75
* The MBR boot loader code is left alone
67
* The ability to create a hybrid MBR, which permits GPT-unaware
68
OSes to access up to three GPT partitions on the disk
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)
70
80
Of course, GPT fdisk isn't without its limitations. Most notably, it lacks
71
81
the filesystem awareness and filesystem-related features of GNU Parted. You
73
83
filesystem already in place with gdisk, for instance. There's no GUI
76
The GPT fdisk package provides two program files: the interactive text-mode
77
gdisk and the command-line-driven sgdisk. The former is intended for use in
78
manually partitioning disks or changing partitioning details; the latter is
79
intended for use in scripts to help automate tasks such as disk cloning or
80
preparing multiple disks for Linux installation.
86
The GPT fdisk package provides three program files: the interactive
87
text-mode gdisk, the curses-based interactive cgdisk, and the
88
command-line-driven sgdisk. The first two are intended for use in manually
89
partitioning disks or changing partitioning details; sgdisk is intended for
90
use in scripts to help automate tasks such as disk cloning or preparing
91
multiple disks for Linux installation.
171
182
platforms) from the compilation options. Suitable lines are present, but
172
183
commented out, in the Makefile, Makefile.mac, and Makefile.bsd files.
174
* The sgdisk program also requires the popt library and its development
175
files (headers). Most Linux distributions install popt by default, but
176
you may need to install a package called popt-dev, popt-devel, or
177
something similar to obtain the header files. Mac OS users can find a
178
version of popt for Mac OS from Drawin Ports (http://popt.darwinports.com)
179
or Fink (http://www.finkproject.org); however, you'll first need to
180
install DarwinPorts or Fink (instructions exist on the relevant projects'
181
pages). Alternatively, you can compile gdisk alone, without sgdisk; gdisk
182
doesn't require popt.
185
* The cgdisk program requires the ncurses library and its development files
186
(headers). Most Linux distributions install ncurses by default, but you
187
may need to install a package called libncurses5-dev, ncurses-devel, or
188
something similar to obtain the header files. These files were installed
189
already on my Mac OS X development system; however, they may have been
190
installed as dependencies of other programs I've installed. If you're
191
having problems installing ncurses, you can compile gdisk and/or sgdisk
192
without cgdisk by specifying only the targets you want to compile to
195
* The sgdisk program requires the popt library and its development files
196
(headers). Most Linux distributions install popt by default, but you may
197
need to install a package called popt-dev, popt-devel, or something
198
similar to obtain the header files. Mac OS users can find a version of
199
popt for Mac OS from Darwin Ports (http://popt.darwinports.com) or Fink
200
(http://www.finkproject.org); however, you'll first need to install
201
DarwinPorts or Fink (instructions exist on the relevant projects' pages).
202
Alternatively, you can compile gdisk and/or cgdisk alone, without sgdisk;
203
gdisk doesn't require popt.
184
205
When all the necessary development tools and libraries are installed, you
185
206
can uncompress the package and type "make" at the command prompt in the
188
209
compile using MinGW for Windows.) You may also need to add header (include)
189
210
directories or library directories by setting the CXXFLAGS environment
190
211
variable or by editing the Makefile. The result should be program files
191
called gdisk, sgdisk, and fixparts. Typing "make gdisk", "make sgdisk", or
192
"make fixparts" will compile only the requested programs. You can use these
193
programs in place or copy the files to a suitable directory, such as
194
/usr/local/sbin. You can copy the man pages (gdisk.8, sgdisk.8, and
195
fixparts.8) to /usr/local/man/man8 to make them available.
212
called gdisk, sgdisk, and fixparts. Typing "make gdisk", "make cgdisk",
213
"make sgdisk", or "make fixparts" will compile only the requested programs.
214
You can use these programs in place or copy the files to a suitable
215
directory, such as /usr/local/sbin. You can copy the man pages (gdisk.8,
216
cgdisk.8, sgdisk.8, and fixparts.8) to /usr/local/man/man8 to make them