GPT(8)

NAME
gpt - GUID partition table maintenance utility

SYNOPSIS
gpt [-Hnqrv] [-m mediasize] [-s sectorsize] [-T timestamp] command [command_options] device
gpt [-qv] set -l
gpt [-qv] unset -l
gpt [-qv] type -l

nbgpt [-Hnqrv] [-m mediasize] [-s sectorsize] [-T timestamp] device command [command_options]

DESCRIPTION
The gpt utility provides the necessary functionality to manipulate GUID partition tables (GPTs), but see BUGS below for how and where functionality is missing. The general options are described in the following paragraph. The remaining paragraphs describe the individual commands with their options. A device is either a special file corresponding to a disk-like device or a regular file. The command specifies the operation to be performed upon the GPT of the device specified. Commands possible are listed below.

Note that when built as a tool, and named “nbgpt” or when run using any other filesystem name than “gpt” the (usually required) device parameter is placed between the general options and the command name specified, rather than at the end of the argument list.

  General Options
The general options allow the user to change default settings or otherwise change the behaviour that is applicable to all commands. Not all commands use all default settings, so some general options may not have an effect on all commands. These options are given before the command name. Each (or at least most) of the commands has options of its own, specified below, which follow the command name. The same option letter may be used, with different effects, as a general and command specific option.

-H  Ignore existing MBR (Hybrid MBR/GPT mode).

-m mediasize
    Override the default media size for the device (obtained from the kernel if possible) or defaulting to the file size for plain files. This size is in units of bytes, but can be scaled by adding one of the suffixes allowed for the size in the add command below ( except for ‘e’ which is not implemented here). If this option is given, and -r is neither given nor implied, then device is permitted to be an empty, or even not yet existing, ordinary file.

-n  Do not update the kernel's wedge information to reflect changes made by gpt. The dkctl(8) command can be used later to manually update the kernel's wedge configuration for the device if -n is used.

-q  Do not print error messages. This is not implemented completely yet.

-r  Open the device for reading only. Currently this option is primarily useful for the show and header commands (where it is the default), but the intent is to also use it to implement dry-run behaviour. This is implied if the device can be opened for reading, but not for writing, and is always applied when the command given does not ever require write access.

-s sectorsize
    Override the default sector size for the device ( obtained from the kernel if possible, or 512 for plain files). The sector size is given as a simple (unsigned) integer, possibly scaled by a ‘K’ suffix, indicating kilobytes (KiB), specifying the number of bytes in each sector. This option usually needs to be repeated with every command applied to the affected device.

-T timestamp
    Specify a timestamp to be used for uuid generation so that uuids are not random and can be consistent for reproducible builds. Each time a command which will create uuids is run, e.g.: gpt add, gpt create, gpt migrate, or gpt uuid, with the same device or another device which will be used in the same system, if -T is to be used, it should be given a different timestamp from that used with any other uuid which might be used in the same system as device. Otherise the same uuids will be generated for multiple uses, and not be unique. This option should not be used other than for testing, or making temporary filesystems for distributions, etc. When this option is not given, timestamps are based upon a random number supplied by the kernel.

    The timestamp can be a pathname, where the timestamps are derived from the file named, an integer value interpreted as the number of seconds from the Epoch, or a parsable date string for parsedate(3) (this final option is not yet available in the tools build).

-v  Controls the verbosity level. The level increases with every occurrence of this option. There is no formalized definition of the different levels yet.

  Commands

gpt add [-a alignment] [-b blocknr] [-i index] [-l label] [-s size] [-t type]

    The add command allows the user to add a new partition to an existing table. By default, it will create an unlabeled UFS partition starting at the first available block of an unused disk space. The command-specific options can be used to control this behaviour.

    The -a alignment option allows the user to specify an alignment for the start and size. The alignment is given in bytes and may have a suffix to indicate its magnitude, see the -s option description just below. gpt will attempt to align the partition.

    The -b blocknr option allows the user to specify the starting (beginning) sector number of the partition. The minimum sector number is 1, but has to fall inside an unused region of disk space that is covered by the GPT. When not given gpt will select a suitable available empty space, if any exists.

    The -i index option allows the user to specify which (free) entry in the GPT table is to be used for the new partition. By default, the first free entry is selected.

    The -l label option allows the user to specify a label for the partition. See the description of the gpt label command for more information on labels.

    The -s size option allows the user to specify the size of the partition. If there is no suffix, or the suffix is ‘s’ or ‘S’ then size is in sectors, otherwise size is in bytes which must be a multiple of the device's sector size. Accepted suffix units (case insensitive) are ‘b’ to denote bytes, ‘k’ to denote kilobytes, ‘m’ to denote megabytes, ‘g’ to denote gigabytes, ‘t’ to denote terabytes, ‘p’ to denote petabytes, and ‘e’ to denote exabytes. The minimum size is 1 sector. If not specified, gpt will use all of the available space in the empty area selected by the -b option, after the selected blocknr, subject to alignment constraints.

    The -t type option allows the user to specify the partition type. If this option is omitted, a NetBSD FFS partition type (ffs) will be created. The type can be given as a UUID, but gpt accepts, amongst others:
    efi EFI System
    ccd NetBSD ccd component
    cgd NetBSD Cryptographic Disk
    ffs NetBSD FFSv1/FFSv2
    lfs NetBSD LFS
    raid
        NetBSD RAIDFrame component
    swap
        NetBSD swap
    zfs NetBSD or FreeBSD ZFS
    fbsd-ufs
        FreeBSD UFS/UFS2
    fbsd-swap
        FreeBSD swap
    apple
        Apple HFS
    bios
        BIOS Boot
    linux-data
        Linux data
    linux-swap
        Linux swap
    linux-lvm
        Linux LVM
    obsd
        OpenBSD data
    windows
        Microsoft basic data - NTFS, FAT32 ("msdos"), FAT16, also used for UDF
    as aliases for the most commonly used partition types.
    Use: “ gpt type -l ” to obtain an up to date list of the supported aliases.

gpt backup [-o outfile]
    The backup command dumps the MBR or (PMBR) and GPT partition tables to standard output or to a file specified by the outfile argument in a format to be used by the restore command. The format is a plist. It should not be modified.

gpt biosboot [-A] [-c bootcode] [-b startsec] [-i index] [-L label]
    The biosboot command allows the user to configure the partition that contains the primary bootstrap program, used during boot(8) when the system firmware (BIOS) either cannot handle EFI booting, or is configured not to.

    The -A options sets the PMBR partition active. This should not normally be necessary, but some firmware might require it. If -A is omitted, the active flag will be cleared from the PMBR header.

    The -c option allows the user to specify the filename from which gpt should read the bootcode. The default is to read from /usr/mdec/gptmbr.bin.

    The partition that should contain the primary bootstrap code, (similar to that installed via installboot(8)) is selected using the -i, -L and -b options. One of these three options is required. The -i option selects the partition given by the index. The -L option selects the partition by label. If there are multiple partitions with the same label, the first one found will be used. The -b option selects the partition starting at block startsec.

gpt create [-AfP] [-p partitions]
    The create command allows the user to create a new (empty) GPT. By default, one cannot create a GPT when the device contains an MBR, however this can be overridden with the -f option. If the -f option is specified, an existing MBR is destroyed and any partitions described by the MBR are lost. See the migrate command below for an alternative. A PMBR header, with one allocated partition (the GPT partition), covering the entire device, is created.

    The -A options sets the PMBR partition active.

    The -P option tells gpt to create only the primary table and not the backup table. This option is only useful for debugging and should not be used otherwise.

    The -p option changes the default number of partitions the GPT can accommodate. This is set whenever a new GPT is created, and can only (currently) be changed by destroying the GPT and beginning again. By default, the gpt utility will create space for 128 partitions (32 sectors if they are each 512 bytes). The partitions value given will be rounded up as needed so that no free space remains in the last allocated partition table sector. The number of partition table entries per sector varies with the sector size. (It is assumed that sector sizes are a power of two, and not less than 128.)

gpt destroy [-r]
    The destroy command allows the user to destroy an existing, possibly not empty, GPT.

    The -r option instructs gpt to destroy the table in a way that it can be recovered.

gpt header
    The header command displays size information about the media (device) and information from its GPT header if it exists.

gpt label -a <-f file | -l newlabel>
gpt label [-b blocknr] [-i index] [-L label] [-s sectors] [-t type] <-f file | -l newlabel>

    The label command allows the user to label any partitions that match the selection. At least one of the following selection options must be specified.

    The -a option specifies that all partitions should be labeled. It is mutually exclusive with all other selection options.

    The -b blocknr option selects the partition that starts at the given block number.

    The -i index option selects the partition with the given partition number.

    The -L label option selects all partitions that have the given label. This can cause multiple partitions to be relabeled.

    The -s sectors option selects all partitions that have the given size. This can cause multiple partitions to be labeled.

    The -t type option selects all partitions that have the given type. The type is given as a UUID or by the aliases that the add command accepts. This can cause multiple partitions to be labeled.

    When more than one of the -b, -i, -L, -s and -t options are given, partitions much match all the given criteria to be selected. For this reason it is rarely useful to specify either -b or -i (which can each only ever select one partition) with each other, or any of the other selection options, unless the intent is something like: “Partition N provided that its X is Y” (and otherwise nothing).

    A label consists of up to 36 characters (not bytes), and can contain anything from the Unicode character set, with a 16 bit code-point, except the NUL (‘\0’) character. Uses of the label for other purposes generally restrict the useful character set to exclude white space and newlines, and often other unprintable characters, and may impose a much shorter length restriction, which would usually apply to the size of the label when encoded in its input/output UTF-8 format.

    The -f file or -l newlabel options specify the new label to be assigned to the selected partitions. The -f file option is used to read the new label from the specified file. Only the first line is read from the file and the trailing newline character is stripped. If the file name is the dash or minus sign (-), the new label is read from the standard input. The -l newlabel option is used to specify the new label on the command line. With either option, the new label supplied is assumed to be encoded in UTF-8. Setting the label to be an empty string effectively causes the label to be removed.

gpt migrate [-Afs] [-p partitions]
    The migrate command allows the user to migrate an MBR-based disk partitioning into a GPT-based partitioning. By default, the MBR is not migrated when it contains partitions of an unknown type. This can be overridden with the -f option. Specifying the -f option will cause unknown partitions to be ignored and any data in them to be lost.

    The -A option sets the PMBR partition active.

    The -s option prevents migrating BSD disk labels into GPT partitions by creating the GPT equivalent of a slice. Note that the -s option is not applicable to NetBSD partitions.

    The -p option changes the default number of partitions the GPT can accommodate, as with the similar option to the gpt create command. This is set whenever a new GPT is created. By default, the gpt utility will create space for 128 partitions.

    The migrate command requires space at the beginning and the end of the device outside any partitions to store the GPTs. Space is required for the GPT header (which takes one sector) and the GPT partition table. See the -p option for the size of the GPT partition table. By default, just about all devices have a minimum of 62 sectors free at the beginning of the device, but many do not have any free space at the end. For the default GPT partition table size on a 512 byte sector size device, 33 sectors at the end of the device would need to be freed.

gpt recover
    The recover command tries to restore the GPT partition label from the backup near the end of the device. It is useful in case the primary label was deleted or overwritten, and rarely otherwise.

gpt remove -a
gpt remove [-b blocknr] [-i index] [-L label] [-s sectors] [-t type]
    The remove command allows the user to remove any and all partitions that match the selection. It uses the same selection options as the label command. See above for a description of these options. Partitions are removed by clearing the partition type. No other information is changed.

gpt resize [-i index] [-b startsec] [-a alignment] [-s size] [-q]
    The resize command allows the user to resize a partition. The partition may be shrunk and if there is sufficient free space immediately after it then it may be expanded. The -s option allows the new size to be specified, otherwise the partition will be increased to the maximum available size. If there is no suffix, or the suffix is ‘s’ or ‘S’ then size is in sectors, otherwise size is in bytes and must be a multiple of the device's sector size. Accepted suffix units are the same as those allowed for the size parameter to the gpt add command. The minimum size is 1 sector. If the -a option is specified then the size will be adjusted to be a multiple of alignment if possible. If the -q option is specified then the utility will not print output when a resize is not required.

gpt resizedisk [-s size] [-q]
    The resizedisk command allows the user to resize a disk. With GPTs, a backup copy of the label is stored at the end of the disk. If the underlying medium changes size (or is going to change size), then the backup label copy needs to be moved to the new end of the disk, and the last sector available for data storage needs to be adjusted. This command does that. If the backup copy no longer exists due to the medium shrinking, then a new backup copy will be created using the primary copy.

    The -s option allows the new size to be specified, otherwise the backup copy will automatically be placed at the current end of the disk. If there is no suffix, or the suffix is ‘s’ or ‘S’ then size is in sectors, otherwise size is in bytes which must be a multiple of the device's sector size. Accepted suffix units are as for the size parameter of the gpt add command. Using the -s option allows you to move the backup copy prior to resizing the medium. This is primarily useful when shrinking the medium. If the -q option is specified then the utility will not print output when a resize is not required.

gpt restore [-F] [-i infile]
    The restore command restores a partition table that was previously saved using the backup command. The partition table is read from standard input or a file specified in the infile argument and is expected to be in the format of a plist. It assumes an empty disk. The -F option can be used to blank the disk. The new disk does not have to be the same size as the old disk as long as all the partitions fit, as restore will automatically adjust. However, the new disk must use the same sector size as the old disk.

gpt set -l
gpt set [-a attribute]... [-N] [-i index] [-b startsec]
    The set command sets various partition attributes. The -l flag lists all available attributes. The -a option specifies which attributes to set and may be specified more than once, or the attributes can be comma-separated. The -N option causes any existing attributes to be cleared before adding new ones. If the -N option is given, and no -a options are specified, all attributes are removed. The -i or the -b option specify which entry to update. The possible attributes are “biosboot”, “bootme”, “bootonce”, “bootfailed”, “noblockio”, and “required”. The “biosboot” flag is used to indicate which partition should be booted by legacy BIOS boot code. See the biosboot command for more information. The “bootme” flag is used to indicate which partition should be booted by the NetBSD UEFI boot code. If not set on any partition, the first (in terms of partition index) FFS partition located will be used. The other boot* attributes are for compatibility with FreeBSD and are not currently used by NetBSD. ( They may be used by NetBSD in the future.)

gpt show [-AagHhlpuwx] [-i index] [-b startsec] [-W width]
    The show command displays the current partitioning on the listed device and gives an overall view of the disk contents.

    There are three output variants, each of which is available in a form intended for human viewing, and another for machine parsing. The formats for some of the data for human viewing can be varied by several of the options.

    The -W option allows the desired output width, for human output, to be set. It defaults to the value of the COLUMNS environment variable, if set, otherwise the width of the output terminal device, if available. If the width has still not been obtained, then it will default to 80, unless the -w option is given, causing 120 columns to be used instead. Repeating -w in this case will generate even wider output (up to a point). The output width is not used as much as it perhaps could be, and in no case will cause truncation of output, which will exceed the specified width if required.

    The first output variant provides an overall summary of the partitioning of the specified device. It is produced when none of the -a, -b or -i options are used. After a heading, this format generates one line for each allocated partition, for each gap between partitions, and for the overhead sectors. See the OUTPUT FORMATS section below for a complete description. Each line contains the start block number, the number of blocks, and when a GPT user data partition is being listed, its partition index, and type – for other output lines, their purpose. Block numbers (start and size) are in units of the device sector size, which can be viewed using the gpt header command.

    With the -g option the GPT partition GUID will be displayed instead of the GPT partition type. With the -l option the GPT partition label will be displayed instead of the GPT partition type. With the -u option the GPT partition type is displayed as a UUID instead of in a user friendly form. The -l and -u options only have any effect on GPT partitions, though -g will also cause GPT header “partitions” to include the partition table's GUID, and an MBR header to include its signature. If more than one of those options are given, -l takes precedence, if the partition has a label, then -g and finally -u. Specifying more than one of those options can allow variations in the output depending upon what data is available.

    With the -p option this output is produced in a parsable format, with no header. See OUTPUT FORMATS below for the details.

    With the -i or the -b option, all the details of the particular GPT partition selected will be displayed. The format of this display remains subject to change. When the -p option is also given, the format is more stable, and always consists of a sequence of lines each beginning with a keyword, followed by a colon and a space, and then the associated data value, terminated by a newline character. Note that only GPT user data partitions can be viewed this way, that is partitions with an index greater than 0. See the OUTPUT FORMATS section below for the details.

    With the -a option, all information for all partitions (also including the headers and gaps) will be printed. When used together with -p the output is a sequence of blocks of output as would be generated for -p -i or -p -b each followed by a blank line signifying the end of that partition's data. Similar data blocks for gaps and header information are included, with the Index shown as 0. In each case, the partitions are shown in the order of increasing values of the Start field.

    The format for presentation to humans of the start and size information can be modified by the -A, -H, -h and -x options. The -x option prints start/size in hex, but is ignored if any of the -A, -H, -h or -p options are also given. The other three options (-AHh) give various forms of more human digestible ways to view the start/size values, but are only used when the -p option is absent. The -h option decodes the start and size information into a sequence of values which, when summed, produce the original simple numeric sector count value, multiplied by the sector size, that is, the number of bytes. Each of these values is followed by a scaling indicator, where only non-zero multiples of the scale indicated are included. The scaling indicators are ( in order in which they would be presented, descending order of scale magnitude) E 2^60, P 2^50, T 2^40, G 2^30, M 2^20, K 2^10, and B 2^0 (1).

    The -A option instead uses humanize_number(3) to present start block numbers and sizes as a rounded approximation to the actual value, as measured in bytes (not sectors), at a suitable scale.

    And least (in all respects) the -H option causes the output from -h (which is implied with -H) to be scaled in decimal, rather than binary, units, so K is 10^3 instead of 2^10, and G is 10^9 instead of 2^30, etc. This can be combined with -A.

    The order of precedence for the main options is: -a, -b, -i, -l, -g, -u. The -b option will be ignored if no partition starting at the given startsec is located.

    The -p option can be combined with any of the above. However the -A, -H and -h options have no effect when -b, -i, or -p are given, and only a very limited effect with -a (the start and size columns are not affected, but additional information is included with the “Size:” output data for GPT user partitions). The -x option is only used when none of the -A, -b, -H, -h, -i, and -p options are given.

gpt type -l
gpt type -a -T newtype
gpt type [-b blocknr] [-i index] [-L label] [-s sectors] [-t type] -T newtype

    The type command allows the user to change the type of any and all partitions that match the selection. It uses the same selection options as the label command. See above for a description of these options. The newtype specifies the UUID for the desired partition type, or an alias, for a type known by gpt. The -l flag lists available types, some of which are shown above with the add command.

gpt unset -l
gpt unset -a attribute [-a attribute]... [-i index] [-b startsec]
    The unset command unsets various partition attributes. The -l flag lists all available attributes. The -a option specifies which attributes to unset and may be specified more than once. Alternatively a comma separated list of attributes can be used. The -i or the -b option specifies which entry to update. The possible attributes are as indicated for the gpt set command.

gpt uuid -a] -U newuuid]
gpt uuid [-b blocknr] [-i index file ...] [-L label] [-s sectors] [-t type] [-U newuuid]

    The uuid command allows the user to change the UUID of any and all partitions that match the selection. It uses the same selection options as the label command. See above for a description of these options. If newuuid is not specified, a random UUID value is derived from the timestamp (see the -T general option). If -a is used, then all partitions are updated, and the header UUID is changed as well.

    The primary purpose of this command is for use after cloning a disk to prevent collisions when both disks are used in the same system.

OUTPUT FORMATS
When the -p option is used with the gpt show command, the output is intended to be parsable by other code, including perhaps GUI applications, intending to manipulate GPT partition tables, and using gpt as a backend to do the actual manipulation.

The most basic format is that used with the -i or -b options to the show command. This provides output about a single partition. The output is a series of lines, each beginning with a keyword, followed by a colon (‘’): and a space. The data associated with the keyword is the whole remainder of the line, up to (not including) the terminating newline (‘\n’) character. The following lines may be output, fields for which no data exists are omitted. Additional fields beyond those listed here may also be included. It is generally safe to ignore an unknown keyword, and its data.
Index
    The (1 based) index number of the partition description in the GPT table. This can be 0 only when this format is used with the gpt show -a -p command.
Start
    An unsigned decimal integer giving the sector number of the first data block of the partition.
Size
    An unsigned decimal integer giving the number of sectors in the partition. This must be greater than zero.
GUID
    The partition's unique identifier in standard GUID format (hexadecimal digits used).
TypeID
    Gives the UUID which defines the intended use of the partition.
Type
    Gives the short alias for the TypeID used by gpt, if one exists.
Long_Type
    Gives a longer, more descriptive, name, if known, for the TypeID.
Attributes
    Lists any attributes set for the partition. Attributes known by gpt are shown first, as names, separated by a comma and space. Any unknown attributes set are displayed last, enclosed in brackets ( ‘[’ and ‘’]) as a hexadecimal string, each enclosed character representing 4 attribute bits, where each bit set represents one of the possible 64 attributes which is applied to the partition. Leading ‘0’ characters are omitted. Note that the higher order 16 bits (the leftmost) have meanings which depend upon the TypeID. The other 48 bits are common to all partition types.
Label
    Gives the value of the GPT “name” field of the partition. This is up to 36 characters, which may include any character except NUL (‘\0’). Each character may be any Unicode character representable by a 16 bit code point (except 0). Spaces, newlines, etc., may form part of the label. To allow this label to always appear, and be understood, on one output line, the label is first converted to UTF-8 encoding, and then further encoded as if by vis(1) using the options VIS_CSTYLE|VIS_OCTAL|VIS_TAB|VIS_NL.
Purpose
    This field is used only when the Index is zero, and hence only with output using the -a option, and indicates the reason that the disk blocks indicated by Start and Size are listed. If this is “Unused” then this set of blocks are not currently assigned, and so are available to be made into one or more partitions as required. Other values are used to indicate various data necessary for the GPT table itself, or represent other, non-GPT data, from the device.

When the gpt show -a -p command is used, the format is identical to that just described, except that multiple data blocks are produced, each followed by a blank line (including the last). As well as the GPT partition blocks, with Index greater than zero, which the previous format produces, this can also produce Index: 0 entries. These indicate blocks on the device which are not (currently) used by any assigned partition, and are are either available for allocation, or overhead used by the GPT system, or are something unrelated to GPT partitioning (probably best viewed by some other tool).

When gpt show -p is used without any of the -a, -b or -i options, a summary of the entire GPT table is produced, with much the same data (and number of entries) as when -a is used, but in a condensed, one line per block, format. Each output line starts with 3 numeric fields, each followed by a single space. Those are the values from the Start, Size and Index fields as described above, and as with -a output, zero can occur as the index. Those fields are followed by the string “GPT part – ” for all partitions where the Index is not zero. The contents of the remainder of the line depend upon which, if any, of the -g, -l or -u options are given. With none of those options, the value from the Long_Type field is appended. If the -l option is used, the Label field is appended, otherwise if the -g option is used, the GUID field is appended, otherwise the -u option must have been used, and the TypeID field is appended.

Lines with Index zero are similar, except after the 0 for the index, and its following space, the Purpose field is appended. Additional data might follow that, depending upon the particular purpose. GPT header fields will include the GUID if -g was used. A “PMBR” field will indicate “(active)” if the active bit is set. MBR partition entries will show the MBR partition type, plus “(active)” if appropriate.

When -p is not used, the gpt show command produces similar output to that described above, in a less rigorous format, more suitable for human consumption, and more likely alter from time to time. In this case the Label when output (as a sequence of UTF-8 characters) is not further encoded, so may have effects upon the terminal, and might occupy multiple lines.

EXIT STATUS
The gpt command exits with a failure status (1) when the header command is used and no GPT header is found. This can be used to check for the existence of a GPT in shell scripts. Otherwise the exit status is 0 when no error has occurred, and non-zero if an error prevented the command from executing correctly.

EXAMPLES

    nas# gpt show wd3
           start        size  index  contents
               0           1         PMBR
               1  3907029167
    nas# gpt create wd3
    nas# gpt show wd3
           start        size  index  contents
               0           1         PMBR
               1           1         Pri GPT header
               2          32         Pri GPT table
              34  3907029101
      3907029135          32         Sec GPT table
      3907029167           1         Sec GPT header
    nas# gpt add -s 10486224 -t swap -i 1 wd3
    nas# gpt label -i 1 -l swap_1 wd3
    partition 1 on rwd3d labeled swap_1
    nas# gpt show wd3
           start        size  index  contents
               0           1         PMBR
               1           1         Pri GPT header
               2          32         Pri GPT table
              34    10486224      1  GPT part - NetBSD swap
        10486258  3896542877
      3907029135          32         Sec GPT table
      3907029167           1         Sec GPT header
    nas# gpt show -l wd3
           start        size  index  contents
               0           1         PMBR
               1           1         Pri GPT header
               2          32         Pri GPT table
              34    10486224      1  GPT part - "swap_1"
        10486258  3896542877
      3907029135          32         Sec GPT table
      3907029167           1         Sec GPT header
    nas#

Booting from GPT on a BIOS system: this creates a bootable partition.

    xotica# gpt create wd1
    xotica# gpt add -b 1024 -l bootroot -t ffs -s 1g wd1
    /dev/rwd1: Partition 1 added: 49f48d5a-b10e-11dc-b99b-0019d1879648 1024 2097152
    xotica ~# dmesg | tail -2
    wd1: GPT GUID: 660e0630-0a3f-47c0-bc52-c88bcec79392
    dk0 at wd1: "bootroot", 2097152 blocks at 1024, type: ffs
    xotica# gpt biosboot -L bootroot wd1
    xotica# newfs dk0
    xotica# installboot /dev/rdk0 /usr/mdec/bootxx_ffsv1
    xotica# mount /dev/dk0 /mnt
    xotica# cp /usr/mdec/boot /mnt

Note that biosboot is not needed for UEFI systems.

    example# gpt label -a -l '' device

will clear all the GPT labels on the device.

    example# gpt label -L '' -l Unlabeled device

will label all unlabeled partitions as “Unlabeled”.

For experimenting, ordinary files can be used as devices:

    fantasy$ gpt -m128T -s8k create -p 8064 ./BIGGEST
    fantasy$ gpt -s8k show -A ./BIGGEST
      start     size  index  contents
          0     8.0K         PMBR
       8.0K     8.0K         Pri GPT header
        16K     1.0M         Pri GPT table
       1.0M     128T         Unused
       128T     1.0M         Sec GPT table
       128T     8.0K         Sec GPT header
    fantasy$ ls -l BIGGEST
    -rw-r--r--  1 user  staff  140737488355328 Feb  8 18:31 BIGGEST
    fantasy$ du -h BIGGEST
    2.1M    BIGGEST

The kernel limits the absolute apparent size of a file, depending upon file system characteristics, though the actual space used by gpt, is not all that significant. This allows experimenting with Christmas wishes. ( A filesystem this big, can currently, in 2026, actually be created by building a Raid Level 5 from 6 or more of the biggest drives available, or a Raid Level 0 (or ccd) from 5 or more of them. So, if you are nice, rather than naughty, your wish may be granted.)

Some examples of different output formats from gpt show follow:

    oldstyle$ gpt show -l sd0
           start          size  index  contents
               0             1         PMBR
               1             1         Pri GPT header
               2            32         Pri GPT table
              34          2014         Unused
            2048        817152      1  GPT part - EFI
          819200       3325952      2  GPT part - Root
         4145152         49152      3  GPT part - Exchange
         4194304    2141192192      4  GPT part - Raid_C0
      2145386496       2095104      5  GPT part - Example
    Multiline
    Label
      2147481600          2016         Unused
      2147483616            32         Sec GPT table
      2147483648             1         Sec GPT header
    newstyle$ gpt show -l -h sd0
                start     size  index  contents
                    0     512B         PMBR
                 512B     512B         Pri GPT header
                   1K      16K         Pri GPT table
                  17K    1007K         Unused
                   1M     399M      1  GPT part - EFI
                 400M  1G 600M      2  GPT part - Root
             1G 1000M      24M      3  GPT part - Exchange
                   2G    1021G      4  GPT part - Raid_C0
                1023G    1023M      5  GPT part - Example
    Multiline
    Label
          1023G 1023M    1008K         Unused
    1023G 1023M 1008K      16K         Sec GPT table
                   1T     512B         Sec GPT header
    friendly$ gpt show -l -A sd0
      start     size  index  contents
          0     512B         PMBR
       512B     512B         Pri GPT header
       1.0K      16K         Pri GPT table
        17K     1.0M         Unused
       1.0M     399M      1  GPT part - EFI
       400M     1.6G      2  GPT part - Root
       2.0G      24M      3  GPT part - Exchange
       2.0G     1.0T      4  GPT part - Raid_C0
       1.0T     1.0G      5  GPT part - Example
    Multiline
    Label
       1.0T     1.0M         Unused
       1.0T      16K         Sec GPT table
       1.0T     512B         Sec GPT header
    parsable$ gpt show -l -p sd0
    0 1 0 PMBR
    1 1 0 Pri GPT header
    2 32 0 Pri GPT table
    34 2014 0 Unused
    2048 817152 1 GPT part - EFI
    819200 3325952 2 GPT part - Root
    4145152 49152 3 GPT part - Exchange
    4194304 2141192192 4 GPT part - Raid_C0
    2145386496 2095104 5 GPT part - Example\nMultiline\nLabel
    2147481600 2016 0 Unused
    2147483616 32 0 Sec GPT table
    2147483648 1 0 Sec GPT header
    oldstyle$ gpt show -i5 sd0
    Details for index 5:
    Start: 2145386496 (1T)
    Size: 2095104 (1G)
    Type: ffs (49f48d5a-b10e-11dc-b99b-0019d1879648)
    GUID: 63033daa-cc31-4b14-84c9-484669f3d199
    Label: Example
    Multiline
    Label
    Attributes: None
    parsable$ gpt show -p -i 5 sd0
    Index: 5
    Start: 2145386496
    Size: 2095104
    GUID: 63033daa-cc31-4b14-84c9-484669f3d199
    TypeID: 49f48d5a-b10e-11dc-b99b-0019d1879648
    Type: ffs
    Long_Type: NetBSD FFSv1/FFSv2
    Label: Example\nMultiline\nLabel

SEE ALSO
vis(1), humanize_number(3), boot(8), dkctl(8), fdisk(8), installboot(8), mount(8), newfs(8), swapctl(8)

HISTORY
The gpt utility appeared in FreeBSD 5.0 for ia64. gpt utility first appeared in NetBSD 5.0.

BUGS
The development of the gpt utility is still work in progress. Many necessary features are missing or partially implemented. In practice this means that the manual page, supposed to describe these features, is farther removed from being complete or useful. As such, missing functionality is not even documented as missing. However, it is believed that the currently present functionality is reliable and stable enough that this tool can be used without bullet-proof footware if one thinks one does not make mistakes.

It is expected that the basic usage model will not change, but it is possible that future versions will not be compatible in the strictest sense of the word. Also, options primarily intended for diagnostic or debug purposes may be removed in future versions.

Another possibility is that the current usage model is accompanied by other interfaces to make the tool usable as a back-end. This all depends on demand and thus feedback.

The biggest bug is that the BUGS section doesn't actually mention any actual bugs.