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.\" 27.Dd September 28, 2009 28.Dt GPT 8 29.Os 30.Sh NAME 31.Nm gpt 32.Nd "GUID partition table maintenance utility" 33.Sh SYNOPSIS 34.Nm 35.Op Ar general_options 36.Ar command 37.Op Ar command_options 38.Ar device ... 39.Sh DESCRIPTION 40The 41.Nm 42utility provides the necessary functionality to manipulate GUID partition 43tables (GPTs), but see 44.Sx BUGS 45below for how and where functionality is missing. 46GPT partitions are accessed as 47.Dx 48disk slices, with same number as GPT partition, 49127 slices per disk device are supported. 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 , hammer, hammer2 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.Pp 160.Em NOTE! 161If you don't specify a beginning sector with 162.Fl b Ar number 163, the new partition will be aligned to 1MiB in size and position 164(in case of 512 byte sector sizes). 165.\" ==== boot ==== 166.It Nm Ic boot Ar device ... 167The 168.Ic boot 169command allows the user to create a small boot partition in a freshly 170created GPT. 171.Pp 172This command creates a small, 1GB boot partition as partition #0 173and hacks in a special 174.Sq slice 1 175in the PMBR which aliases it. 176The PMBR is further modified to add the necessary boot code. 177You can then disklabel GPT partition #0 and mount it, placing the contents of 178.Pa /boot 179directory within. 180You must add a line to 181.Pa loader.conf , 182like 183.Bd -literal -offset indent 184vfs.root.mountfrom="ufs:da1s1a" 185.Ed 186.Pp 187which point to the actual root mount. 188.Pp 189Your root partition may be another GPT partition and you may use a 64 bit 190disklabel within that partition if you desire. 191.Pp 192The 193.Sq boot0 194boot manager is used, it can be manipulated with the 195.Xr boot0cfg 8 196command, 197.Sq packet 198option usually needs to be set. 199.Pp 200.Em NOTE! 201A disk setup with the 202.Ar boot 203command may not be shared with another OS, 204as it doesn't use a fully standard GPT. 205.Pp 206.Em WARNING! 207Some BIOSes may not be able to deal with this hack, your mileage may vary. 208.\" ==== create ==== 209.It Nm Ic create Oo Fl fp Oc Ar device ... 210The 211.Ic create 212command allows the user to create a new (empty) GPT. 213By default, one cannot create a GPT when the device contains a MBR, 214however this can be overridden with the 215.Fl f 216option. 217If the 218.Fl f 219option is specified, an existing MBR is destroyed and any partitions 220described by the MBR are lost. 221.Pp 222The 223.Fl p 224option tells 225.Nm 226to create only the primary table and not the backup table. 227This option is only useful for debugging and should not be used otherwise. 228.\" ==== destroy ==== 229.It Nm Ic destroy Oo Fl r Oc Ar device ... 230The 231.Ic destroy 232command allows the user to destroy an existing, possibly not empty GPT. 233.Pp 234The 235.Fl r 236option instructs 237.Nm 238to destroy the table in a way that it can be recovered. 239.\" ==== label ==== 240.It Xo 241.Nm 242.Ic label 243.Op Fl a 244.Aq Fl f Ar file | Fl l Ar label 245.Ar device ... 246.Xc 247.It Xo 248.Nm 249.Ic label 250.Op Fl b Ar number 251.Op Fl i Ar index 252.Op Fl s Ar count 253.Op Fl t Ar type 254.Aq Fl f Ar file | Fl l Ar label 255.Ar device ... 256.Xc 257The 258.Ic label 259command allows the user to label any partitions that match the selection. 260At least one of the following selection options must be specified. 261.Pp 262The 263.Fl a 264option specifies that all partitions should be labeled. 265It is mutually exclusive with all other selection options. 266.Pp 267The 268.Fl b Ar number 269option selects the partition that starts at the given block number. 270.Pp 271The 272.Fl i Ar index 273option selects the partition with the given partition number. 274Partition numbers start at 0. 275.Pp 276The 277.Fl s Ar count 278option selects all partitions that have the given size. 279This can cause multiple partitions to be removed. 280.Pp 281The 282.Fl t Ar type 283option selects all partitions that have the given type. 284The type is given as an UUID or by the aliases that the 285.Ic add 286command accepts. 287This can cause multiple partitions to be removed. 288.Pp 289The 290.Fl f Ar file 291or 292.Fl l Ar label 293options specify the new label to be assigned to the selected partitions. 294The 295.Fl f Ar file 296option is used to read the label from the specified file. 297Only the first line is read from the file and the trailing newline 298character is stripped. 299If the file name is the dash or minus sign 300.Pq Fl , 301the label is read from 302the standard input. 303The 304.Fl l Ar label 305option is used to specify the label in the command line. 306The label is assumed to be encoded in UTF-8. 307.\" ==== migrate ==== 308.It Nm Ic migrate Oo Fl fs Oc Ar device ... 309The 310.Ic migrate 311command allows the user to migrate an MBR-based disk partitioning into a 312GPT-based partitioning. 313By default, the MBR is not migrated when it contains partitions of an unknown 314type. 315This can be overridden with the 316.Fl f 317option. 318Specifying the 319.Fl f 320option will cause unknown partitions to be ignored and any data in it 321to be lost. 322.Pp 323The 324.Fl s 325option prevents migrating 326.Bx 327disk labels into GPT partitions by creating 328the GPT equivalent of a slice. 329.\" ==== remove ==== 330.It Nm Ic remove Oo Fl a Oc Ar device ... 331.It Xo 332.Nm 333.Ic remove 334.Op Fl b Ar number 335.Op Fl i Ar index 336.Op Fl s Ar count 337.Op Fl t Ar type 338.Ar device ... 339.Xc 340The 341.Ic remove 342command allows the user to remove any and all partitions that match the 343selection. 344It uses the same selection options as the 345.Ic label 346command. 347See above for a description of these options. 348Partitions are removed by clearing the partition type. 349No other information is changed. 350.\" ==== show ==== 351.It Nm Ic show Oo Fl lu Oc Ar device ... 352The 353.Ic show 354command displays the current partitioning on the listed devices and gives 355an overall view of the disk contents. 356With the 357.Fl l 358option the GPT partition label will be displayed instead of the GPT partition 359type. 360The option has no effect on non-GPT partitions. 361With the 362.Fl u 363option the GPT partition type is displayed as an UUID instead of in a 364user friendly form. 365The 366.Fl l 367option takes precedence over the 368.Fl u 369option. 370.El 371.Sh FILES 372.Bl -tag -width ".Pa /etc/defaults/uuids" 373.It Pa /boot/boot0 374The default 375.Sq boot0 376image. 377.It Pa /etc/defaults/uuids 378A list of UUIDs 379and their symbolic names provided by the OS vendor. 380.It Pa /etc/uuids 381A list of UUIDs 382and their symbolic names provided by the system administrator. 383.El 384.Sh EXAMPLES 385To install an empty GPT on 386.Pa ad6 : 387.Pp 388.Dl "gpt create ad6" 389.Pp 390GPT partitions are defined in number of sectors, the sector size is usually 512B, 391which is assumed in the examples below, it can be found using: 392.Pp 393.Dl "gpt -v show ad6" 394.Pp 395To add a dummy GPT partition 0: 396.Pp 397.Dl "gpt add -i0 -s16 ad6" 398.Pp 399You might want to do this to not use slice 0 for data; 400when GPT is not used on a disk, slice 0 is the compatibility slice, 401which is used for 402.Dq dangerously dedicated 403disks. 404For GPT slice 0 has no special meaning, it is just the first slice on the disk. 405.Pp 406To add a GPT partition of size approx. 100GB: 407.Pp 408.Dl "gpt add -s200000000 ad6" 409.Pp 410This will be GPT partition 1 as it is the first one free, 411it will be accessible as 412.Pa ad6s1 , 413which is also printed by the command. 414The type will be 415.Dq DragonFly Label64 , 416it will have to be set up by 417.Xr disklabel64 8 . 418.Pp 419To add GPT partition 5 with type 420.Dq DragonFly HAMMER 421using the remaining free space: 422.Bd -literal -offset indent 423gpt add -i5 -t "DragonFly HAMMER" ad6 424.Ed 425.Pp 426To print the contents of the GPT: 427.Pp 428.Dl "gpt show ad6" 429.Ss Boot Setup 430To setup a disk using GPT for booting, the steps below can be used. 431System is copied from an already installed disk, 432e.g.\& a hard disk or an install CD. 433This example will setup disk 434.Pa da1 435with GPT for booting, using the 436.Ic boot 437command. 438.Pp 439.Em WARNING! 440Any previous data on disk installed to will be deleted. 441.Bd -literal -offset indent 442gpt create -f da1 443gpt boot da1 444boot0cfg -s 2 da1 445disklabel -B -r -w da1s0 auto 446disklabel -e da1s0 # add `a: * * 4.2BSD', to add `a' partition 447 # with fstype `4.2BSD' covering whole slice 448 449gpt add da1 450disklabel64 -r -w da1s1 auto 451disklabel64 -e da1s1 # add `b: 4G * swap', to add `b' partition 452 # with fstype `swap' and size 4GB, 453 # add `a: * * HAMMER', to add `a' partition 454 # with fstype `HAMMER' covering rest of slice 455newfs_hammer -L ROOT /dev/da1s1a 456mount_hammer /dev/da1s1a /mnt 457 458newfs /dev/da1s0a 459mkdir /mnt/boot 460mount /dev/da1s0a /mnt/boot 461 462cpdup / /mnt # copy each file system you need, e.g. 463cpdup /boot /mnt/boot 464cpdup /var /mnt/var 465cpdup /var/tmp /mnt/var/tmp 466cpdup /usr /mnt/usr 467 468cd /mnt 469vi etc/fstab # add `/dev/da1s1a / hammer rw', 470 # add `/dev/da1s1b none swap sw', 471 # add `/dev/da1s0a /boot ufs rw 1 1', 472 # delete lines for file systems cpdup'ed above 473vi boot/loader.conf # add `vfs.root.mountfrom="hammer:da1s1a"' 474cd 475umount /mnt/boot 476umount /mnt 477.Ed 478.Sh COMPATIBILITY 479The GPT that 480.Nm 481manipulates is part of the EFI standard and is supported by many OSs. 482GPT uses 64 bits to store number of sectors, this supports very large disks. 483With the prevalent sector size of 512B this is 8 billion TB. 484.Sh SEE ALSO 485.Xr uuid 3 , 486.Xr disklabel64 5 , 487.Xr uuids 5 , 488.Xr boot0cfg 8 , 489.Xr disklabel 8 , 490.Xr disklabel64 8 , 491.Xr fdisk 8 , 492.Xr mount 8 , 493.Xr newfs 8 , 494.Xr newfs_hammer 8 , 495.Xr swapon 8 496.Sh HISTORY 497The 498.Nm 499utility appeared in 500.Fx 5.0 501for ia64. 502It was imported to 503.Dx 1.9 . 504.Sh BUGS 505The development of the 506.Nm 507utility is still work in progress. 508Many necessary features are missing or partially implemented. 509In practice this means that the manual page, supposed to describe these 510features, is farther removed from being complete or useful. 511As such, missing functionality is not even documented as missing. 512However, it is believed that the currently present functionality is reliable 513and stable enough that this tool can be used without bullet-proof footware if 514one thinks one does not make mistakes. 515.Pp 516It is expected that the basic usage model does not change, but it is 517possible that future versions will not be compatible in the strictest sense 518of the word. 519For example, the 520.Fl p Ar count 521option may be changed to a command option rather than a generic option. 522There are only two commands that use it so there is a chance that the natural 523tendency for people is to use it as a command option. 524Also, options primarily intended for diagnostic or debug purposes may be 525removed in future versions. 526.Pp 527Another possibility is that the current usage model is accompanied by 528other interfaces to make the tool usable as a back-end. 529This all depends on demand and thus feedback. 530.Pp 531The 532.Ic migrate 533command doesn't support 534.Dx 535partition types. 536