blob: dfdaa2c3b119459e8679f30a92e9442b4f99e6c5 [file] [log] [blame]
Rod Smith44cda472018-07-05 09:07:58 -04001.\" Copyright 2011-2018 Roderick W. Smith (rodsmith@rodsbooks.com)
srs5694e7b4ff92009-08-18 13:16:10 -04002.\" May be distributed under the GNU General Public License
Rod Smith44cda472018-07-05 09:07:58 -04003.TH "GDISK" "8" "1.0.4" "Roderick W. Smith" "GPT fdisk Manual"
srs5694978041c2009-09-21 20:51:47 -04004.SH "NAME"
srs56940a697312010-01-28 21:10:52 -05005gdisk \- Interactive GUID partition table (GPT) manipulator
srs5694978041c2009-09-21 20:51:47 -04006.SH "SYNOPSIS"
srs5694e7b4ff92009-08-18 13:16:10 -04007.BI "gdisk "
8[ \-l ]
9.I device
srs5694221e0872009-08-29 15:00:31 -040010
srs5694978041c2009-09-21 20:51:47 -040011.SH "DESCRIPTION"
srs5694978041c2009-09-21 20:51:47 -040012GPT fdisk (aka \fBgdisk\fR) is a text\-mode menu\-driven program for
13creation and manipulation of partition tables. It will automatically
14convert an old\-style Master Boot Record (MBR) partition table or BSD
15disklabel stored without an MBR carrier partition to the newer Globally
srs56948bb78762009-11-24 15:43:49 -050016Unique Identifier (GUID) Partition Table (GPT) format, or will load a GUID
srs5694978041c2009-09-21 20:51:47 -040017partition table. When used with the \fI\-l\fR command\-line option, the
18program displays the current partition table and then exits.
srs5694e7b4ff92009-08-18 13:16:10 -040019
srs5694978041c2009-09-21 20:51:47 -040020GPT fdisk operates mainly on the GPT headers and partition tables; however,
srs5694e7b4ff92009-08-18 13:16:10 -040021it can and will generate a fresh protective MBR, when required. (Any boot
22loader code in the protective MBR will not be disturbed.) If you've created
23an unusual protective MBR, such as a hybrid MBR created by
srs5694978041c2009-09-21 20:51:47 -040024\fBgptsync\fR or \fBgdisk\fR's own hybrid MBR creation feature,
srs5694e7b4ff92009-08-18 13:16:10 -040025this should not be disturbed by most ordinary actions. Some advanced data
26recovery options require you to understand the distinctions between the
27main and backup data, as well as between the GPT headers and the partition
srs5694978041c2009-09-21 20:51:47 -040028tables. For information on MBR vs. GPT, as well as GPT terminology and
29structure, see the extended \fBgdisk\fR documentation at
30\fIhttp://www.rodsbooks.com/gdisk/\fR or consult Wikipedia.
srs5694e7b4ff92009-08-18 13:16:10 -040031
srs5694978041c2009-09-21 20:51:47 -040032The \fBgdisk\fR program employs a user interface similar to that of Linux's
srs56948bb78762009-11-24 15:43:49 -050033\fBfdisk\fR, but \fBgdisk\fR modifies GPT partitions. It also has the
34capability of transforming MBR partitions or BSD disklabels into GPT
35partitions. Like the original \fBfdisk\fR program, \fBgdisk\fR does not
36modify disk structures until you explicitly write them to disk, so if you
srs56946aae2a92011-06-10 01:16:51 -040037make a mistake, you can exit from the program with the 'q' option to leave
38your partitions unmodified.
srs5694e7b4ff92009-08-18 13:16:10 -040039
srs5694978041c2009-09-21 20:51:47 -040040Ordinarily, \fBgdisk\fR operates on disk device files, such as
41\fI/dev/sda\fR or \fI/dev/hda\fR under Linux, \fI/dev/disk0\fR under
42Mac OS X, or \fI/dev/ad0\fR or \fI/dev/da0\fR under FreeBSD. The program
43can also operate on disk image files, which can be either copies of whole
44disks (made with \fBdd\fR, for instance) or raw disk images used by
45emulators such as QEMU or VMWare. Note that only \fIraw\fR disk images
46are supported; \fBgdisk\fR cannot work on compressed or other advanced
47disk image formats.
srs5694e7b4ff92009-08-18 13:16:10 -040048
49The MBR partitioning system uses a combination of cylinder/head/sector
50(CHS) addressing and logical block addressing (LBA). The former is klunky
srs5694978041c2009-09-21 20:51:47 -040051and limiting. GPT drops CHS addressing and uses 64\-bit LBA mode
srs5694e7b4ff92009-08-18 13:16:10 -040052exclusively. Thus, GPT data structures, and therefore
srs5694978041c2009-09-21 20:51:47 -040053\fBgdisk\fR, do not need to deal with CHS geometries and all the problems
54they create. Users of \fBfdisk\fR will note that \fBgdisk\fR
srs5694e7b4ff92009-08-18 13:16:10 -040055lacks the options and limitations associated with CHS geometries.
56
srs5694978041c2009-09-21 20:51:47 -040057For best results, you should use an OS\-specific partition table
58program whenever possible. For example, you should make Mac OS X
59partitions with the Mac OS X Disk Utility program and Linux partitions
60with the Linux \fBgdisk\fR or GNU Parted program.
srs5694221e0872009-08-29 15:00:31 -040061
srs56948bb78762009-11-24 15:43:49 -050062Upon start, \fBgdisk\fR attempts to identify the partition type in use on
63the disk. If it finds valid GPT data, \fBgdisk\fR will use it. If
64\fBgdisk\fR finds a valid MBR or BSD disklabel but no GPT data, it will
65attempt to convert the MBR or disklabel into GPT form. (BSD disklabels are
66likely to have unusable first and/or final partitions because they overlap
67with the GPT data structures, though.) GPT fdisk can identify, but not use
68data in, Apple Partition Map (APM) disks, which are used on 680x0\- and
69PowerPC\-based Macintoshes. Upon exiting with the 'w' option, \fBgdisk\fR
70replaces the MBR or disklabel with a GPT. \fIThis action is potentially
71dangerous!\fR Your system may become unbootable, and partition type codes
72may become corrupted if the disk uses unrecognized type codes. Boot
73problems are particularly likely if you're multi\-booting with any
74GPT\-unaware OS. If you mistakenly launch \fBgdisk\fR on an MBR disk, you
75can safely exit the program without making any changes by using the 'q'
76option.
srs5694e7b4ff92009-08-18 13:16:10 -040077
srs5694978041c2009-09-21 20:51:47 -040078The MBR\-to\-GPT conversion will leave at least one gap in the partition
srs5694e7b4ff92009-08-18 13:16:10 -040079numbering if the original MBR used logical partitions. These gaps are
80harmless, but you can eliminate them by using the 's' option, if you like.
srs5694978041c2009-09-21 20:51:47 -040081(Doing this may require you to update your \fI/etc/fstab\fR file.)
srs5694e7b4ff92009-08-18 13:16:10 -040082
83When creating a fresh partition table, certain considerations may be in
84order:
85
srs5694978041c2009-09-21 20:51:47 -040086.TP
srs5694e7b4ff92009-08-18 13:16:10 -040087.B *
srs5694978041c2009-09-21 20:51:47 -040088For data (non\-boot) disks, and for boot disks used on BIOS\-based computers
srs5694e7b4ff92009-08-18 13:16:10 -040089with GRUB as the boot loader, partitions may be created in whatever order
90and in whatever sizes are desired.
91
srs5694978041c2009-09-21 20:51:47 -040092.TP
srs5694e7b4ff92009-08-18 13:16:10 -040093.B *
Rod Smithdafd2d12017-02-12 10:57:04 -050094Boot disks for EFI\-based systems require an \fIEFI System Partition\fR
95(\fBgdisk\fR internal code 0xEF00) formatted as FAT\-32. I recommended
96making this partition 550 MiB. (Smaller ESPs are common, but some EFIs have
97flaky FAT drivers that necessitate a larger partition for reliable
98operation.) Boot\-related files are stored here. (Note that GNU Parted
99identifies such partitions as having the "boot flag" set.)
srs5694e7b4ff92009-08-18 13:16:10 -0400100
srs5694978041c2009-09-21 20:51:47 -0400101.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400102.B *
srs5694978041c2009-09-21 20:51:47 -0400103Some boot loaders for BIOS\-based systems make use of a \fIBIOS Boot
srs56948bb78762009-11-24 15:43:49 -0500104Partition\fR (\fBgdisk\fR internal code 0xEF02), in which the secondary
srs569455d92612010-03-07 22:16:07 -0500105boot loader is stored, possibly without the benefit of a filesystem. (GRUB2
106may optionally use such a partition.) This partition can typically be quite
Rod Smithdafd2d12017-02-12 10:57:04 -0500107small (roughly 32 to 200 KiB, although 1 MiB is more common in practice),
108but you should consult your boot loader documentation for details.
srs56942a9f5da2009-08-26 00:48:01 -0400109
srs5694978041c2009-09-21 20:51:47 -0400110.TP
srs56942a9f5da2009-08-26 00:48:01 -0400111.B *
srs5694978041c2009-09-21 20:51:47 -0400112If Windows is to boot from a GPT disk, a partition of type \fIMicrosoft
113Reserved\fR (\fBgdisk\fR
srs5694e7b4ff92009-08-18 13:16:10 -0400114internal code 0x0C01) is recommended. This partition should be about 128 MiB
115in size. It ordinarily follows the EFI System Partition and immediately
srs56948a4ddfc2010-03-21 19:05:49 -0400116precedes the Windows data partitions. (Note that old versions of GNU Parted
117create all FAT partitions as this type, which actually makes the partition
118unusable for normal file storage in both Windows and Mac OS X.)
srs5694e7b4ff92009-08-18 13:16:10 -0400119
srs5694978041c2009-09-21 20:51:47 -0400120.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400121.B *
122Some OSes' GPT utilities create some blank space (typically 128 MiB) after
123each partition. The intent is to enable future disk utilities to use this
124space. Such free space is not required of GPT disks, but creating it may
srs5694e4ac11e2009-08-31 10:13:04 -0400125help in future disk maintenance. You can use GPT fdisk's relative partition
126positioning option (specifying the starting sector as '+128M', for
127instance) to simplify creating such gaps.
srs5694e7b4ff92009-08-18 13:16:10 -0400128
srs5694978041c2009-09-21 20:51:47 -0400129.SH "OPTIONS"
130.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400131.B \-l
Roderick W. Smithaf39cb42013-08-06 15:23:46 -0400132List the partition table for the specified device and then exits.
srs5694978041c2009-09-21 20:51:47 -0400133.PP
srs5694e7b4ff92009-08-18 13:16:10 -0400134
srs5694978041c2009-09-21 20:51:47 -0400135Most interactions with \fBgdisk\fR
136occur with its interactive text\-mode menus. Three menus exist: the main
137menu, the recovery & transformation menu, and the experts' menu. The main
138menu provides the functions that are most likely to be useful for typical partitioning tasks, such as creating and deleting partitions, changing partition type codes, and so on. Specific functions are:
srs5694e7b4ff92009-08-18 13:16:10 -0400139
srs5694978041c2009-09-21 20:51:47 -0400140.TP
srs5694221e0872009-08-29 15:00:31 -0400141.B b
srs56948bb78762009-11-24 15:43:49 -0500142Save partition data to a backup file. You can back up your current
srs569455d92612010-03-07 22:16:07 -0500143in\-memory partition table to a disk file using this option. The resulting
srs56948bb78762009-11-24 15:43:49 -0500144file is a binary file consisting of the protective MBR, the main GPT
145header, the backup GPT header, and one copy of the partition table, in that
srs569455d92612010-03-07 22:16:07 -0500146order. Note that the backup is of the current in\-memory data structures, so
srs56948bb78762009-11-24 15:43:49 -0500147if you launch the program, make changes, and then use this option, the
148backup will reflect your changes. Note also that the restore option is on
149the recovery & transformation menu; the backup option is on the main menu
150to encourage its use.
srs5694221e0872009-08-29 15:00:31 -0400151
srs5694978041c2009-09-21 20:51:47 -0400152
153.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400154.B c
srs5694978041c2009-09-21 20:51:47 -0400155Change the GPT name of a partition. This name is encoded as a UTF\-16
srs5694699941e2011-03-21 21:33:57 -0400156string, but proper entry and display of anything beyond basic ASCII values
157requires suitable locale and font support. For the most part, Linux ignores
158the partition name, but it may be important in some OSes. GPT fdisk sets a
159default name based on the partition type code. Note that the GPT partition
160name is different from the filesystem name, which is encoded in the
161filesystem's data structures.
srs5694e7b4ff92009-08-18 13:16:10 -0400162
srs5694978041c2009-09-21 20:51:47 -0400163.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400164.B d
165Delete a partition. This action deletes the entry from the partition table
166but does not disturb the data within the sectors originally allocated to
srs5694e4ac11e2009-08-31 10:13:04 -0400167the partition on the disk. If a corresponding hybrid MBR partition exists,
srs5694978041c2009-09-21 20:51:47 -0400168\fBgdisk\fR deletes it, as well, and expands any adjacent 0xEE (EFI GPT)
169MBR protective partition to fill the new free space.
srs5694e7b4ff92009-08-18 13:16:10 -0400170
srs5694978041c2009-09-21 20:51:47 -0400171.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400172.B i
173Show detailed partition information. The summary information produced by
174the 'p' command necessarily omits many details, such as the partition's
srs5694978041c2009-09-21 20:51:47 -0400175unique GUID and the translation of \fBgdisk\fR's
srs5694e7b4ff92009-08-18 13:16:10 -0400176internal partition type code to a plain type name. The 'i' option
177displays this information for a single partition.
178
srs5694978041c2009-09-21 20:51:47 -0400179.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400180.B l
srs569400b6d7a2011-06-26 22:40:06 -0400181Display a summary of partition types. GPT uses a GUID to identify partition
182types for particular OSes and purposes. For ease of data entry, \fBgdisk\fR
183compresses these into two\-byte (four\-digit hexadecimal) values that are
184related to their equivalent MBR codes. Specifically, the MBR code is
185multiplied by hexadecimal 0x0100. For instance, the code for Linux swap
186space in MBR is 0x82, and it's 0x8200 in \fBgdisk\fR. A one\-to\-one
187correspondence is impossible, though. Most notably, the codes for all
Rod Smith44cda472018-07-05 09:07:58 -0400188varieties of FAT and NTFS partition correspond to a single GPT code (entered
189as 0x0700 in \fBgdisk\fR). Some OSes use a single MBR code but employ many
190more codes in GPT. For these, \fBgdisk\fR adds code numbers sequentially,
191such as 0xa500 for a FreeBSD disklabel, 0xa501 for FreeBSD boot, 0xa502 for
192FreeBSD swap, and so on. Note that these two\-byte codes are unique to
193\fBgdisk\fR. The type code list may optionally be filtered by a search
194string; for instance, entering \fI\fBLinux\fR\fR shows only partition type
195codes with descriptions that include the string \fILinux\fR. This search is
196performed case\-sensitively.
srs5694e7b4ff92009-08-18 13:16:10 -0400197
srs5694978041c2009-09-21 20:51:47 -0400198.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400199.B n
Rod Smithdafd2d12017-02-12 10:57:04 -0500200Create a new partition. This command is modeled after the equivalent
srs5694978041c2009-09-21 20:51:47 -0400201\fBfdisk\fR option, although some differences exist. You enter a partition
202number, starting sector, and an ending sector. Both start and end sectors
srs56948bb78762009-11-24 15:43:49 -0500203can be specified in absolute terms as sector numbers or as positions
srs56940873e9d2010-10-07 13:00:45 -0400204measured in kibibytes (K), mebibytes (M), gibibytes (G), tebibytes (T), or
205pebibytes (P); for instance, \fI\fB40M\fR\fR specifies a position 40MiB
206from the start of the disk. You can specify locations relative to the start
srs56944307ef22012-05-30 12:30:48 -0400207or end of the specified default range by preceding the number by a '+' or '\-'
208symbol, as in \fI\fB+2G\fR\fR to specify a point 2GiB after the
srs56940873e9d2010-10-07 13:00:45 -0400209default start sector, or \fI\fB\-200M\fR\fR to specify a point 200MiB
210before the last available sector. Pressing the Enter key with no input
211specifies the default value, which is the start of the largest available
212block for the start sector and the end of the same block for the end
213sector.
srs5694e7b4ff92009-08-18 13:16:10 -0400214
srs5694978041c2009-09-21 20:51:47 -0400215.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400216.B o
217Clear out all partition data. This includes GPT header data,
srs56948a4ddfc2010-03-21 19:05:49 -0400218all partition definitions, and the protective MBR. The sector alignment
nl6720b93e29d2018-08-12 12:43:02 +0300219is reset to the default (1 MiB, or 2048 sectors on a disk with 512-byte
Roderick W. Smith8017e082015-04-24 21:39:20 -0400220sectors).
srs5694e7b4ff92009-08-18 13:16:10 -0400221
srs5694978041c2009-09-21 20:51:47 -0400222.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400223.B p
224Display basic partition summary data. This includes partition
225numbers, starting and ending sector numbers, partition sizes,
srs5694978041c2009-09-21 20:51:47 -0400226\fBgdisk\fR's partition types codes, and partition names. For
227additional information, use the 'i' command.
srs5694e7b4ff92009-08-18 13:16:10 -0400228
srs5694978041c2009-09-21 20:51:47 -0400229.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400230.B q
srs5694978041c2009-09-21 20:51:47 -0400231Quit from the program \fIwithout saving your changes\fR.
srs56942a9f5da2009-08-26 00:48:01 -0400232Use this option if you just wanted to view information or if you make a
233mistake and want to back out of all your changes.
srs5694e7b4ff92009-08-18 13:16:10 -0400234
srs5694978041c2009-09-21 20:51:47 -0400235.TP
236.B r
237Enter the recovery & transformation menu. This menu includes emergency
238recovery options (to fix damaged GPT data structures) and options to
239transform to or from other partitioning systems, including creating
240hybrid MBRs.
241
242.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400243.B s
244Sort partition entries. GPT partition numbers need not match the order of
245partitions on the disk. If you want them to match, you can use this option.
srs56948bb78762009-11-24 15:43:49 -0500246Note that some partitioning utilities sort partitions whenever they make
247changes. Such changes will be reflected in your device filenames, so you
248may need to edit \fI/etc/fstab\fR if you use this option.
srs5694e7b4ff92009-08-18 13:16:10 -0400249
srs5694978041c2009-09-21 20:51:47 -0400250.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400251.B t
252Change a single partition's type code. You enter the type code using a
srs5694978041c2009-09-21 20:51:47 -0400253two\-byte hexadecimal number, as described earlier. You may also enter a
254GUID directly, if you have one and \fBgdisk\fR doesn't know it.
srs5694e7b4ff92009-08-18 13:16:10 -0400255
srs5694978041c2009-09-21 20:51:47 -0400256.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400257.B v
258Verify disk. This option checks for a variety of problems, such as
259incorrect CRCs and mismatched main and backup data. This option does not
srs5694978041c2009-09-21 20:51:47 -0400260automatically correct most problems, though; for that, you must use
261options on the recovery & transformation menu. If no problems are found,
262this command displays a summary of unallocated disk space.
srs5694e7b4ff92009-08-18 13:16:10 -0400263
srs5694978041c2009-09-21 20:51:47 -0400264.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400265.B w
266Write data. Use this command to save your changes.
267
srs5694978041c2009-09-21 20:51:47 -0400268.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400269.B x
270Enter the experts' menu. Using this option provides access to features you
271can use to get into even more trouble than the main menu allows.
srs5694978041c2009-09-21 20:51:47 -0400272.PP
srs5694e7b4ff92009-08-18 13:16:10 -0400273
srs5694978041c2009-09-21 20:51:47 -0400274.TP
275.B ?
276Print the menu. Type this command (or any other unrecognized command) to
277see a summary of available options.
srs5694e7b4ff92009-08-18 13:16:10 -0400278
srs5694978041c2009-09-21 20:51:47 -0400279.PP
280The second \fBgdisk\fR menu is the recovery & transformation menu, which
281provides access to data recovery options and features related to the
282transformation of partitions between partitioning schemes (converting
283BSD disklabels into GPT partitions or creating hybrid MBRs, for instance).
284A few options on this menu duplicate functionality on the main
285menu, for the sake of convenience. The options on this menu are:
286
287.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400288.B b
srs5694978041c2009-09-21 20:51:47 -0400289Rebuild GPT header from backup. You can use the backup GPT header to
srs5694e7b4ff92009-08-18 13:16:10 -0400290rebuild the main GPT header with this option. It's likely to be useful if
291your main GPT header was damaged or destroyed (say, by sloppy use of
srs5694978041c2009-09-21 20:51:47 -0400292\fBdd\fR).
293
294.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400295.B c
srs5694978041c2009-09-21 20:51:47 -0400296Load backup partition table. Ordinarily, \fBgdisk\fR
srs5694e7b4ff92009-08-18 13:16:10 -0400297uses only the main partition table (although the backup's integrity is
298checked when you launch the program). If the main partition table has been
299damaged, you can use this option to load the backup from disk and use it
300instead. Note that this will almost certainly produce no or strange
301partition entries if you've just converted an MBR disk to GPT format, since
302there will be no backup partition table on disk.
303
srs5694978041c2009-09-21 20:51:47 -0400304.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400305.B d
306Use main GPT header and rebuild the backup. This option is likely to be
307useful if the backup GPT header has been damaged or destroyed.
srs5694c0ca8f82009-08-20 21:35:25 -0400308
srs5694978041c2009-09-21 20:51:47 -0400309.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400310.B e
311Load main partition table. This option reloads the main partition table
312from disk. It's only likely to be useful if you've tried to use the backup
313partition table (via 'c') but it's in worse shape then the main partition
314table.
srs5694c0ca8f82009-08-20 21:35:25 -0400315
srs5694978041c2009-09-21 20:51:47 -0400316.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400317.B f
srs5694978041c2009-09-21 20:51:47 -0400318Load MBR and build fresh GPT from it. Use this option if your GPT is corrupt
319or conflicts with the MBR and you want to use the MBR as the basis for a new
320set of GPT partitions.
321
322.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400323.B g
srs569455d92612010-03-07 22:16:07 -0500324Convert GPT into MBR and exit. This option converts as many partitions as possible
srs5694978041c2009-09-21 20:51:47 -0400325into MBR form, destroys the GPT data structures, saves the new MBR, and exits.
326Use this option if you've tried GPT and find that MBR works better for you.
srs569455d92612010-03-07 22:16:07 -0500327Note that this function generates up to four primary MBR partitions or three
328primary partitions and as many logical partitions as can be generated. Each
329logical partition requires at least one unallocated block immediately before
330its first block. Therefore, it may be possible to convert a maximum of four
331partitions on disks with tightly\-packed partitions; however, if free space was
332inserted between partitions when they were created, and if the disk is under
3332 TiB in size, it should be possible to convert all the partitions to MBR form.
334See also the 'h' option.
srs5694c0ca8f82009-08-20 21:35:25 -0400335
srs5694978041c2009-09-21 20:51:47 -0400336.TP
srs5694c0ca8f82009-08-20 21:35:25 -0400337.B h
srs5694978041c2009-09-21 20:51:47 -0400338Create a hybrid MBR. This is an ugly workaround that enables GPT\-unaware
339OSes, or those that can't boot from a GPT disk, to access up to three of
srs5694c0ca8f82009-08-20 21:35:25 -0400340the partitions on the disk by creating MBR entries for them. Note that
srs5694978041c2009-09-21 20:51:47 -0400341these hybrid MBR entries can easily go out of sync with the GPT entries,
342particularly when hybrid\-unaware GPT utilities are used to edit the disk.
Roderick W. Smithd28495e2014-03-02 11:37:20 -0500343Thus, you may need to re\-create the hybrid MBR if you use such tools. Unlike
srs569455d92612010-03-07 22:16:07 -0500344the 'g' option, this option does not support converting any partitions into
345MBR logical partitions.
srs5694c0ca8f82009-08-20 21:35:25 -0400346
srs5694978041c2009-09-21 20:51:47 -0400347.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400348.B i
349Show detailed partition information. This option is identical to the 'i'
350option on the main menu.
srs5694978041c2009-09-21 20:51:47 -0400351
352.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400353.B l
srs5694978041c2009-09-21 20:51:47 -0400354Load partition data from a backup file. This option is the reverse of the 'b'
355option on the main menu. Note that restoring partition data from anything
356but the original disk is not recommended.
357
358.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400359.B m
srs5694978041c2009-09-21 20:51:47 -0400360Return to the main menu. This option enables you to enter main\-menu commands.
361
362.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400363.B o
364Print protective MBR data. You can see a summary of the protective MBR's
365partitions with this option. This may enable you to spot glaring problems
366or help identify the partitions in a hybrid MBR.
srs5694978041c2009-09-21 20:51:47 -0400367
368.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400369.B p
370Print the partition table. This option is identical to the 'p' option in
371the main menu.
srs5694978041c2009-09-21 20:51:47 -0400372
373.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400374.B q
375Quit without saving changes. This option is identical to the 'q' option in
376the main menu.
srs56942a9f5da2009-08-26 00:48:01 -0400377
srs5694978041c2009-09-21 20:51:47 -0400378.TP
379.B t
380Transform BSD partitions into GPT partitions. This option works on BSD
381disklabels held within GPT (or converted MBR) partitions. Converted
382partitions' type codes are likely to need manual adjustment. \fBgdisk\fR
383will attempt to convert BSD disklabels stored on the main disk when
384launched, but this conversion is likely to produce first and/or last
385partitions that are unusable. The many BSD variants means that the
386probability of \fBgdisk\fR being unable to convert a BSD disklabel is
387high compared to the likelihood of problems with an MBR conversion.
388
389.TP
390.B v
391Verify disk. This option is identical to the 'v' option in the main menu.
392
393.TP
394.B w
395Write table to disk and exit. This option is identical to the 'w' option in
396the main menu.
397
398.TP
399.B x
400Enter the experts' menu. This option is identical to the 'x' option in the
401main menu.
402
403.TP
404.B ?
405Print the menu. This option (or any unrecognized entry) displays a summary
406of the menu options.
407
408.PP
409The third \fBgdisk\fR menu is the experts' menu. This menu provides advanced
410options that aren't closely related to recovery or transformation between
411partitioning systems. Its options are:
412
413.TP
414.B a
415Set attributes. GPT provides a 64\-bit attributes field that can be used to
416set features for each partition. \fBgdisk\fR supports four attributes:
417\fIsystem partition\fR, \fIread\-only\fR, \fIhidden\fR, and
418\fIdo not automount\fR. You can set other attributes, but their numbers
419aren't translated into anything useful. In practice, most OSes seem to
420ignore these attributes.
421
422.TP
423.B c
424Change partition GUID. You can enter a custom unique GUID for a partition
425using this option. (Note this refers to the GUID that uniquely identifies a
426partition, not to its type code, which you can change with the 't' main\-menu
427option.) Ordinarily, \fBgdisk\fR assigns this number randomly; however,
428you might want to adjust the number manually if you've wound up with the
429same GUID on two partitions because of buggy GUID assignments (hopefully
430not in \fBgdisk\fR) or sheer incredible coincidence.
431
srs569455d92612010-03-07 22:16:07 -0500432.TP
srs56941d1448a2009-12-31 21:20:19 -0500433.B d
srs56948a4ddfc2010-03-21 19:05:49 -0400434Display the sector alignment value. See the
435description of the 'l' option for more details.
srs56941d1448a2009-12-31 21:20:19 -0500436
srs569455d92612010-03-07 22:16:07 -0500437.TP
srs56948bb78762009-11-24 15:43:49 -0500438.B e
srs56941d1448a2009-12-31 21:20:19 -0500439Move backup GPT data structures to the end of the disk. Use this command if
440you've added disks to a RAID array, thus creating a virtual disk with space
441that follows the backup GPT data structures. This command moves the backup
442GPT data structures to the end of the disk, where they belong.
srs56948bb78762009-11-24 15:43:49 -0500443
srs56949ba54212010-05-18 23:24:02 -0400444.TP
445.B f
446Randomize the disk's GUID and all partitions' unique GUIDs (but not their
447partition type code GUIDs). This function may be used after cloning a disk
448with another utility in order to render all GUIDs once again unique.
449
srs5694978041c2009-09-21 20:51:47 -0400450.TP
451.B g
452Change disk GUID. Each disk has a unique GUID code, which \fBgdisk\fR
453assigns randomly upon creation of the GPT data structures. You can generate
454a fresh random GUID or enter one manually with this option.
455
srs56949ba54212010-05-18 23:24:02 -0400456.TP
457.B h
458Recompute CHS values in protective or hybrid MBR. This option can sometimes
459help if a disk utility, OS, or BIOS doesn't like the CHS values used by the
460partitions in the protective or hybrid MBR. In particular, the GPT
461specification requires a CHS value of 0xFFFFFF for over-8GiB partitions,
462but this value is technically illegal by the usual standards. Some BIOSes
463hang if they encounter this value. This option will recompute a more normal
464CHS value -- 0xFEFFFF for over-8GiB partitions, enabling these BIOSes to
465boot.
466
srs5694978041c2009-09-21 20:51:47 -0400467.TP
468.B i
469Show detailed partition information. This option is identical to the 'i'
470option on the main menu.
471
Rod Smith503e9ad2017-07-21 21:48:13 -0400472.TP
473.B j
474Adjust the location of the main partition table. This value is normally 2,
475but it may need to be increased in some cases, such as when a
476system\-on\-chip (SoC) is hard\-coded to read boot code from sector 2. I
477recommend against adjusting this value unless doing so is absolutely
478necessary.
479
srs569455d92612010-03-07 22:16:07 -0500480.TP
srs56941d1448a2009-12-31 21:20:19 -0500481.B l
srs56948a4ddfc2010-03-21 19:05:49 -0400482Change the sector alignment value. Disks with more logical sectors per
srs5694a17fe692011-09-10 20:30:20 -0400483physical sectors (such as modern Advanced Format drives), some RAID
484configurations, and many SSD devices, can suffer performance problems if
485partitions are not aligned properly for their internal data structures. On
nl6720b93e29d2018-08-12 12:43:02 +0300486new disks, GPT fdisk attempts to align partitions on 1 MiB boundaries
Roderick W. Smith8017e082015-04-24 21:39:20 -0400487(2048\-sectors on disks with 512-byte sectors) by default, which optimizes
488performance for all of these disk types. On pre\-partitioned disks, GPT
489fdisk attempts to identify the alignment value used on that disk, but will
490set 8-sector alignment on disks larger than 300 GB even if lesser alignment
491values are detected. In either case, it can be changed by using this
492option.
srs56941d1448a2009-12-31 21:20:19 -0500493
srs5694978041c2009-09-21 20:51:47 -0400494.TP
495.B m
496Return to the main menu. This option enables you to enter main\-menu commands.
497
498.TP
499.B n
500Create a new protective MBR. Use this option if the current protective MBR
501is damaged in a way that \fBgdisk\fR doesn't automatically detect and
502correct, or if you want to convert a hybrid MBR into a "pure" GPT with a
503conventional protective MBR.
504
505.TP
506.B o
507Print protective MBR data. You can see a summary of the protective MBR's
508partitions with this option. This may enable you to spot glaring problems
509or help identify the partitions in a hybrid MBR.
510
511.TP
512.B p
513Print the partition table. This option is identical to the 'p' option in
514the main menu.
515
516.TP
517.B q
518Quit without saving changes. This option is identical to the 'q' option in
519the main menu.
520
521.TP
522.B r
523Enter the recovery & transformations menu. This option is identical to
524the 'r' option on the main menu.
525
526.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400527.B s
srs56942a9f5da2009-08-26 00:48:01 -0400528Resize partition table. The default partition table size is 128 entries.
529Officially, sizes of less than 16KB (128 entries, given the normal entry
530size) are unsupported by the GPT specification; however, in practice they
531seem to work, and can sometimes be useful in converting MBR disks. Larger
532sizes also work fine. OSes may impose their own limits on the number of
533partitions, though.
534
srs569455d92612010-03-07 22:16:07 -0500535.TP
srs569408bb0da2010-02-19 17:19:55 -0500536.B t
537Swap two partitions' entries in the partition table. One partition may be
538empty. For instance, if partitions 1\-4 are defined, transposing 1 and 5
539results in a table with partitions numbered from 2\-5. Transposing
540partitions in this way has no effect on their disk space allocation; it
541only alters their order in the partition table.
542
srs56949ddc14b2010-08-22 22:44:42 -0400543.TP
544.B u
545Replicate the current device's partition table on another device. You will
546be prompted to type the new device's filename. After the write operation
547completes, you can continue editing the original device's partition table.
548Note that the replicated partition table is an exact copy, including all
549GUIDs; if the device should have its own unique GUIDs, you should use the
550\fBf\fR option on the new disk.
551
srs5694978041c2009-09-21 20:51:47 -0400552.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400553.B v
554Verify disk. This option is identical to the 'v' option in the main menu.
srs5694c0ca8f82009-08-20 21:35:25 -0400555
srs5694978041c2009-09-21 20:51:47 -0400556.TP
srs5694c0ca8f82009-08-20 21:35:25 -0400557.B z
srs5694978041c2009-09-21 20:51:47 -0400558Zap (destroy) the GPT data structures and exit. Use this option if you want to
559repartition a GPT disk using \fBfdisk\fR or some other GPT\-unaware program.
srs5694c0ca8f82009-08-20 21:35:25 -0400560You'll be given the choice of preserving the existing MBR, in case it's a
srs5694978041c2009-09-21 20:51:47 -0400561hybrid MBR with salvageable partitions or if you've already created new MBR
562partitions and want to erase the remnants of your GPT partitions. \fIIf you've
563already created new MBR partitions, it's conceivable that this option will
564damage the first and/or last MBR partitions!\fR Such an event is unlikely, but
565could occur if your new MBR partitions overlap the old GPT data structures.
srs5694c0ca8f82009-08-20 21:35:25 -0400566
srs5694978041c2009-09-21 20:51:47 -0400567.TP
568.B ?
569Print the menu. This option (or any unrecognized entry) displays a summary
570of the menu options.
srs5694e7b4ff92009-08-18 13:16:10 -0400571
srs5694978041c2009-09-21 20:51:47 -0400572.PP
srs5694e7b4ff92009-08-18 13:16:10 -0400573In many cases, you can press the Enter key to select a default option when
srs5694978041c2009-09-21 20:51:47 -0400574entering data. When only one option is possible, \fBgdisk\fR
srs5694e7b4ff92009-08-18 13:16:10 -0400575usually bypasses the prompt entirely.
576
srs5694978041c2009-09-21 20:51:47 -0400577.SH "BUGS"
Roderick W. Smith54f8fb12015-03-17 19:46:05 -0400578Known bugs and limitations include:
srs5694e7b4ff92009-08-18 13:16:10 -0400579
srs5694978041c2009-09-21 20:51:47 -0400580.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400581.B *
srs569455d92612010-03-07 22:16:07 -0500582The program compiles correctly only on Linux, FreeBSD, Mac OS X, and Windows.
583Linux versions for x86\-64 (64\-bit), x86 (32\-bit), and PowerPC (32\-bit) have been
srs56948a4ddfc2010-03-21 19:05:49 -0400584tested, with the x86\-64 version having seen the most testing. Under FreeBSD,
58532\-bit (x86) and 64\-bit (x86\-64) versions have been tested. Only 32\-bit
srs5694df9d3632011-01-08 18:33:24 -0500586versions for Mac OS X and Windows have been tested by the author, although
587I've heard of 64-bit versions being successfully compiled.
srs5694e4ac11e2009-08-31 10:13:04 -0400588
srs5694978041c2009-09-21 20:51:47 -0400589.TP
srs5694e4ac11e2009-08-31 10:13:04 -0400590.B *
591The FreeBSD version of the program can't write changes to the partition
592table to a disk when existing partitions on that disk are mounted. (The
593same problem exists with many other FreeBSD utilities, such as
srs56947dbb9322010-01-20 16:56:30 -0500594\fBgpt\fR, \fBfdisk\fR, and \fBdd\fR.) This limitation can be overcome
595by typing \fBsysctl kern.geom.debugflags=16\fR at a shell prompt.
srs5694e4ac11e2009-08-31 10:13:04 -0400596
srs5694978041c2009-09-21 20:51:47 -0400597.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400598.B *
srs5694e7b4ff92009-08-18 13:16:10 -0400599The fields used to display the start and end sector numbers for partitions
600in the 'p' command are 14 characters wide. This translates to a limitation
601of about 45 PiB. On larger disks, the displayed columns will go out of
602alignment.
603
srs5694978041c2009-09-21 20:51:47 -0400604.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400605.B *
srs5694699941e2011-03-21 21:33:57 -0400606In the Windows version, only ASCII characters are supported in the
607partition name field. If an existing partition uses non\-ASCII UTF\-16
608characters, they're likely to be corrupted in the 'i' and 'p' menu options'
609displays; however, they should be preserved when loading and saving
610partitions. Binaries for Linux, FreeBSD, and OS X support full UTF-16
611partition names.
srs5694e7b4ff92009-08-18 13:16:10 -0400612
srs5694978041c2009-09-21 20:51:47 -0400613.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400614.B *
srs5694978041c2009-09-21 20:51:47 -0400615The program can load only up to 128 partitions (4 primary partitions and
616124 logical partitions) when converting from MBR format. This limit can
617be raised by changing the \fI#define MAX_MBR_PARTS\fR line in the
srs5694bf8950c2011-03-12 01:23:12 -0500618\fIbasicmbr.h\fR source code file and recompiling; however, such a change
srs56948bb78762009-11-24 15:43:49 -0500619will require using a larger\-than\-normal partition table. (The limit
srs5694978041c2009-09-21 20:51:47 -0400620of 128 partitions was chosen because that number equals the 128 partitions
srs56948bb78762009-11-24 15:43:49 -0500621supported by the most common partition table size.)
srs5694e7b4ff92009-08-18 13:16:10 -0400622
srs5694978041c2009-09-21 20:51:47 -0400623.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400624.B *
625Converting from MBR format sometimes fails because of insufficient space at
626the start or (more commonly) the end of the disk. Resizing the partition
627table (using the 's' option in the experts' menu) can sometimes overcome
628this problem; however, in extreme cases it may be necessary to resize a
srs5694978041c2009-09-21 20:51:47 -0400629partition using GNU Parted or a similar tool prior to conversion with
630\fBgdisk\fR.
srs5694e7b4ff92009-08-18 13:16:10 -0400631
srs5694978041c2009-09-21 20:51:47 -0400632.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400633.B *
srs5694e7b4ff92009-08-18 13:16:10 -0400634MBR conversions work only if the disk has correct LBA partition
635descriptors. These descriptors should be present on any disk over 8 GiB in
636size or on smaller disks partitioned with any but very ancient software.
637
srs5694978041c2009-09-21 20:51:47 -0400638.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400639.B *
srs5694e4ac11e2009-08-31 10:13:04 -0400640BSD disklabel support can create first and/or last partitions that overlap
641with the GPT data structures. This can sometimes be compensated by
642adjusting the partition table size, but in extreme cases the affected
643partition(s) may need to be deleted.
srs5694e7b4ff92009-08-18 13:16:10 -0400644
srs5694978041c2009-09-21 20:51:47 -0400645.TP
srs5694e7b4ff92009-08-18 13:16:10 -0400646.B *
srs5694e4ac11e2009-08-31 10:13:04 -0400647Because of the highly variable nature of BSD disklabel structures,
srs5694978041c2009-09-21 20:51:47 -0400648conversions from this form may be unreliable \-\- partitions may be dropped,
srs5694e4ac11e2009-08-31 10:13:04 -0400649converted in a way that creates overlaps with other partitions, or
650converted with incorrect start or end values. Use this feature with
651caution!
652
srs5694978041c2009-09-21 20:51:47 -0400653.TP
srs5694e4ac11e2009-08-31 10:13:04 -0400654.B *
655Booting after converting an MBR or BSD disklabel disk is likely to be
srs5694978041c2009-09-21 20:51:47 -0400656disrupted. Sometimes re\-installing a boot loader will fix the problem, but
657other times you may need to switch boot loaders. Except on EFI\-based
srs569455d92612010-03-07 22:16:07 -0500658platforms, Windows through at least Windows 7 doesn't support booting
srs5694978041c2009-09-21 20:51:47 -0400659from GPT disks. Creating a hybrid MBR (using the 'h' option on the recovery &
660transformation menu) or abandoning GPT in favor of MBR may be your only
661options in this case.
srs5694c0ca8f82009-08-20 21:35:25 -0400662
srs5694978041c2009-09-21 20:51:47 -0400663.PP
srs5694e7b4ff92009-08-18 13:16:10 -0400664
srs5694978041c2009-09-21 20:51:47 -0400665.SH "AUTHORS"
srs5694e7b4ff92009-08-18 13:16:10 -0400666Primary author: Roderick W. Smith (rodsmith@rodsbooks.com)
667
668Contributors:
669
670* Yves Blusseau (1otnwmz02@sneakemail.com)
671
srs56947f244ba2009-08-18 14:22:12 -0400672* David Hubbard (david.c.hubbard@gmail.com)
srs5694e7b4ff92009-08-18 13:16:10 -0400673
srs569461768bc2010-07-04 01:54:00 -0400674* Justin Maggard (justin.maggard@netgear.com)
675
Roderick W. Smith54f8fb12015-03-17 19:46:05 -0400676* Dwight Schauer (dschauer@gmail.com)
srs5694659eaf12010-08-23 11:26:12 -0400677
srs569464cbd172011-03-01 22:03:54 -0500678* Florian Zumbiehl (florz@florz.de)
679
srs56948f1b2d62010-05-23 13:07:19 -0400680
srs5694e7b4ff92009-08-18 13:16:10 -0400681.SH "SEE ALSO"
nl6720b93e29d2018-08-12 12:43:02 +0300682.BR cfdisk (8),
683.BR cgdisk (8),
684.BR fdisk (8),
685.BR mkfs (8),
686.BR parted (8),
687.BR sfdisk (8),
688.BR sgdisk (8),
689.BR fixparts (8).
srs5694e7b4ff92009-08-18 13:16:10 -0400690
srs5694978041c2009-09-21 20:51:47 -0400691\fIhttp://en.wikipedia.org/wiki/GUID_Partition_Table\fR
srs5694e7b4ff92009-08-18 13:16:10 -0400692
srs5694978041c2009-09-21 20:51:47 -0400693\fIhttp://developer.apple.com/technotes/tn2006/tn2166.html\fR
srs5694e7b4ff92009-08-18 13:16:10 -0400694
srs5694978041c2009-09-21 20:51:47 -0400695\fIhttp://www.rodsbooks.com/gdisk/\fR
srs5694e7b4ff92009-08-18 13:16:10 -0400696
srs5694978041c2009-09-21 20:51:47 -0400697.SH "AVAILABILITY"
698The \fBgdisk\fR command is part of the \fIGPT fdisk\fR package and is
699available from Rod Smith.