gpt8
Guid partition table maintenance utility
Usage
gpt [general_options]
command
[command_options]
device ...
Overview
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 basic usage model of the gpt tool follows that of the cvs(1) tool. The general options are described in the following paragraph. The remaining paragraphs describe the individual commands with their options. Here we conclude by mentioning that a device is either a special file corresponding to a disk-like device or a regular file. The command is applied to each device listed on the command line.
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.
The -f option causes the gpt utility to open the device with O_SHLOCK|O_RDWR mode. Use this mode cautiously. It may conflict with other tasks currently have the write access to the same device.
The -p count option allows the user to change the number of partitions the GPT can accommodate. This is used whenever a new GPT is created. By default, the gpt utility will create space for 128 partitions (or 32 sectors of 512 bytes).
The -r option causes the gpt utility to open the device for reading only. Currently this option is primarily useful for the show command, but the intent is to use it to implement dry-run behaviour.
The -v option controls the verbosity level. The level increases with every occurrence of this option. There is no formalized definition of the different levels yet.
Commands
-
gptadd[-bnumber] [-iindex] [-scount] [-ttype] device ... Theaddcommand allows the user to add a new partition to an existing table. By default, it will create an HFS partition covering the first available block of an unused disk space. The command-specific options can be used to control this behaviour.The
-bnumber 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.The
-iindex 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
-scount option allows the user to specify the size of the partition in sectors. The minimum size is 1.The
-ttype option allows the user to specify the partition type. The type is given as an UUID, butgptacceptsefi,hfs,apfs,linuxandwindowsas aliases for the most commonly used partition types. gptcreate[-fp] device ...-
The
createcommand allows the user to create a new (empty) GPT. By default, one cannot create a GPT when the device contains a MBR, however this can be overridden with the-foption. If the-foption is specified, an existing MBR is destroyed and any partitions described by the MBR are lost.The
-poption tellsgptto create only the primary table and not the backup table. This option is only useful for debugging and should not be used otherwise. gptdestroy[-r] device ...-
The
destroycommand allows the user to destroy an existing, possibly not empty GPT.The
-roption instructsgptto destroy the table in a way that it can be recovered. -
gptlabel[-a] ⟨-ffile |-llabel⟩ device ... -
gptlabel[-bnumber] [-iindex] [-scount] [-ttype] ⟨-ffile |-llabel⟩ device ... Thelabelcommand allows the user to label any partitions that match the selection. At least one of the following selection options must be specified.The
-aoption specifies that all partitions should be labeled. It is mutually exclusive with all other selection options.The
-bnumber option selects the partition that starts at the given block number.The
-iindex option selects the partition with the given partition number.The
-scount option selects all partitions that have the given size. This can cause multiple partitions to be removed.The
-ttype option selects all partitions that have the given type. The type is given as an UUID or by the aliases that theaddcommand accepts. This can cause multiple partitions to be removed.The
-ffile or-llabel options specify the new label to be assigned to the selected partitions. The-ffile option is used to read the 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 label is read from the standard input. The-llabel option is used to specify the label in the command line. The label is assumed to be encoded in UTF-8. gptrecoverdevice ...-
The
recovercommand allows the user to recover the GPT from the backup table. gptremove[-a] device ...-
gptremove[-bnumber] [-iindex] [-scount] [-ttype] device ... Theremovecommand allows the user to remove any and all partitions that match the selection. It uses the same selection options as thelabelcommand. See above for a description of these options. Partitions are removed by clearing the partition type. No other information is changed. gptshow[-l] device ...-
The
showcommand displays the current partitioning on the listed devices and gives an overall view of the disk contents. With the-loption the GPT partition label will be displayed instead of the GPT partition type. The option has no effect on non-GPT partitions.
Releases
135 releases since Mac OS X 10.4; the text changed 4 times.