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