1.\" Copyright (c) 2002 Marcel Moolenaar 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24.\" 25.\" $FreeBSD: src/sbin/gpt/gpt.8,v 1.17 2006/06/22 22:22:32 marcel Exp $ 26.\" $DragonFly: src/sbin/gpt/gpt.8,v 1.6 2008/07/30 01:16:29 dillon Exp $ 27.\" 28.Dd July 27, 2008 29.Os 30.Dt GPT 8 31.Sh NAME 32.Nm gpt 33.Nd "GUID partition table maintenance utility" 34.Sh SYNOPSIS 35.Nm 36.Op Ar general_options 37.Ar command 38.Op Ar command_options 39.Ar device ... 40.Sh DESCRIPTION 41The 42.Nm 43utility provides the necessary functionality to manipulate GUID partition 44tables (GPTs), but see 45.Sx BUGS 46below for how and where functionality is missing. 47GPT partitions are accessed as 48.Dx 49disk slices, with same number as GPT partition. 50The basic usage model of the 51.Nm 52tool follows that of the 53.Xr cvs 1 54tool. 55The general options are described in the following paragraph. 56The remaining paragraphs describe the individual commands with their options. 57Here we conclude by mentioning that a 58.Ar device 59is either a special file 60corresponding to a disk-like device or a regular file. 61The command is applied to each 62.Ar device 63listed on the command line. 64.Ss General Options 65The general options allow the user to change default settings or otherwise 66change the behaviour that is applicable to all commands. 67Not all commands use all default settings, so some general options may not 68have an effect on all commands. 69.Pp 70The 71.Fl p Ar count 72option allows the user to change the number of partitions the GPT can 73accommodate. 74This is used whenever a new GPT is created. 75By default, the 76.Nm 77utility will create space for 128 partitions (or 32 sectors of 512 bytes). 78.Pp 79The 80.Fl r 81option causes the 82.Nm 83utility to open the device for reading only. 84Currently this option is primarily useful for the 85.Ic show 86command, but the intent 87is to use it to implement dry-run behaviour. 88.Pp 89The 90.Fl v 91option controls the verbosity level. 92The level increases with every occurrence of this option. 93There is no formalized definition of the different levels yet. 94.Ss Commands 95.Bl -tag -width indent 96.\" ==== add ==== 97.It Xo 98.Nm 99.Ic add 100.Op Fl b Ar number 101.Op Fl i Ar index 102.Op Fl s Ar count 103.Op Fl t Ar type 104.Ar device ... 105.Xc 106The 107.Ic add 108command allows the user to add a new partition to an existing table, 109the name of the disk slice for the added partition is printed. 110By default, it will create a 111.Cm dfly 112partition covering the first available block 113of an unused disk space. 114The command-specific options can be used to control this behaviour. 115.Pp 116The 117.Fl b Ar number 118option allows the user to specify the starting (beginning) sector number of 119the partition. 120The minimum sector number is 1, but has to fall inside an unused region of 121disk space that is covered by the GPT. 122.Pp 123The 124.Fl i Ar index 125option allows the user to specify which (free) entry in the GPT table is to 126be used for the new partition. 127By default, the first free entry is selected. 128Entries start at index 0 representing partition 0 of the GPT. 129.Pp 130The 131.Fl s Ar count 132option allows the user to specify the size of the partition in sectors. 133The minimum size is 1. 134.Pp 135The 136.Fl t Ar type 137option allows the user to specify the partition type. 138The type is given as an UUID, but 139.Nm 140accepts 141.Cm efi , swap , ufs , hfs , linux , dfly , 142and 143.Cm windows 144as aliases for the most commonly used partition types. 145.Cm ufs 146is a 147.Fx 148UFS UUID. 149.Cm dfly 150has the alias 151.Cm dragonfly 152and is a 153.Dx 154.Xr disklabel64 5 155UUID. 156You may also specify any symbolic name in the system 157.Xr uuids 5 158files. 159.\" ==== boot ==== 160.It Nm Ic boot Ar device ... 161The 162.Ic boot 163command allows the user to create a small boot partition in a freshly 164created GPT. 165.Pp 166This command creates the small, 100MB boot partition as partition #0 167and hacks in a special 'slice 1' in the PMBR which aliases it. 168The PMBR is further modified to add the necessary boot code. 169You can then disklabel GPT partition #0 and mount it, placing the boot 170directory and kernel within. 171The boot directory must be a sub-directory, e.g. /mnt/boot in XXXs0a. 172You must also add a "vfs.root.mountfrom="filesystem:device" line to 173/mnt/boot/loader.conf to point to the actual root mount. 174For example, "ufs:da8s1a". 175.Pp 176Your root partition may be another GPT partition and you may use a 64 bit 177disklabel within that partition if you desire. Note that the boot partition 178must use a 32 bit disklabel. 179.Pp 180WARNING WARNING! Some BIOSes may not be able to deal with this hack, 181your mileage may vary. 182.\" ==== create ==== 183.It Nm Ic create Oo Fl fp Oc Ar device ... 184The 185.Ic create 186command allows the user to create a new (empty) GPT. 187By default, one cannot create a GPT when the device contains a MBR, 188however this can be overridden with the 189.Fl f 190option. 191If the 192.Fl f 193option is specified, an existing MBR is destroyed and any partitions 194described by the MBR are lost. 195.Pp 196The 197.Fl p 198option tells 199.Nm 200to create only the primary table and not the backup table. 201This option is only useful for debugging and should not be used otherwise. 202.\" ==== destroy ==== 203.It Nm Ic destroy Oo Fl r Oc Ar device ... 204The 205.Ic destroy 206command allows the user to destroy an existing, possibly not empty GPT. 207.Pp 208The 209.Fl r 210option instructs 211.Nm 212to destroy the table in a way that it can be recovered. 213.\" ==== label ==== 214.It Xo 215.Nm 216.Ic label 217.Op Fl a 218.Aq Fl f Ar file | Fl l Ar label 219.Ar device ... 220.Xc 221.It Xo 222.Nm 223.Ic label 224.Op Fl b Ar number 225.Op Fl i Ar index 226.Op Fl s Ar count 227.Op Fl t Ar type 228.Aq Fl f Ar file | Fl l Ar label 229.Ar device ... 230.Xc 231The 232.Ic label 233command allows the user to label any partitions that match the selection. 234At least one of the following selection options must be specified. 235.Pp 236The 237.Fl a 238option specifies that all partitions should be labeled. 239It is mutually exclusive with all other selection options. 240.Pp 241The 242.Fl b Ar number 243option selects the partition that starts at the given block number. 244.Pp 245The 246.Fl i Ar index 247option selects the partition with the given partition number. 248Partition numbers start at 0. 249.Pp 250The 251.Fl s Ar count 252option selects all partitions that have the given size. 253This can cause multiple partitions to be removed. 254.Pp 255The 256.Fl t Ar type 257option selects all partitions that have the given type. 258The type is given as an UUID or by the aliases that the 259.Ic add 260command accepts. 261This can cause multiple partitions to be removed. 262.Pp 263The 264.Fl f Ar file 265or 266.Fl l Ar label 267options specify the new label to be assigned to the selected partitions. 268The 269.Fl f Ar file 270option is used to read the label from the specified file. 271Only the first line is read from the file and the trailing newline 272character is stripped. 273If the file name is the dash or minus sign 274.Pq Fl , 275the label is read from 276the standard input. 277The 278.Fl l Ar label 279option is used to specify the label in the command line. 280The label is assumed to be encoded in UTF-8. 281.\" ==== migrate ==== 282.It Nm Ic migrate Oo Fl fs Oc Ar device ... 283The 284.Ic migrate 285command allows the user to migrate an MBR-based disk partitioning into a 286GPT-based partitioning. 287By default, the MBR is not migrated when it contains partitions of an unknown 288type. 289This can be overridden with the 290.Fl f 291option. 292Specifying the 293.Fl f 294option will cause unknown partitions to be ignored and any data in it 295to be lost. 296.Pp 297The 298.Fl s 299option prevents migrating 300.Bx 301disk labels into GPT partitions by creating 302the GPT equivalent of a slice. 303.\" ==== remove ==== 304.It Nm Ic remove Oo Fl a Oc Ar device ... 305.It Xo 306.Nm 307.Ic remove 308.Op Fl b Ar number 309.Op Fl i Ar index 310.Op Fl s Ar count 311.Op Fl t Ar type 312.Ar device ... 313.Xc 314The 315.Ic remove 316command allows the user to remove any and all partitions that match the 317selection. 318It uses the same selection options as the 319.Ic label 320command. 321See above for a description of these options. 322Partitions are removed by clearing the partition type. 323No other information is changed. 324.\" ==== show ==== 325.It Nm Ic show Oo Fl lu Oc Ar device ... 326The 327.Ic show 328command displays the current partitioning on the listed devices and gives 329an overall view of the disk contents. 330With the 331.Fl l 332option the GPT partition label will be displayed instead of the GPT partition 333type. 334The option has no effect on non-GPT partitions. 335With the 336.Fl u 337option the GPT partition type is displayed as an UUID instead of in a 338user friendly form. 339The 340.Fl l 341option takes precedence over the 342.Fl u 343option. 344.El 345.Sh FILES 346.Bl -tag -width ".Pa /etc/defaults/uuids" 347.It Pa /etc/defaults/uuids 348A list of UUIDs 349and their symbolic names provided by the OS vendor. 350.It Pa /etc/uuids 351A list of UUIDs 352and their symbolic names provided by the system administrator. 353.El 354.Sh EXAMPLES 355To install an empty GPT on 356.Pa ad6 : 357.Pp 358.Dl "gpt create ad6" 359.Pp 360GPT partitions are defined in number of sectors, the sector size is usually 512B, 361which is assumed in the examples below, it can be found using: 362.Pp 363.Dl "gpt -v show ad6" 364.Pp 365To add a dummy GPT partition 0: 366.Pp 367.Dl "gpt add -i0 -s1 ad6" 368.Pp 369You might want to do this to not use slice 0 for data; 370when GPT is not used on a disk, slice 0 is the compatibility slice, 371which is used for 372.Dq dangerously dedicated 373disks. 374For GPT slice 0 has no special meaning, it is just the first slice on the disk. 375.Pp 376To add a GPT partition of size approx. 100GB: 377.Pp 378.Dl "gpt add -s200000000 ad6" 379.Pp 380This will be GPT partition 1 as it is the first one free, 381it will be accessible as 382.Pa ad6s1 , 383which is also printed by the command. 384The type will be 385.Dq DragonFly Label64 , 386it will have to be set up by 387.Xr disklabel64 8 . 388.Pp 389To add GPT partition 5 with type 390.Dq DragonFly HAMMER 391using the remaining free space: 392.Bd -literal -offset indent 393gpt add -i5 -t "DragonFly HAMMER" ad6 394.Ed 395.Pp 396To print the contents of the GPT: 397.Pp 398.Dl "gpt show ad6" 399.Sh COMPATIBILITY 400The GPT that 401.Nm 402manipulates is part of the EFI standard and is supported by many OSs. 403GPT uses 64 bits to store number of sectors, this supports very large disks. 404With the prevalent sector size of 512B this is 8 billion TB. 405.Sh SEE ALSO 406.Xr uuid 3 , 407.Xr disklabel64 5 , 408.Xr uuids 5 , 409.Xr disklabel 8 , 410.Xr disklabel64 8 , 411.Xr fdisk 8 , 412.Xr mount 8 , 413.Xr newfs 8 , 414.Xr newfs_hammer 8 , 415.Xr swapon 8 416.Sh HISTORY 417The 418.Nm 419utility appeared in 420.Fx 5.0 421for ia64. 422It was imported to 423.Dx 1.9 . 424.Sh BUGS 425The development of the 426.Nm 427utility is still work in progress. 428Many necessary features are missing or partially implemented. 429In practice this means that the manual page, supposed to describe these 430features, is farther removed from being complete or useful. 431As such, missing functionality is not even documented as missing. 432However, it is believed that the currently present functionality is reliable 433and stable enough that this tool can be used without bullet-proof footware if 434one thinks one does not make mistakes. 435.Pp 436It is expected that the basic usage model does not change, but it is 437possible that future versions will not be compatible in the strictest sense 438of the word. 439For example, the 440.Fl p Ar count 441option may be changed to a command option rather than a generic option. 442There are only two commands that use it so there is a chance that the natural 443tendency for people is to use it as a command option. 444Also, options primarily intended for diagnostic or debug purposes may be 445removed in future versions. 446.Pp 447Another possibility is that the current usage model is accompanied by 448other interfaces to make the tool usable as a back-end. 449This all depends on demand and thus feedback. 450.Pp 451The 452.Ic migrate 453command doesn't support 454.Dx 455partition types. 456.Pp 457.Dx 458doesn't support booting from GPT partitions. 459