blob: 3dbddfffc2f01a88d35ffd244c5ad954d4e7503e [file] [log] [blame]
Rod Smith44cda472018-07-05 09:07:58 -04001.\" Copyright 2011-2018 Roderick W. Smith (rodsmith@rodsbooks.com)
srs56943860cbe2011-09-10 20:29:53 -04002.\" May be distributed under the GNU General Public License
Rod Smith44cda472018-07-05 09:07:58 -04003.TH "CGDISK" "8" "1.0.4" "Roderick W. Smith" "GPT fdisk Manual"
srs56943860cbe2011-09-10 20:29:53 -04004.SH "NAME"
5cgdisk \- Curses-based GUID partition table (GPT) manipulator
6.SH "SYNOPSIS"
7.BI "cgdisk "
Roderick W. Smithe09ef882013-07-08 22:56:00 -04008[ \-a ]
srs56943860cbe2011-09-10 20:29:53 -04009.I device
10
11.SH "DESCRIPTION"
12
13GPT fdisk is a text\-mode family of programs for creation and manipulation
14of partition tables. The \fBcgdisk\fR member of this family employs a
15curses-based user interface for interaction using a text\-mode menuing
16system. It will automatically convert an old\-style Master Boot Record
17(MBR) partition table or BSD disklabel stored without an MBR carrier
18partition to the newer Globally Unique Identifier (GUID) Partition Table
19(GPT) format, or will load a GUID partition table. Other members of this
20program family are \fBgdisk\fR (the most feature-rich program of the group,
21with a non-curses-based interactive user interface) and \fBsgdisk\fR (which
22is driven via command-line options for use by experts or in scripts).
23FixParts is a related program for fixing a limited set of problems with MBR
24disks.
25
26For information on MBR vs. GPT, as well as GPT terminology and structure,
27see the extended GPT fdisk documentation at
28\fIhttp://www.rodsbooks.com/gdisk/\fR or consult Wikipedia.
29
30The \fBcgdisk\fR program employs a user interface similar to that of Linux's
31\fBcfdisk\fR, but \fBcgdisk\fR modifies GPT partitions. It also has the
32capability of transforming MBR partitions or BSD disklabels into GPT
33partitions. Like the original \fBcfdisk\fR program, \fBcgdisk\fR does not
34modify disk structures until you explicitly write them to disk, so if you
35make a mistake, you can exit from the program with the Quit option to leave
36your partitions unmodified.
37
38Ordinarily, \fBcgdisk\fR operates on disk device files, such as
39\fI/dev/sda\fR or \fI/dev/hda\fR under Linux, \fI/dev/disk0\fR under
40Mac OS X, or \fI/dev/ad0\fR or \fI/dev/da0\fR under FreeBSD. The program
41can also operate on disk image files, which can be either copies of whole
42disks (made with \fBdd\fR, for instance) or raw disk images used by
43emulators such as QEMU or VMWare. Note that only \fIraw\fR disk images
44are supported; \fBcgdisk\fR cannot work on compressed or other advanced
45disk image formats.
46
47Upon start, \fBcgdisk\fR attempts to identify the partition type in use on
48the disk. If it finds valid GPT data, \fBcgdisk\fR will use it. If
49\fBcgdisk\fR finds a valid MBR or BSD disklabel but no GPT data, it will
50attempt to convert the MBR or disklabel into GPT form. (BSD disklabels are
51likely to have unusable first and/or final partitions because they overlap
52with the GPT data structures, though.) Upon exiting with the 'w' option,
53\fBcgdisk\fR replaces the MBR or disklabel with a GPT. \fIThis action is
54potentially dangerous!\fR Your system may become unbootable, and partition
55type codes may become corrupted if the disk uses unrecognized type codes.
56Boot problems are particularly likely if you're multi\-booting with any
57GPT\-unaware OS. If you mistakenly launch \fBcgdisk\fR on an MBR disk, you
58can safely exit the program without making any changes by using the Quit
59option.
60
61When creating a fresh partition table, certain considerations may be in
62order:
63
64.TP
65.B *
66For data (non\-boot) disks, and for boot disks used on BIOS\-based computers
67with GRUB as the boot loader, partitions may be created in whatever order
68and in whatever sizes are desired.
69
70.TP
71.B *
72Boot disks for EFI\-based systems require an \fIEFI System
73Partition\fR (GPT fdisk internal code 0xEF00) formatted as FAT\-32.
74The recommended size of this partition is between 100 and 300 MiB.
75Boot\-related files are stored here. (Note that GNU Parted identifies
76such partitions as having the "boot flag" set.)
77
78.TP
79.B *
80The GRUB 2 boot loader for BIOS\-based systems makes use of a \fIBIOS Boot
81Partition\fR (GPT fdisk internal code 0xEF02), in which the secondary
82boot loader is stored, without the benefit of a filesystem. This partition
83can typically be quite small (roughly 32 KiB to 1 MiB), but you should
84consult your boot loader documentation for details.
85
86.TP
87.B *
88If Windows is to boot from a GPT disk, a partition of type \fIMicrosoft
89Reserved\fR (GPT fdisk
90internal code 0x0C01) is recommended. This partition should be about 128 MiB
91in size. It ordinarily follows the EFI System Partition and immediately
92precedes the Windows data partitions. (Note that old versions of GNU Parted
93create all FAT partitions as this type, which actually makes the partition
94unusable for normal file storage in both Windows and Mac OS X.)
95
96.TP
97.B *
98Some OSes' GPT utilities create some blank space (typically 128 MiB) after
99each partition. The intent is to enable future disk utilities to use this
100space. Such free space is not required of GPT disks, but creating it may
101help in future disk maintenance. You can use GPT fdisk's relative partition
102positioning option (specifying the starting sector as '+128M', for
103instance) to simplify creating such gaps.
104
105.SH "OPTIONS"
106
107.PP
108
Roderick W. Smithe09ef882013-07-08 22:56:00 -0400109Only one command-line option is accepted, aside from the device filename:
110\fI\-a\fR. This option alters the highlighting of partitions and blocks of
111free space: Instead of using ncurses, when \fI\-a\fR is used \fBcgdisk\fR
112uses a ">" symbol to the left of the selected partition or free space.
113This option is intended for use on limited display devices such as
114teletypes and screen readers.
115
srs56943860cbe2011-09-10 20:29:53 -0400116Interactions with \fBcgdisk\fR occur with its interactive text\-mode menus.
117The display is broken into two interactive parts:
118
119.TP
120.B *
121The partition display area, in which partitions and gaps between them
122(marked as "free space") are summarized.
123
124.TP
125.B *
126The option selection area, in which buttons for the main options appear.
127
128.PP
129
130In addition, the top of the display shows the program's name and version
131number, the device filename associated with the disk, and the disk's size
132in both sectors and IEEE-1541 units (GiB, TiB, and so on).
133
134You can use the following keys to move among the various options and to
135select among them:
136
137.TP
138.B up arrow
139This key moves the partition selection up by one partition.
140
141.TP
142.B down arrow
143This key moves the partition selection down by one partition.
144
145.TP
146.B Page Up
147This key moves the partition selection up by one screen.
148
149.TP
150.B Page Down
151This key moves the partition selection down by one screen.
152
153.TP
154.B right arrow
155This key moves the option selection to the right by one item.
156
157.TP
158.B left arrow
159This key moves the option selection to the left by one item.
160
161.TP
162.B Enter
163This key activates the currently selected option. You can also activate an
164option by typing the capitalized letter in the option's name on the
165keyboard, such as \fBa\fR to activate the Align option.
166
167.PP
168
169If more partitions exist than can be displayed in one screen, you can
170scroll between screens using the partition selection keys, much as in a
171text editor.
172
173Available options are as described below. (Note that \fBcgdisk\fR provides
174a much more limited set of options than its sibling \fBgdisk\fR. If you
175need to perform partition table recovery, hybrid MBR modifcation, or other
176advanced operations, you should consult the \fBgdisk\fR documentation.)
177
178.TP
179.B Align
180Change the sector alignment value. Disks with more logical sectors than
181physical sectors (such as modern Advanced Format drives), some RAID
182configurations, and many SSD devices, can suffer performance problems if
183partitions are not aligned properly for their internal data structures. On
nl6720b93e29d2018-08-12 12:43:02 +0300184new disks, GPT fdisk attempts to align partitions on 1 MiB boundaries
Roderick W. Smith8017e082015-04-24 21:39:20 -0400185(2048\-sectors on disks with 512-byte sectors) by default, which optimizes
186performance for all of these disk types. On pre\-partitioned disks, GPT
187fdisk attempts to identify the alignment value used on that disk, but will
188set 8-sector alignment on disks larger than 300 GB even if lesser alignment
189values are detected. In either case, it can be changed by using this
190option.
srs56943860cbe2011-09-10 20:29:53 -0400191
192.TP
193.B Backup
194Save partition data to a backup file. You can back up your current
195in\-memory partition table to a disk file using this option. The resulting
196file is a binary file consisting of the protective MBR, the main GPT
197header, the backup GPT header, and one copy of the partition table, in that
198order. Note that the backup is of the current in\-memory data structures, so
199if you launch the program, make changes, and then use this option, the
200backup will reflect your changes.
201
202.TP
203.B Delete
204Delete a partition. This action deletes the entry from the partition table
205but does not disturb the data within the sectors originally allocated to
206the partition on the disk. If a corresponding hybrid MBR partition exists,
207\fBgdisk\fR deletes it, as well, and expands any adjacent 0xEE (EFI GPT)
208MBR protective partition to fill the new free space.
209
210.TP
211.B Help
212Print brief descriptions of all the options.
213
214.TP
215.B Info
216Show detailed partition information. The summary information shown in the
217partition display area necessarily omits many details, such as the
218partitions' unique GUIDs and the partitions' sector-exact start and end
219points. The Info option displays this information for a single partition.
220
221.TP
222.B Load
223Load partition data from a backup file. This option is the reverse of the
224Backup option. Note that restoring partition data from anything but the
225original disk is not recommended.
226
227.TP
228.B naMe
229Change the GPT name of a partition. This name is encoded as a UTF\-16
230string, but proper entry and display of anything beyond basic ASCII values
231requires suitable locale and font support. For the most part, Linux ignores
232the partition name, but it may be important in some OSes. GPT fdisk sets a
233default name based on the partition type code. Note that the GPT partition
234name is different from the filesystem name, which is encoded in the
235filesystem's data structures. Note also that to activate this item by
236typing its alphabetic equivalent, you must use \fBM\fR, not the more
237obvious \fBN\fR, because the latter is used by the next option....
238
239.TP
240.B New
241Create a new partition. You enter a starting sector, a size, a type code,
242and a name. The start sector can be specified in absolute terms as a sector
243number or as a position measured in kibibytes (K), mebibytes (M), gibibytes
244(G), tebibytes (T), or pebibytes (P); for instance, \fI\fB40M\fR\fR
245specifies a position 40MiB from the start of the disk. You can specify
246locations relative to the start or end of the specified default range by
247preceding the number by a '+' symbol, as in \fI\fB+2G\fR\fR to specify a
248point 2GiB after the default start sector. The size value can use the K, M,
249G, T, and P suffixes, too. Pressing the Enter key with no input specifies
250the default value, which is the start of the largest available block for
251the start sector and the full available size for the size.
252
253.TP
254.B Quit
255Quit from the program \fIwithout saving your changes\fR.
256Use this option if you just wanted to view information or if you make a
257mistake and want to back out of all your changes.
258
259.TP
260.B Type
261Change a single partition's type code. You enter the type code using a
262two\-byte hexadecimal number. You may also enter a GUID directly, if you
263have one and \fBcgdisk\fR doesn't know it. If you don't know the type code
264for your partition, you can type \fBL\fR to see a list of known type codes.
Rod Smith44cda472018-07-05 09:07:58 -0400265The type code list may optionally be filtered by a search string; for
266instance, entering \fI\fBLinux\fR\fR shows only partition type codes with
267descriptions that include the string \fILinux\fR. This search is performed
268case\-sensitively.
srs56943860cbe2011-09-10 20:29:53 -0400269
270.TP
271.B Verify
272Verify disk. This option checks for a variety of problems, such as
273incorrect CRCs and mismatched main and backup data. This option does not
274automatically correct most problems, though; for that, you must use
275\fBgdisk\fR. If no problems are found, this command displays a summary of
276unallocated disk space.
277
278.TP
279.B Write
280Write data. Use this command to save your changes.
281
282.SH "BUGS"
283
Roderick W. Smith54f8fb12015-03-17 19:46:05 -0400284Known bugs and limitations include:
srs56943860cbe2011-09-10 20:29:53 -0400285
286.TP
287.B *
288The program compiles correctly only on Linux, FreeBSD, and Mac OS X. In
289theory, it should compile under Windows if the Ncurses library for Windows
290is installed, but I have not tested this capability. Linux versions for
291x86\-64 (64\-bit), x86 (32\-bit), and PowerPC (32\-bit) have been tested,
292with the x86\-64 version having seen the most testing. Under FreeBSD,
29332\-bit (x86) and 64\-bit (x86\-64) versions have been tested. Only 32\-bit
294versions for Mac OS X has been tested by the author.
295
296.TP
297.B *
298The FreeBSD version of the program can't write changes to the partition
299table to a disk when existing partitions on that disk are mounted. (The
300same problem exists with many other FreeBSD utilities, such as
301\fBgpt\fR, \fBfdisk\fR, and \fBdd\fR.) This limitation can be overcome
302by typing \fBsysctl kern.geom.debugflags=16\fR at a shell prompt.
303
304.TP
305.B *
306The program can load only up to 128 partitions (4 primary partitions and
307124 logical partitions) when converting from MBR format. This limit can
308be raised by changing the \fI#define MAX_MBR_PARTS\fR line in the
309\fIbasicmbr.h\fR source code file and recompiling; however, such a change
310will require using a larger\-than\-normal partition table. (The limit
311of 128 partitions was chosen because that number equals the 128 partitions
312supported by the most common partition table size.)
313
314.TP
315.B *
316Converting from MBR format sometimes fails because of insufficient space at
317the start or (more commonly) the end of the disk. Resizing the partition
318table (using the 's' option in the experts' menu in \fBgdisk\fR) can
319sometimes overcome this problem; however, in extreme cases it may be
320necessary to resize a partition using GNU Parted or a similar tool prior to
321conversion with GPT fdisk.
322
323.TP
324.B *
325MBR conversions work only if the disk has correct LBA partition
326descriptors. These descriptors should be present on any disk over 8 GiB in
327size or on smaller disks partitioned with any but very ancient software.
328
329.TP
330.B *
331BSD disklabel support can create first and/or last partitions that overlap
332with the GPT data structures. This can sometimes be compensated by
333adjusting the partition table size, but in extreme cases the affected
334partition(s) may need to be deleted.
335
336.TP
337.B *
338Because of the highly variable nature of BSD disklabel structures,
339conversions from this form may be unreliable \-\- partitions may be dropped,
340converted in a way that creates overlaps with other partitions, or
341converted with incorrect start or end values. Use this feature with
342caution!
343
344.TP
345.B *
346Booting after converting an MBR or BSD disklabel disk is likely to be
347disrupted. Sometimes re\-installing a boot loader will fix the problem, but
348other times you may need to switch boot loaders. Except on EFI\-based
349platforms, Windows through at least Windows 7 doesn't support booting from
350GPT disks. Creating a hybrid MBR (using the 'h' option on the recovery &
351transformation menu in \fBgdisk\fR) or abandoning GPT in favor of MBR may
352be your only options in this case.
353
354.TP
355.B *
356The \fBcgdisk\fR Verify function and the partition type listing obtainable
357by typing \fIL\fR in the Type function (or when specifying a partition type
358while creating a new partition) both currently exit ncurses mode. This
359limitation is a minor cosmetic blemish that does not affect functionality.
360
361.SH "AUTHORS"
362Primary author: Roderick W. Smith (rodsmith@rodsbooks.com)
363
364Contributors:
365
366* Yves Blusseau (1otnwmz02@sneakemail.com)
367
368* David Hubbard (david.c.hubbard@gmail.com)
369
370* Justin Maggard (justin.maggard@netgear.com)
371
Roderick W. Smith54f8fb12015-03-17 19:46:05 -0400372* Dwight Schauer (dschauer@gmail.com)
srs56943860cbe2011-09-10 20:29:53 -0400373
374* Florian Zumbiehl (florz@florz.de)
375
376
377.SH "SEE ALSO"
nl6720b93e29d2018-08-12 12:43:02 +0300378.BR cfdisk (8),
379.BR fdisk (8),
380.BR gdisk (8),
381.BR mkfs (8),
382.BR parted (8),
383.BR sfdisk (8),
384.BR sgdisk (8),
385.BR fixparts (8).
srs56943860cbe2011-09-10 20:29:53 -0400386
387\fIhttp://en.wikipedia.org/wiki/GUID_Partition_Table\fR
388
389\fIhttp://developer.apple.com/technotes/tn2006/tn2166.html\fR
390
391\fIhttp://www.rodsbooks.com/gdisk/\fR
392
393.SH "AVAILABILITY"
394The \fBcgdisk\fR command is part of the \fIGPT fdisk\fR package and is
395available from Rod Smith.