blob: d5a71a078a4e3581ab4144d18fdcf1a86a5669b4 [file] [log] [blame]
Rod Smith44cda472018-07-05 09:07:58 -04001.\" Copyright 2011-2018 Roderick W. Smith (rodsmith@rodsbooks.com)
srs569473ba4792010-01-12 18:18:17 -05002.\" May be distributed under the GNU General Public License
Rod Smith44cda472018-07-05 09:07:58 -04003.TH "SGDISK" "8" "1.0.4" "Roderick W. Smith" "GPT fdisk Manual"
srs569473ba4792010-01-12 18:18:17 -05004.SH "NAME"
5sgdisk \- Command\-line GUID partition table (GPT) manipulator for Linux and Unix
6.SH "SYNOPSIS"
7.BI "sgdisk "
8[ options ]
9.I device
10
11.SH "DESCRIPTION"
12GPT fdisk is a text\-mode menu\-driven package for creation and manipulation of
13partition tables. It consists of two programs: the text\-mode interactive
14\fBgdisk\fR and the command\-line \fBsgdisk\fR. Either program will
15automatically convert an old\-style Master Boot Record (MBR) partition table
16or BSD disklabel stored without an MBR carrier partition to the newer Globally
17Unique Identifier (GUID) Partition Table (GPT) format, or will load a GUID
18partition table. This man page documents the command\-line \fBsgdisk\fR
19program.
20
21Some advanced data manipulation and
22recovery options require you to understand the distinctions between the
23main and backup data, as well as between the GPT headers and the partition
24tables. For information on MBR vs. GPT, as well as GPT terminology and
25structure, see the extended \fBgdisk\fR documentation at
26\fIhttp://www.rodsbooks.com/gdisk/\fR or consult Wikipedia.
27
28The \fBsgdisk\fR program employs a user interface that's based entirely on
29the command line, making it suitable for use in scripts or by experts who
30want to make one or two quick changes to a disk. (The program may query the
31user when certain errors are encountered, though.) The program's name is
32based on \fBsfdisk\fR, but the user options of the two programs are
33entirely different from one another.
34
35Ordinarily, \fBsgdisk\fR operates on disk device files, such as
36\fI/dev/sda\fR or \fI/dev/hda\fR under Linux, \fI/dev/disk0\fR under
37Mac OS X, or \fI/dev/ad0\fR or \fI/dev/da0\fR under FreeBSD. The program
38can also operate on disk image files, which can be either copies of whole
39disks (made with \fBdd\fR, for instance) or raw disk images used by
40emulators such as QEMU or VMWare. Note that only \fIraw\fR disk images
41are supported; \fBsgdisk\fR cannot work on compressed or other advanced
42disk image formats.
43
44The MBR partitioning system uses a combination of cylinder/head/sector
45(CHS) addressing and logical block addressing (LBA). The former is klunky
46and limiting. GPT drops CHS addressing and uses 64\-bit LBA mode
47exclusively. Thus, GPT data structures, and therefore
48\fBsgdisk\fR, do not need to deal with CHS geometries and all the problems
49they create.
50
51For best results, you should use an OS\-specific partition table
52program whenever possible. For example, you should make Mac OS X
53partitions with the Mac OS X Disk Utility program and Linux partitions
54with the Linux \fBgdisk\fR, \fBsgdisk\fR, or GNU Parted programs.
55
56Upon start, \fBsgdisk\fR attempts to identify the partition type in use on
57the disk. If it finds valid GPT data, \fBsgdisk\fR will use it. If
58\fBsgdisk\fR finds a valid MBR or BSD disklabel but no GPT data, it will
59attempt to convert the MBR or disklabel into GPT form. (BSD disklabels are
60likely to have unusable first and/or final partitions because they overlap
61with the GPT data structures, though.) GPT fdisk can identify, but not use
62data in, Apple Partition Map (APM) disks, which are used on 680x0\- and
srs569408bb0da2010-02-19 17:19:55 -050063PowerPC\-based Macintoshes. If you specify any option that results in
64changes to an MBR or BSD disklabel, \fBsgdisk\fR ignores those changes
65unless the \fI\-g\fR (\fI\-\-mbrtogpt\fR), \fI\-z\fR (\fI\-\-zap\fR), or
66\fI\-Z\fR (\fI\-\-zap\-all\fR) option is used. If you use the \fI\-g\fR
67option, \fBsgdisk\fR replaces the MBR or disklabel with a GPT. \fIThis
68action is potentially dangerous!\fR Your system may become unbootable, and
69partition type codes may become corrupted if the disk uses unrecognized
70type codes. Boot problems are particularly likely if you're multi\-booting
71with any GPT\-unaware OS.
srs569473ba4792010-01-12 18:18:17 -050072
73The MBR\-to\-GPT conversion will leave at least one gap in the partition
74numbering if the original MBR used logical partitions. These gaps are
75harmless, but you can eliminate them by using the \fI\-s\fR (\fI\-\-sort\fR)
76option, if you like. (Doing this may require you to update your
77\fI/etc/fstab\fR file.)
78
79When creating a fresh partition table, certain considerations may be in
80order:
81
82.TP
83.B *
84For data (non\-boot) disks, and for boot disks used on BIOS\-based computers
85with GRUB as the boot loader, partitions may be created in whatever order
86and in whatever sizes are desired.
87
88.TP
89.B *
Rod Smith4fff6542017-02-12 10:59:32 -050090Boot disks for EFI\-based systems require an \fIEFI System Partition\fR
91(\fBgdisk\fR internal code 0xEF00) formatted as FAT\-32. I recommended
92making this partition 550 MiB. (Smaller ESPs are common, but some EFIs have
93flaky FAT drivers that necessitate a larger partition for reliable
94operation.) Boot\-related files are stored here. (Note that GNU Parted
95identifies such partitions as having the "boot flag" set.)
srs569473ba4792010-01-12 18:18:17 -050096
97.TP
98.B *
99Some boot loaders for BIOS\-based systems make use of a \fIBIOS Boot
Rod Smith4fff6542017-02-12 10:59:32 -0500100Partition\fR (\fBgdisk\fR internal code 0xEF02), in which the secondary
101boot loader is stored, possibly without the benefit of a filesystem. (GRUB2
102may optionally use such a partition.) This partition can typically be quite
103small (roughly 32 to 200 KiB, although 1 MiB is more common in practice),
104but you should consult your boot loader documentation for details.
srs569473ba4792010-01-12 18:18:17 -0500105
106.TP
107.B *
108If Windows is to boot from a GPT disk, a partition of type \fIMicrosoft
109Reserved\fR (\fBsgdisk\fR
110internal code 0x0C01) is recommended. This partition should be about 128 MiB
111in size. It ordinarily follows the EFI System Partition and immediately
112precedes the Windows data partitions. (Note that GNU Parted creates all
113FAT partitions as this type, which actually makes the partition unusable
114for normal file storage in both Windows and Mac OS X.)
115
116.TP
117.B *
118Some OSes' GPT utilities create some blank space (typically 128 MiB) after
119each partition. The intent is to enable future disk utilities to use this
120space. Such free space is not required of GPT disks, but creating it may
121help in future disk maintenance.
122
123.SH "OPTIONS"
124Some options take no arguments, others take one argument (typically a partition
125number), and others take compound arguments with colon delimitation. For
126instance, \fI\-n\fR (\fI\-\-new\fR) takes a partition number, a starting
127sector number, and an ending sector number, as in \fBsgdisk \-n 2:2000:50000
128/dev/sdc\fR, which creates a new partition, numbered 2, starting at sector
1292000 an ending at sector 50,000, on \fI/dev/sdc\fR.
130
131Unrelated options may be combined; however, some such combinations will be
132nonsense (such as deleting a partition and then changing its GUID type code).
133\fBsgdisk\fR interprets options in the order in which they're entered, so
134effects can vary depending on order. For instance, \fBsgdisk \-s \-d 2\fR
135sorts the partition table entries and then deletes partition 2 from the
136newly\-sorted list; but \fBsgdisk \-d 2 \-s\fR deletes the original partition
1372 and then sorts the modified partition table.
138
139Error checking and opportunities to correct mistakes in \fBsgdisk\fR are
140minimal. Although the program endeavors to keep the GPT data structures legal,
141it does not prompt for verification before performing its actions. Unless you
142require a command\-line\-driven program, you should use the interactive
143\fBgdisk\fR instead of \fBsgdisk\fR, since \fBgdisk\fR allows you to
144quit without saving your changes, should you make a mistake.
145
146Although \fBsgdisk\fR is based on the same partition\-manipulation code as
147\fBgdisk\fR, \fBsgdisk\fR implements fewer features than its interactive
148sibling. Options available in \fBsgdisk\fR are:
149
150.TP
151.B \-a, \-\-set\-alignment=value
152Set the sector alignment multiple. GPT fdisk aligns the start of partitions
nl6720b93e29d2018-08-12 12:43:02 +0300153to sectors that are multiples of this value, which defaults to 1 MiB (2048
Roderick W. Smith8017e082015-04-24 21:39:20 -0400154on disks with 512-byte sectors) on freshly formatted disks. This alignment
155value is necessary to obtain optimum performance with Western Digital
156Advanced Format and similar drives with larger physical than logical sector
157sizes, with some types of RAID arrays, and with SSD devices.
srs569473ba4792010-01-12 18:18:17 -0500158
srs56949ddc14b2010-08-22 22:44:42 -0400159.TP
160.B \-A, \-\-attributes=list|[partnum:show|or|nand|xor|=|set|clear|toggle|get[:bitnum|hexbitmask]]
161View or set partition attributes. Use \fIlist\fR to see defined (known)
162attribute values. Omit the partition number (and even the device filename)
163when using this option. The others require a partition number. The
164\fIshow\fR and \fIget\fR options show the current attribute settings
165(all attributes or for a particular bit, respectively). The \fIor\fR,
srs56944307ef22012-05-30 12:30:48 -0400166\fInand\fR, \fIxor\fR, \fI=\fR, \fIset\fR, \fIclear\fR, and
srs56949ddc14b2010-08-22 22:44:42 -0400167\fItoggle\fR options enable you to change the attribute bit value. The
168\fIset\fR, \fIclear\fR, \fItoggle\fR, and \fIget\fR options work on a
169bit number; the others work on a hexadecimal bit mask. For example, type
170\fBsgdisk -A 4:set:2 /dev/sdc\fR to set the bit 2 attribute (legacy BIOS
171bootable) on partition 4 on \fI/dev/sdc\fR.
172
srs569473ba4792010-01-12 18:18:17 -0500173.TP
174.B \-b, \-\-backup=file
175Save partition data to a backup file. You can back up your current
176in\-memory partition table to a disk file using this option. The resulting
177file is a binary file consisting of the protective MBR, the main GPT
178header, the backup GPT header, and one copy of the partition table, in that
179order. Note that the backup is of the current in\-memory data structures, so
180if you launch the program, make changes, and then use this option, the
181backup will reflect your changes. If the GPT data structures are damaged,
182the backup may not accurately reflect the damaged state; instead, they
183will reflect GPT fdisk's first\-pass interpretation of the GPT.
184
185.TP
srs56949ba54212010-05-18 23:24:02 -0400186.B \-c, \-\-change\-name=partnum:name
srs569473ba4792010-01-12 18:18:17 -0500187Change the GPT name of a partition. This name is encoded as a UTF\-16
srs5694699941e2011-03-21 21:33:57 -0400188string, but proper entry and display of anything beyond basic ASCII values
189requires suitable locale and font support. For the most part, Linux ignores
Roderick W. Smith946866e2014-03-02 13:33:44 -0500190the partition name, but it may be important in some OSes. If you want to
191set a name that includes a space, enclose it in quotation marks, as in
srs5694c54e9b42010-05-01 21:04:23 -0400192\fIsgdisk \-c 1:"Sample Name" /dev/sdb\fR. Note that the GPT name of a
193partition is distinct from the filesystem name, which is encoded in the
194filesystem's data structures.
srs569473ba4792010-01-12 18:18:17 -0500195
srs56949ba54212010-05-18 23:24:02 -0400196.TP
197.B \-C, \-\-recompute-chs
198Recompute CHS values in protective or hybrid MBR. This option can sometimes
199help if a disk utility, OS, or BIOS doesn't like the CHS values used by the
200partitions in the protective or hybrid MBR. In particular, the GPT
201specification requires a CHS value of 0xFFFFFF for over-8GiB partitions,
202but this value is technically illegal by the usual standards. Some BIOSes
203hang if they encounter this value. This option will recompute a more normal
204CHS value -- 0xFEFFFF for over-8GiB partitions, enabling these BIOSes to
205boot.
206
srs569473ba4792010-01-12 18:18:17 -0500207.TP
208.B \-d, \-\-delete=partnum
209Delete a partition. This action deletes the entry from the partition table
210but does not disturb the data within the sectors originally allocated to
211the partition on the disk. If a corresponding hybrid MBR partition exists,
212\fBgdisk\fR deletes it, as well, and expands any adjacent 0xEE (EFI GPT)
213MBR protective partition to fill the new free space.
214
215.TP
srs569455d92612010-03-07 22:16:07 -0500216.B \-D, \-\-display\-alignment
217Display current sector alignment value. Partitions will be created on multiples
218of the sector value reported by this option. You can change the alignment value
219with the \-a option.
220
221.TP
Rod Smith53710d82019-03-15 15:36:41 -0400222.B \-e, \-\-move\-second\-header
srs569473ba4792010-01-12 18:18:17 -0500223Move backup GPT data structures to the end of the disk. Use this option if
224you've added disks to a RAID array, thus creating a virtual disk with space
225that follows the backup GPT data structures. This command moves the backup
226GPT data structures to the end of the disk, where they belong.
227
228.TP
srs56949ddc14b2010-08-22 22:44:42 -0400229.B \-E, \-\-end\-of\-largest
srs569473ba4792010-01-12 18:18:17 -0500230Displays the sector number of the end of the largest available block of
231sectors on the disk. A script may store this value and pass it back as
232part of \fI\-n\fR's option to create a partition. If no unallocated
233sectors are available, this function returns the value 0.
234
235.TP
236.B \-f, \-\-first\-in\-largest
237Displays the sector number of the start of the largest available block of
238sectors on the disk. A script may store this value and pass it back as
239part of \fI\-n\fR's option to create a partition. If no unallocated
srs5694ab4b0432010-09-25 20:39:52 -0400240sectors are available, this function returns the value 0. Note that this
241parameter is blind to partition alignment; when you actually create a
242partition, its start point might be changed from this value.
243
244.TP
245.B \-F, \-\-first\-aligned\-in\-largest
246Similar to \fI\-f\fR (\fI\-\-first\-in\-largest\fR), except returns the
247sector number with the current alignment correction applied. Use this
248function if you need to compute the actual partition start point rather
249than a theoretical start point or the actual start point if you set the
250alignment value to 1.
srs569473ba4792010-01-12 18:18:17 -0500251
252.TP
253.B \-g, \-\-mbrtogpt
srs56943c0af382010-01-15 19:19:18 -0500254Convert an MBR or BSD disklabel disk to a GPT disk. As a safety measure, use of
255this option is required on MBR or BSD disklabel disks if you intend to save your
256changes, in order to prevent accidentally damaging such disks.
srs569473ba4792010-01-12 18:18:17 -0500257
srs56949ba54212010-05-18 23:24:02 -0400258.TP
259.B \-G, \-\-randomize\-guids
260Randomize the disk's GUID and all partitions' unique GUIDs (but not their
261partition type code GUIDs). This function may be used after cloning a disk
262in order to render all GUIDs once again unique.
263
srs569455d92612010-03-07 22:16:07 -0500264.TP
srs569408bb0da2010-02-19 17:19:55 -0500265.B \-h, \-\-hybrid
266Create a hybrid MBR. This option takes from one to three partition numbers,
Geoff Williamsd4e56072019-09-22 17:04:42 +1000267separated by colons, as arguments. You may optionally specify a final partition
268"EE" to indicate that the EFI GPT (type 0xEE) should be placed last in the table,
269otherwise it will be placed first, followed by the partition(s) you specify.
270Their type codes are based on the GPT fdisk type codes divided by 0x0100, which
271is usually correct for Windows partitions. If the active/bootable flag should
272be set, you must do so in another program, such as \fBfdisk\fR. The \fBgdisk\fR
273program offers additional hybrid MBR creation options.
srs569408bb0da2010-02-19 17:19:55 -0500274
srs569473ba4792010-01-12 18:18:17 -0500275.TP
276.B \-i, \-\-info=partnum
277Show detailed partition information. The summary information produced by
278the \fI\-p\fR command necessarily omits many details, such as the partition's
279unique GUID and the translation of \fBsgdisk\fR's
280internal partition type code to a plain type name. The \fI\-i\fR option
281displays this information for a single partition.
282
Rod Smith503e9ad2017-07-21 21:48:13 -0400283.TP
284.B \-j, \-\-adjust\-main\-table=sector
285Adjust the location of the main partition table. This value is normally 2,
286but it may need to be increased in some cases, such as when a
287system\-on\-chip (SoC) is hard\-coded to read boot code from sector 2. I
288recommend against adjusting this value unless doing so is absolutely
289necessary.
290
srs569473ba4792010-01-12 18:18:17 -0500291.TP
292.B \-l, \-\-load\-backup=file
293Load partition data from a backup file. This option is the reverse of the
294\fI\-b\fR option. Note that restoring partition data from anything
srs5694a17fe692011-09-10 20:30:20 -0400295but the original disk is not recommended. This option will work even if the
296disk's original partition table is bad; however, most other options on the
297same command line will be ignored.
srs569473ba4792010-01-12 18:18:17 -0500298
299.TP
300.B \-L, \-\-list\-types
srs569400b6d7a2011-06-26 22:40:06 -0400301Display a summary of partition types. GPT uses a GUID to identify partition
302types for particular OSes and purposes. For ease of data entry,
srs569473ba4792010-01-12 18:18:17 -0500303\fBsgdisk\fR compresses these into two\-byte (four\-digit hexadecimal)
304values that are related to their equivalent MBR codes. Specifically, the
305MBR code is multiplied by hexadecimal 0x0100. For instance, the code for
srs569400b6d7a2011-06-26 22:40:06 -0400306Linux swap space in MBR is 0x82, and it's 0x8200 in \fBgdisk\fR. A
307one\-to\-one correspondence is impossible, though. Most notably, the codes
308for all varieties of FAT and NTFS partition correspond to a single GPT code
srs569473ba4792010-01-12 18:18:17 -0500309(entered as 0x0700 in \fBsgdisk\fR). Some OSes use a single MBR code but
srs569400b6d7a2011-06-26 22:40:06 -0400310employ many more codes in GPT. For these, \fBsgdisk\fR adds code numbers
311sequentially, such as 0xa500 for a FreeBSD disklabel, 0xa501 for FreeBSD
312boot, 0xa502 for FreeBSD swap, and so on. Note that these two\-byte codes
313are unique to \fBgdisk\fR and \fBsgdisk\fR. This option does not require
314you to specify a valid disk device filename.
srs569473ba4792010-01-12 18:18:17 -0500315
srs569455d92612010-03-07 22:16:07 -0500316.TP
srs569408bb0da2010-02-19 17:19:55 -0500317.B \-m, \-\-gpttombr
318Convert disk from GPT to MBR form. This option takes from one to four
319partition numbers, separated by colons, as arguments. Their type codes are
320based on the GPT fdisk type codes divided by 0x0100. If the active/bootable
321flag should be set, you must do so in another program, such as \fBfdisk\fR.
322The \fBgdisk\fR program offers additional MBR conversion options. It is not
323possible to convert more than four partitions from GPT to MBR form or to
324convert partitions that start above the 2TiB mark or that are larger than
3252TiB.
326
srs569473ba4792010-01-12 18:18:17 -0500327.TP
328.B \-n, \-\-new=partnum:start:end
srs56940873e9d2010-10-07 13:00:45 -0400329Create a new partition. You enter a partition number, starting sector, and
330an ending sector. Both start and end sectors can be specified in absolute
331terms as sector numbers or as positions measured in kibibytes (K),
332mebibytes (M), gibibytes (G), tebibytes (T), or pebibytes (P); for
333instance, \fI\fB40M\fR\fR specifies a position 40MiB from the start of the
334disk. You can specify locations relative to the start or end of the
srs569473ba4792010-01-12 18:18:17 -0500335specified default range by preceding the number by a '+' or '\-' symbol, as
336in \fI\fB+2G\fR\fR to specify a point 2GiB after the default start sector,
337or \fI\fB\-200M\fR\fR to specify a point 200MiB before the last available
srs5694df9d3632011-01-08 18:33:24 -0500338sector. A start or end value of 0 specifies the default value, which is the
339start of the largest available block for the start sector and the end of
340the same block for the end sector. A partnum value of 0 causes the program
Roderick W. Smith946866e2014-03-02 13:33:44 -0500341to use the first available partition number. Subsequent uses of the
342\fI\-A\fR, \fI\-c\fR, \fI\-t\fR, and \fI\-u\fR options may also use
343\fI0\fR to refer to the same partition.
srs569473ba4792010-01-12 18:18:17 -0500344
srs56949ba54212010-05-18 23:24:02 -0400345.TP
srs569461768bc2010-07-04 01:54:00 -0400346.B \-N, \-\-largest\-new=num
srs56949ba54212010-05-18 23:24:02 -0400347Create a new partition that fills the largest available block of space on
Roderick W. Smith6aec1dc2015-10-18 15:56:31 -0400348the disk. You can use the \fI\-a\fR (\fI\-\-set\-alignment\fR) option to
srs5694df9d3632011-01-08 18:33:24 -0500349adjust the alignment, if desired. A num value of 0 causes the program to
350use the first available partition number.
srs56949ba54212010-05-18 23:24:02 -0400351
srs569473ba4792010-01-12 18:18:17 -0500352.TP
353.B \-o, \-\-clear
srs5694a17fe692011-09-10 20:30:20 -0400354Clear out all partition data. This includes GPT header data, all partition
355definitions, and the protective MBR. Note that this operation will, like
356most other operations, fail on a damaged disk. If you want to prepare a
357disk you know to be damaged for GPT use, you should first wipe it with -Z
358and then partition it normally. This option will work even if the
359disk's original partition table is bad; however, most other options on the
360same command line will be ignored.
srs569473ba4792010-01-12 18:18:17 -0500361
362.TP
Roderick W. Smith54f8fb12015-03-17 19:46:05 -0400363.B \-O, \-\-print\-mbr
364Display basic \fIMBR\fR partition summary data. This includes partition
365numbers, starting and ending sector numbers, partition sizes, MBR partition
366types codes, and partition names. This option is useful mainly for
367diagnosing partition table problems, particularly on disks with hybrid
368MBRs.
369
370.TP
srs569473ba4792010-01-12 18:18:17 -0500371.B \-p, \-\-print
Roderick W. Smith54f8fb12015-03-17 19:46:05 -0400372Display basic GPT partition summary data. This includes partition numbers,
373starting and ending sector numbers, partition sizes, \fBsgdisk\fR's
374partition types codes, and partition names. For additional information, use
375the \fI\-i\fR (\fI\-\-info\fR) option.
srs569473ba4792010-01-12 18:18:17 -0500376
377.TP
378.B \-P, \-\-pretend
379Pretend to make specified changes. In\-memory GPT data structures are
380altered according to other parameters, but changes are not written
381to disk.
382
srs569455d92612010-03-07 22:16:07 -0500383.TP
srs569408bb0da2010-02-19 17:19:55 -0500384.B \-r, \-\-transpose
385Swap two partitions' entries in the partition table. One or both partitions
386may be empty, although swapping two empty partitions is pointless. For
387instance, if partitions 1\-4 are defined, transposing 1 and 5 results in a
388table with partitions numbered from 2\-5. Transposing partitions in this
389way has no effect on their disk space allocation; it only alters their
390order in the partition table.
391
srs56949ddc14b2010-08-22 22:44:42 -0400392.TP
393.B \-R, \-\-replicate=second_device_filename
394Replicate the main device's partition table on the specified second device.
395Note that the replicated partition table is an exact copy, including all
396GUIDs; if the device should have its own unique GUIDs, you should use the
397\-G option on the new disk.
398
srs569473ba4792010-01-12 18:18:17 -0500399.TP
400.B \-s, \-\-sort
401Sort partition entries. GPT partition numbers need not match the order of
402partitions on the disk. If you want them to match, you can use this option.
403Note that some partitioning utilities sort partitions whenever they make
404changes. Such changes will be reflected in your device filenames, so you
405may need to edit \fI/etc/fstab\fR if you use this option.
406
407.TP
srs5694327129e2010-09-22 01:07:31 -0400408.B \-t, \-\-typecode=partnum:{hexcode|GUID}
409Change a single partition's type code. You enter the type code using either
410a two\-byte hexadecimal number, as described earlier, or a fully-specified
411GUID value, such as EBD0A0A2-B9E5-4433-87C0-68B6B72699C7.
srs569473ba4792010-01-12 18:18:17 -0500412
413.TP
414.B \-T, \-\-transform\-bsd=partnum
415Transform BSD partitions into GPT partitions. This option works on BSD
416disklabels held within GPT (or converted MBR) partitions. Converted
417partitions' type codes are likely to need manual adjustment. \fBsgdisk\fR
418will attempt to convert BSD disklabels stored on the main disk when
419launched, but this conversion is likely to produce first and/or last
420partitions that are unusable. The many BSD variants means that the
421probability of \fBsgdisk\fR being unable to convert a BSD disklabel is
422high compared to the likelihood of problems with an MBR conversion.
423
srs56949ba54212010-05-18 23:24:02 -0400424.TP
425.B \-u, \-\-partition-guid=partnum:guid
srs56948f1b2d62010-05-23 13:07:19 -0400426Set the partition unique GUID for an individual partition. The GUID may be
427a complete GUID or 'R' to set a random GUID.
srs56949ba54212010-05-18 23:24:02 -0400428
429.TP
430.B \-U, \-\-disk-guid=guid
srs56948f1b2d62010-05-23 13:07:19 -0400431Set the GUID for the disk. The GUID may be a complete GUID or 'R' to set a
432random GUID.
srs56949ba54212010-05-18 23:24:02 -0400433
srs569473ba4792010-01-12 18:18:17 -0500434.TP
435.B \-\-usage
436Print a brief summary of available options.
437
438.TP
439.B \-v, \-\-verify
440Verify disk. This option checks for a variety of problems, such as
441incorrect CRCs and mismatched main and backup data. This option does not
srs5694a17fe692011-09-10 20:30:20 -0400442automatically correct most problems, though; for that, you must use options
443on the recovery & transformation menu. If no problems are found, this
444command displays a summary of unallocated disk space. This option will work
445even if the disk's original partition table is bad; however, most other
446options on the same command line will be ignored.
srs569473ba4792010-01-12 18:18:17 -0500447
448.TP
449.B \-V, \-\-version
450Display program version information. This option may be used without
451specifying a device filename.
452
453.TP
454.B \-z, \-\-zap
srs569408bb0da2010-02-19 17:19:55 -0500455Zap (destroy) the GPT data structures and then exit. Use this option if you
456want to repartition a GPT disk using \fBfdisk\fR or some other GPT\-unaware
457program. This option destroys only the GPT data structures; it leaves the
458MBR intact. This makes it useful for wiping out GPT data structures after a
srs569455d92612010-03-07 22:16:07 -0500459disk has been repartitioned for MBR using a GPT\-unaware utility; however,
srs569408bb0da2010-02-19 17:19:55 -0500460there's a risk that it will damage boot loaders or even the start of the
461first or end of the last MBR partition. If you use it on a valid GPT disk,
462the MBR will be left with an inappropriate EFI GPT (0xEE) partition
463definition, which you can delete using another utility.
464
srs569455d92612010-03-07 22:16:07 -0500465.TP
srs569408bb0da2010-02-19 17:19:55 -0500466.B \-Z, \-\-zap\-all
467Zap (destroy) the GPT and MBR data structures and then exit. This option
468works much like \fI\-z\fR, but as it wipes the MBR as well as the GPT, it's
469more suitable if you want to repartition a disk after using this option,
470and completely unsuitable if you've already repartitioned the disk.
srs569473ba4792010-01-12 18:18:17 -0500471
472.TP
473.B \-?, \-\-help
474Print a summary of options.
475
476.SH "RETURN VALUES"
477\fBsgdisk\fR returns various values depending on its success or failure:
478
479.TP
480.B 0
481Normal program execution
482
483.TP
484.B 1
485Too few arguments
486
487.TP
srs56943c0af382010-01-15 19:19:18 -0500488.B 2
srs569473ba4792010-01-12 18:18:17 -0500489An error occurred while reading the partition table
490
491.TP
492.B 3
Roderick W. Smith8017e082015-04-24 21:39:20 -0400493Non\-GPT disk detected and no \fI\-g\fR option, but operation requires a
494write action
srs569473ba4792010-01-12 18:18:17 -0500495
496.TP
497.B 4
498An error prevented saving changes
srs5694a17fe692011-09-10 20:30:20 -0400499
500.TP
srs5694a6297b82012-03-25 16:13:16 -0400501.B 5
502An error occurred while reading standard input (should never occur with
503sgdisk, but may with gdisk)
504
505.TP
srs5694a17fe692011-09-10 20:30:20 -0400506.B 8
507Disk replication operation (-R) failed
508
srs569473ba4792010-01-12 18:18:17 -0500509.SH "BUGS"
Roderick W. Smith54f8fb12015-03-17 19:46:05 -0400510Known bugs and limitations include:
srs569473ba4792010-01-12 18:18:17 -0500511
512.TP
513.B *
514The program compiles correctly only on Linux, FreeBSD, and Mac OS X. Linux
515versions for x86\-64 (64\-bit), x86 (32\-bit), and PowerPC (32\-bit) have been
516tested, with the x86\-64 version having seen the most testing.
517
518.TP
519.B *
520The FreeBSD version of the program can't write changes to the partition
521table to a disk when existing partitions on that disk are mounted. (The
522same problem exists with many other FreeBSD utilities, such as
srs56947dbb9322010-01-20 16:56:30 -0500523\fBgpt\fR, \fBfdisk\fR, and \fBdd\fR.) This limitation can be overcome
524by typing \fBsysctl kern.geom.debugflags=16\fR at a shell prompt.
srs569473ba4792010-01-12 18:18:17 -0500525
526.TP
527.B *
528The fields used to display the start and end sector numbers for partitions
529in the \fI\-p\fR option are 14 characters wide. This translates to a limitation
530of about 45 PiB. On larger disks, the displayed columns will go out of
531alignment.
532
533.TP
534.B *
srs569473ba4792010-01-12 18:18:17 -0500535The program can load only up to 128 partitions (4 primary partitions and
536124 logical partitions) when converting from MBR format. This limit can
537be raised by changing the \fI#define MAX_MBR_PARTS\fR line in the
srs5694bf8950c2011-03-12 01:23:12 -0500538\fIbasicmbr.h\fR source code file and recompiling; however, such a change
srs569473ba4792010-01-12 18:18:17 -0500539will require using a larger\-than\-normal partition table. (The limit
540of 128 partitions was chosen because that number equals the 128 partitions
541supported by the most common partition table size.)
542
543.TP
544.B *
545Converting from MBR format sometimes fails because of insufficient space at
546the start or (more commonly) the end of the disk. Resizing the partition
547table (using the 's' option in the experts' menu) can sometimes overcome
548this problem; however, in extreme cases it may be necessary to resize a
549partition using GNU Parted or a similar tool prior to conversion with
550\fBgdisk\fR.
551
552.TP
553.B *
554MBR conversions work only if the disk has correct LBA partition
555descriptors. These descriptors should be present on any disk over 8 GiB in
556size or on smaller disks partitioned with any but very ancient software.
557
558.TP
559.B *
560BSD disklabel support can create first and/or last partitions that overlap
561with the GPT data structures. This can sometimes be compensated by
562adjusting the partition table size, but in extreme cases the affected
563partition(s) may need to be deleted.
564
565.TP
566.B *
567Because of the highly variable nature of BSD disklabel structures,
568conversions from this form may be unreliable \-\- partitions may be dropped,
569converted in a way that creates overlaps with other partitions, or
570converted with incorrect start or end values. Use this feature with
571caution!
572
573.TP
574.B *
575Booting after converting an MBR or BSD disklabel disk is likely to be
576disrupted. Sometimes re\-installing a boot loader will fix the problem, but
577other times you may need to switch boot loaders. Except on EFI\-based
578platforms, Windows through at least Windows 7 RC doesn't support booting
579from GPT disks. Creating a hybrid MBR (using the 'h' option on the recovery &
580transformation menu) or abandoning GPT in favor of MBR may be your only
581options in this case.
582
srs5694a17fe692011-09-10 20:30:20 -0400583.PP
srs569473ba4792010-01-12 18:18:17 -0500584
585.SH "AUTHORS"
586Primary author: Roderick W. Smith (rodsmith@rodsbooks.com)
587
588Contributors:
589
590* Yves Blusseau (1otnwmz02@sneakemail.com)
591
592* David Hubbard (david.c.hubbard@gmail.com)
593
srs569461768bc2010-07-04 01:54:00 -0400594* Justin Maggard (justin.maggard@netgear.com)
srs56948f1b2d62010-05-23 13:07:19 -0400595
Roderick W. Smith54f8fb12015-03-17 19:46:05 -0400596* Dwight Schauer (dschauer@gmail.com)
srs5694659eaf12010-08-23 11:26:12 -0400597
srs569464cbd172011-03-01 22:03:54 -0500598* Florian Zumbiehl (florz@florz.de)
599
srs5694659eaf12010-08-23 11:26:12 -0400600
srs569473ba4792010-01-12 18:18:17 -0500601.SH "SEE ALSO"
nl6720b93e29d2018-08-12 12:43:02 +0300602.BR cfdisk (8),
603.BR cgdisk (8),
604.BR fdisk (8),
605.BR gdisk (8),
606.BR mkfs (8),
607.BR parted (8),
608.BR sfdisk (8),
609.BR fixparts (8).
srs569473ba4792010-01-12 18:18:17 -0500610
611\fIhttp://en.wikipedia.org/wiki/GUID_Partition_Table\fR
612
613\fIhttp://developer.apple.com/technotes/tn2006/tn2166.html\fR
614
615\fIhttp://www.rodsbooks.com/gdisk/\fR
616
617.SH "AVAILABILITY"
618The \fBsgdisk\fR command is part of the \fIGPT fdisk\fR package and is
619available from Rod Smith.