gpt
GUID partition table maintenance utility
gpt [-p -r -v ] command [command_options] device …
Manipulate GUID partition tables (GPTs),
A mistep here can wipe out the entire disk contents. Most commands require exclusive use of the decive
El Captian and later require disabling Integrity Protection (SIP), or less formally, "rootless."
General options change default behaviour applicable to all commands.
-p count change the number of partitions the GPT can accommodate, when a new GPT is created. Default, 128 partitions
| -r reading only.
| -v verbosity . level increases with every occurrence
| | | |
Commands:
show [-l ] device … current partitioning, gives an overall view of the disk .
With -l the GPT partition label will be displayed instead of the GPT partition type.
> sudo gpt show -l disk0
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 6
40 409600 1 GPT part - "EFI System Partition"
409640 98147192 2 GPT part - "Macintosh HD"
98556832 1269536 3 GPT part - "Recovery HD"
99826368 1344
99827712 181348816 4 GPT part - "PHOTOS90"
281176528 1269544 5 GPT part - "Recovery HD"
282446072 125011224 6 GPT part - "Recovery3-sizeQQ"
407457296 262144
407719440 88769456 7 GPT part - "DATA45G"
496488896 262144
496751040 127121832 8 GPT part - "HDIMAGES 2"
623872872 1269536 9 GPT part - "Recovery HD"
625142408 7
625142415 32 Sec GPT table
625142447 1 Sec GPT header
> sudo gpt show disk0
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 6
40 409600 1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
409640 98147192 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
98556832 1269536 3 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
99826368 1344
99827712 181348816 4 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
281176528 1269544 5 GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
282446072 125011224 6 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
407457296 262144
407719440 88769456 7 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
496488896 262144
496751040 127121832 8 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
623872872 1269536 9 GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
625142408 7
625142415 32 Sec GPT table
625142447 1 Sec GPT header
Apple-defined GPT partition types
Type GUID APM Equivalent
HFS [Plus] 48465300-0000-11AA-AA11-00306543ECAC Apple_HFS
UFS 55465300-0000-11AA-AA11-00306543ECAC Apple_UFS
Boot 426F6F74-0000-11AA-AA11-00306543ECAC Apple_Boot
RAID 52414944-0000-11AA-AA11-00306543ECAC Apple_RAID
OfflineRAID 52414944-5F4F-11AA-AA11-00306543ECAC Apple_RAID_Offline
Label 4C616265-6C00-11AA-AA11-00306543ECAC Apple_Label
| recover device … recover the GPT from the backup table. ONLY on NONE BUSY DISK!
| create [-f] device … create a new (empty) GPT (and backup!).
-f option, existing MBR is destroyed and any partitions described by the MBR are lost.
| destroy [-r] device … existing, possibly not empty GPT.
-r to destroy the table in a way that it can be recovered.
| add
[-b number] [-i index] [-s sectors]
[-t type]
device …
new partition to an existing table. By default, it will create an HFS
partition covering the first available block of an unused disk space.
| label [-a]
{-f file | -l label}
device …
> diskutil umount /dev/disk0s5
Volume PHOTOS on disk0s5 unmounted
> sudo gpt label -i 4 -l PHOTOS /dev/disk0
gpt label: unable to open device '/dev/disk0': Operation not permitted SIP is active!
Specify the new label to be assigned to the selected partitions.
| -a all partitions should be labeled. mutually exclusive with other selections
| -f file or -l label |
-f file read the label from the first line of the file and use - for STDIN
-l label label on the command line encoded in UTF-8.
|
Label any partitions that match the selection.
| -i index partition number.
| -b number | starts at the given block number.
| -s sectors size.
This can cause multiple partitions to be removed.
| -t type as an UUID or by the
aliases that add accepts. This can cause multiple partitions to be removed.
| | | | |
label [-b number] [-i index] [-s sectors] [-t type]
{-f file | -l label} device …
remove [-a] device …
Partitions that match the selection, same as label .
Partitions are removed by clearing the partition type. No other information is changed.
| remove
[-b number] [-i index] [-s sectors] [-t type]
{-f file | -l label}
device …
| | |
| | | | | | |
See also
diskutil,fdisk(8), mount(8), newfs(8), pdisk(8)
gdisk