xref: /netbsd-src/sbin/gpt/gpt.8 (revision 5c5a1160462b0449181ca8fdb1ae10d483191515)
1*5c5a1160Schristos.\" $NetBSD: gpt.8,v 1.85 2025/01/12 20:48:20 christos Exp $
21a2477c1Swiz.\"
35819a8c0Schristos.\" Copyright (c) 2002 Marcel Moolenaar
45819a8c0Schristos.\" All rights reserved.
55819a8c0Schristos.\"
65819a8c0Schristos.\" Redistribution and use in source and binary forms, with or without
75819a8c0Schristos.\" modification, are permitted provided that the following conditions
85819a8c0Schristos.\" are met:
95819a8c0Schristos.\"
105819a8c0Schristos.\" 1. Redistributions of source code must retain the above copyright
115819a8c0Schristos.\"    notice, this list of conditions and the following disclaimer.
125819a8c0Schristos.\" 2. Redistributions in binary form must reproduce the above copyright
135819a8c0Schristos.\"    notice, this list of conditions and the following disclaimer in the
145819a8c0Schristos.\"    documentation and/or other materials provided with the distribution.
155819a8c0Schristos.\"
165819a8c0Schristos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
175819a8c0Schristos.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
185819a8c0Schristos.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
195819a8c0Schristos.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
205819a8c0Schristos.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
215819a8c0Schristos.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
225819a8c0Schristos.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
235819a8c0Schristos.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
245819a8c0Schristos.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
255819a8c0Schristos.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
265819a8c0Schristos.\"
275819a8c0Schristos.\" $FreeBSD: src/sbin/gpt/gpt.8,v 1.17 2006/06/22 22:22:32 marcel Exp $
285819a8c0Schristos.\"
29*5c5a1160Schristos.Dd January 12, 2025
305819a8c0Schristos.Dt GPT 8
31997634feSjoerg.Os
325819a8c0Schristos.Sh NAME
335819a8c0Schristos.Nm gpt
341a2477c1Swiz.Nd GUID partition table maintenance utility
355819a8c0Schristos.Sh SYNOPSIS
365819a8c0Schristos.Nm
376f392fa3Swiz.Op Fl Hnqrv
38e4ed2565Schristos.Op Fl m Ar mediasize
39e4ed2565Schristos.Op Fl s Ar sectorsize
40ef9cffabSchristos.Op Fl T Ar timestamp
415819a8c0Schristos.Ar command
425819a8c0Schristos.Op Ar command_options
431c8d6ff1Schristos.Ar device
44a23ee504Smlelstv.Nm
45a23ee504Smlelstv.Ar set
46a23ee504Smlelstv.Fl l
47a23ee504Smlelstv.Nm
48a23ee504Smlelstv.Ar unset
49a23ee504Smlelstv.Fl l
50a23ee504Smlelstv.Nm
51a23ee504Smlelstv.Ar type
52a23ee504Smlelstv.Fl l
535819a8c0Schristos.Sh DESCRIPTION
545819a8c0SchristosThe
555819a8c0Schristos.Nm
565819a8c0Schristosutility provides the necessary functionality to manipulate GUID partition
5734523e4bSjnemethtables
5834523e4bSjnemeth.Pq GPTs ,
5934523e4bSjnemethbut see
605819a8c0Schristos.Sx BUGS
615819a8c0Schristosbelow for how and where functionality is missing.
625819a8c0SchristosThe general options are described in the following paragraph.
635819a8c0SchristosThe remaining paragraphs describe the individual commands with their options.
645819a8c0SchristosHere we conclude by mentioning that a
655819a8c0Schristos.Ar device
665819a8c0Schristosis either a special file
675819a8c0Schristoscorresponding to a disk-like device or a regular file.
685819a8c0SchristosThe command is applied to each
695819a8c0Schristos.Ar device
705819a8c0Schristoslisted on the command line.
715819a8c0Schristos.Ss General Options
725819a8c0SchristosThe general options allow the user to change default settings or otherwise
735819a8c0Schristoschange the behaviour that is applicable to all commands.
745819a8c0SchristosNot all commands use all default settings, so some general options may not
755819a8c0Schristoshave an effect on all commands.
76e4ed2565Schristos.Bl -tag -width XXXX
776f392fa3Swiz.It Fl H
786f392fa3SwizIgnore existing MBR (Hybrid MBR/GPT mode).
79e4ed2565Schristos.It Fl m Ar mediasize
80e4ed2565SchristosOverride the default media size for the device (obtained
81279da393Schristosfrom the kernel if possible) or defaulting to the file size for
82279da393Schristosplain files.
83e4ed2565Schristos.It Fl n
84994edde5SsevanDo not update the wedge information that
85e4ed2565Schristos.Nm
86e4ed2565Schristoschanged.
87e4ed2565SchristosYou need to use the
88e4ed2565Schristos.Xr dkctl 8
89*5c5a1160Schristoscommand to manually update the device's wedge configuration if you do that.
906f392fa3Swiz.It Fl q
916f392fa3SwizDo not print error messages.
926f392fa3SwizThis is not implemented completely yet.
93e4ed2565Schristos.It Fl r
94e4ed2565SchristosOpen the device for reading only.
955819a8c0Schristos.Nm
965819a8c0SchristosCurrently this option is primarily useful for the
975819a8c0Schristos.Ic show
98e4ed2565Schristoscommand, but the intent is to use it to implement dry-run behaviour.
99e4ed2565Schristos.It Fl s Ar sectorsize
100e4ed2565SchristosOverride the default sector size for the device (obtained
101279da393Schristosfrom the kernel if possible) or
102279da393Schristos.Dv 512
103279da393Schristosfor plain files.
104ef9cffabSchristos.It Fl T Ar timestamp
105ef9cffabSchristosSpecify a timestamp to be used for uuid generation so that uuids
106ef9cffabSchristosare not random and can be consistent for reproducible builds.
107ef9cffabSchristosThe timestamp can be a pathname, where the timestamps are derived from
108ef9cffabSchristosthat file, a parseable date for parsedate(3) (this option is not
109ef9cffabSchristosyet available in the tools build), or an integer value interpreted
110ef9cffabSchristosas the number of seconds from the Epoch.
111e4ed2565Schristos.It Fl v
112e4ed2565SchristosControls the verbosity level.
1135819a8c0SchristosThe level increases with every occurrence of this option.
1145819a8c0SchristosThere is no formalized definition of the different levels yet.
115e4ed2565Schristos.El
1165819a8c0Schristos.Ss Commands
1175819a8c0Schristos.Bl -tag -width indent
1185819a8c0Schristos.\" ==== add ====
1194f22d16fSjnemeth.It Nm Ic add Oo Fl a Ar alignment Oc Oo Fl b Ar blocknr Oc \
1202098c850SjnemethOo Fl i Ar index Oc Oo Fl l Ar label Oc Oo Fl s Ar size Oc \
1211c8d6ff1SchristosOo Fl t Ar type Oc
1225819a8c0SchristosThe
1235819a8c0Schristos.Ic add
1245819a8c0Schristoscommand allows the user to add a new partition to an existing table.
1255819a8c0SchristosBy default, it will create a UFS partition covering the first available block
1265819a8c0Schristosof an unused disk space.
1275819a8c0SchristosThe command-specific options can be used to control this behaviour.
1285819a8c0Schristos.Pp
1295819a8c0SchristosThe
130650728b4Sjnemeth.Fl a Ar alignment
131650728b4Sjnemethoption allows the user to specify an alignment for the start and size.
132ff454992SmlelstvThe alignment is given in bytes and may have a suffix to indicate its
133ff454992Smlelstvmagnitude.
134650728b4Sjnemeth.Nm
135650728b4Sjnemethwill attempt to align the partition.
136650728b4Sjnemeth.Pp
137650728b4SjnemethThe
1384f22d16fSjnemeth.Fl b Ar blocknr
1395819a8c0Schristosoption allows the user to specify the starting (beginning) sector number of
1405819a8c0Schristosthe partition.
1415819a8c0SchristosThe minimum sector number is 1, but has to fall inside an unused region of
1425819a8c0Schristosdisk space that is covered by the GPT.
1435819a8c0Schristos.Pp
1445819a8c0SchristosThe
1455819a8c0Schristos.Fl i Ar index
1465819a8c0Schristosoption allows the user to specify which (free) entry in the GPT table is to
1475819a8c0Schristosbe used for the new partition.
1485819a8c0SchristosBy default, the first free entry is selected.
1495819a8c0Schristos.Pp
1505819a8c0SchristosThe
151650728b4Sjnemeth.Fl l Ar label
152650728b4Sjnemethoption allows the user to specify a label for the partition.
153650728b4Sjnemeth.Pp
154650728b4SjnemethThe
1552098c850Sjnemeth.Fl s Ar size
1562098c850Sjnemethoption allows the user to specify the size of the partition.
1572098c850SjnemethIf there is no suffix, or the suffix is
1582098c850Sjnemeth.Sq s
1592098c850Sjnemethor
1602098c850Sjnemeth.Sq S
1612098c850Sjnemeththen size is in sectors, otherwise size is in bytes which must be
1622098c850Sjnemetha multiple of the device's sector size.
163c9fee3eeSmartinAccepted suffix units (case insensitive) are
1643610eeecSsborrill.Sq b
1653610eeecSsborrillto denote bytes,
1663610eeecSsborrill.Sq k
1673610eeecSsborrillto denote kilobytes,
1683610eeecSsborrill.Sq m
1693610eeecSsborrillto denote megabytes and
1703610eeecSsborrill.Sq g
171c9fee3eeSmartinto denote gigabytes,
172c9fee3eeSmartin.Sq t
173c9fee3eeSmartinto denote terabytes,
174c9fee3eeSmartin.Sq p
175c9fee3eeSmartinto denote petabytes, and
176c9fee3eeSmartin.Sq e
177c9fee3eeSmartinto denote exabytes.
1782098c850SjnemethThe minimum size is 1 sector.
1795819a8c0Schristos.Pp
1805819a8c0SchristosThe
1815819a8c0Schristos.Fl t Ar type
1825819a8c0Schristosoption allows the user to specify the partition type.
1831b683709SgutteridgeThe type is given as a UUID, but
1845819a8c0Schristos.Nm
1855819a8c0Schristosaccepts
186c3505b64Smlelstv.Bl -tag -width "windows-reserved" -compact -offset indent
187c3505b64Smlelstv.It Cm apple
188c3505b64SmlelstvApple HFS
189c3505b64Smlelstv.It Cm apple-ufs
190c3505b64SmlelstvApple UFS
191c3505b64Smlelstv.It Cm bios
192c3505b64SmlelstvBIOS Boot
193c3505b64Smlelstv.It Cm efi
194c3505b64SmlelstvEFI System
195c3505b64Smlelstv.It Cm fbsd-legacy
196cd2cf513Swiz.Fx
197cd2cf513Swizlegacy
198c3505b64Smlelstv.It Cm fbsd-swap
199cd2cf513Swiz.Fx
200cd2cf513Swizswap
201c3505b64Smlelstv.It Cm fbsd-ufs
202cd2cf513Swiz.Fx
203cd2cf513SwizUFS/UFS2
204c3505b64Smlelstv.It Cm fbsd-vinum
205cd2cf513Swiz.Fx
206cd2cf513Swizvinum
207a0c61f45Schristos.It Cm zfs
208a0c61f45Schristos.Fx ,
209a0c61f45Schristos.Nx
210cd2cf513SwizZFS
211c3505b64Smlelstv.It Cm linux-data
212c3505b64SmlelstvLinux data
213c3505b64Smlelstv.It Cm linux-raid
214c3505b64SmlelstvLinux RAID
215c3505b64Smlelstv.It Cm linux-swap
216c3505b64SmlelstvLinux swap
217c3505b64Smlelstv.It Cm linux-lvm
218c3505b64SmlelstvLinux LVM
219197ad859Schristos.It Cm obsd
220197ad859SchristosOpenBSD data
221c3505b64Smlelstv.It Cm windows
2227a697167SniaMicrosoft basic data - NTFS, FAT32 ("msdos"), FAT16, also used for UDF
223c3505b64Smlelstv.It Cm windows-reserved
2247a697167SniaMicrosoft reserved
225c3505b64Smlelstv.It Cm ccd
226cd2cf513Swiz.Nx
227cd2cf513Swizccd component
228c3505b64Smlelstv.It Cm cgd
229cd2cf513Swiz.Nx
230cd2cf513SwizCryptographic Disk
231c3505b64Smlelstv.It Cm ffs
232cd2cf513Swiz.Nx
233cd2cf513SwizFFSv1/FFSv2
234c3505b64Smlelstv.It Cm lfs
235cd2cf513Swiz.Nx
236cd2cf513SwizLFS
237c3505b64Smlelstv.It Cm raid
238cd2cf513Swiz.Nx
239cd2cf513SwizRAIDFrame component
240c3505b64Smlelstv.It Cm swap
241cd2cf513Swiz.Nx
242cd2cf513Swizswap
243c3505b64Smlelstv.El
2445819a8c0Schristosas aliases for the most commonly used partition types.
2454fb24d0cSjnemeth.\" ==== backup ====
2462eda9128Schristos.It Nm Ic backup Oo Fl o Ar outfile Oc
2474fb24d0cSjnemethThe
2484fb24d0cSjnemeth.Ic backup
2494fb24d0cSjnemethcommand dumps the MBR or (PMBR) and GPT partition tables to standard
2502eda9128Schristosoutput or to a file specified by the
2512eda9128Schristos.Ar outfile
2522eda9128Schristosargument in a format to be used by the
2534fb24d0cSjnemeth.Ic restore
2544fb24d0cSjnemethcommand.
2554fb24d0cSjnemethThe format is a plist.
2564fb24d0cSjnemethIt should not be modified.
2578049d1e8Sjym.\" ==== biosboot ====
258f63c9f44Smartin.It Nm Ic biosboot Oo Fl A Oc Oo Fl c Ar bootcode Oc Oo Fl b Ar startsec Oc \
259f63c9f44SmartinOo Fl i Ar index Oc Oo Fl L Ar label Oc
2608049d1e8SjymThe
2618049d1e8Sjym.Ic biosboot
2628049d1e8Sjymcommand allows the user to configure the partition that contains the
2638049d1e8Sjymprimary bootstrap program, used during
2648049d1e8Sjym.Xr boot 8 .
2658049d1e8Sjym.Pp
2668049d1e8SjymThe
267b7b34325Schristos.Fl A
2683017a7a3Schristosoptions sets the PMBR partition active.
2691467a583SkreThis should not normally be necessary,
2701467a583Skrebut some firmware might require it.
2711467a583SkreIf
2721467a583Skre.Fl A
2731467a583Skreis omitted, the active flag will be cleared from the PMBR label.
2743017a7a3Schristos.Pp
2753017a7a3SchristosThe
2768049d1e8Sjym.Fl c
2771467a583Skreoption allows the user to specify the filename from which
2788049d1e8Sjym.Nm
2791467a583Skreshould read the bootcode.
2808049d1e8SjymThe default is to read from
281da4ea9e8Sdrochner.Pa /usr/mdec/gptmbr.bin .
2828049d1e8Sjym.Pp
2831467a583SkreThe partition that should contain the primary bootstrap code,
2841467a583Skre.Pq similar to that installed via Xr installboot 8
2851467a583Skreis selected using the
2861467a583Skre.Fl i ,
2871467a583Skre.Fl L
2881467a583Skreand
2891467a583Skre.Fl b
2901467a583Skreoptions.
2911467a583SkreOne of these three options is required.
2928049d1e8SjymThe
2938049d1e8Sjym.Fl i
2941467a583Skreoption selects the partition given by the
2951467a583Skre.Ar index .
296ac204e48SjnemethThe
297ac204e48Sjnemeth.Fl L
2981467a583Skreoption selects the partition by
2991467a583Skre.Ar label .
3001467a583SkreIf there are multiple partitions with the same label,
3011467a583Skrethe first one found will be used.
302f63c9f44SmartinThe
303f63c9f44Smartin.Fl b
3041467a583Skreoption selects the partition starting at block
3051467a583Skre.Ar startsec .
3065819a8c0Schristos.\" ==== create ====
307b7b34325Schristos.It Nm Ic create Oo Fl AfP Oc Oo Fl p Ar partitions Oc
3085819a8c0SchristosThe
3095819a8c0Schristos.Ic create
3105819a8c0Schristoscommand allows the user to create a new (empty) GPT.
3115819a8c0SchristosBy default, one cannot create a GPT when the device contains a MBR,
3125819a8c0Schristoshowever this can be overridden with the
3135819a8c0Schristos.Fl f
3145819a8c0Schristosoption.
3155819a8c0SchristosIf the
3165819a8c0Schristos.Fl f
3175819a8c0Schristosoption is specified, an existing MBR is destroyed and any partitions
3185819a8c0Schristosdescribed by the MBR are lost.
3195819a8c0Schristos.Pp
3205819a8c0SchristosThe
321b7b34325Schristos.Fl A
3223017a7a3Schristosoptions sets the PMBR partition active.
3233017a7a3Schristos.Pp
3243017a7a3SchristosThe
3250b43d398Schristos.Fl P
3265819a8c0Schristosoption tells
3275819a8c0Schristos.Nm
3285819a8c0Schristosto create only the primary table and not the backup table.
3295819a8c0SchristosThis option is only useful for debugging and should not be used otherwise.
3300b43d398Schristos.Pp
3310b43d398SchristosThe
3320b43d398Schristos.Fl p
3330b43d398Schristosoption changes the default number of partitions the GPT can
3340b43d398Schristosaccommodate.
3350b43d398SchristosThis is used whenever a new GPT is created.
3360b43d398SchristosBy default, the
3370b43d398Schristos.Nm
3380b43d398Schristosutility will create space for 128 partitions (or 32 sectors of 512 bytes).
3395819a8c0Schristos.\" ==== destroy ====
3401c8d6ff1Schristos.It Nm Ic destroy Oo Fl r Oc
3415819a8c0SchristosThe
3425819a8c0Schristos.Ic destroy
3435819a8c0Schristoscommand allows the user to destroy an existing, possibly not empty GPT.
3445819a8c0Schristos.Pp
3455819a8c0SchristosThe
3465819a8c0Schristos.Fl r
3475819a8c0Schristosoption instructs
3485819a8c0Schristos.Nm
3495819a8c0Schristosto destroy the table in a way that it can be recovered.
350902aecabSjnemeth.\" ==== header ====
3511c8d6ff1Schristos.It Nm Ic header
352902aecabSjnemethThe
353902aecabSjnemeth.Ic header
354902aecabSjnemethcommand displays size information about the media and information from the
355902aecabSjnemethGPT header if it exists.
3565819a8c0Schristos.\" ==== label ====
3571c8d6ff1Schristos.It Nm Ic label Oo Fl a Oc Ao Fl f Ar file | Fl l Ar label Ac
3584f22d16fSjnemeth.It Nm Ic label Oo Fl b Ar blocknr Oc Oo Fl i Ar index Oc \
359ac204e48SjnemethOo Fl L Ar label Oc Oo Fl s Ar sectors Oc Oo Fl t Ar type Oc \
3601c8d6ff1SchristosAo Fl f Ar file | Fl l Ar label Ac
3615819a8c0SchristosThe
3625819a8c0Schristos.Ic label
3635819a8c0Schristoscommand allows the user to label any partitions that match the selection.
3645819a8c0SchristosAt least one of the following selection options must be specified.
3655819a8c0Schristos.Pp
3665819a8c0SchristosThe
3675819a8c0Schristos.Fl a
3685819a8c0Schristosoption specifies that all partitions should be labeled.
3695819a8c0SchristosIt is mutually exclusive with all other selection options.
3705819a8c0Schristos.Pp
3715819a8c0SchristosThe
3724f22d16fSjnemeth.Fl b Ar blocknr
3735819a8c0Schristosoption selects the partition that starts at the given block number.
3745819a8c0Schristos.Pp
3755819a8c0SchristosThe
3765819a8c0Schristos.Fl i Ar index
3775819a8c0Schristosoption selects the partition with the given partition number.
3785819a8c0Schristos.Pp
3795819a8c0SchristosThe
380ac204e48Sjnemeth.Fl L Ar label
381ac204e48Sjnemethoption selects all partitions that have the given label.
382ac204e48SjnemethThis can cause multiple partitions to be relabeled.
383ac204e48Sjnemeth.Pp
384ac204e48SjnemethThe
3854f22d16fSjnemeth.Fl s Ar sectors
3865819a8c0Schristosoption selects all partitions that have the given size.
38734523e4bSjnemethThis can cause multiple partitions to be labeled.
3885819a8c0Schristos.Pp
3895819a8c0SchristosThe
3905819a8c0Schristos.Fl t Ar type
3915819a8c0Schristosoption selects all partitions that have the given type.
3921b683709SgutteridgeThe type is given as a UUID or by the aliases that the
3935819a8c0Schristos.Ic add
3945819a8c0Schristoscommand accepts.
39534523e4bSjnemethThis can cause multiple partitions to be labeled.
3965819a8c0Schristos.Pp
3975819a8c0SchristosThe
3985819a8c0Schristos.Fl f Ar file
3995819a8c0Schristosor
4005819a8c0Schristos.Fl l Ar label
4015819a8c0Schristosoptions specify the new label to be assigned to the selected partitions.
4025819a8c0SchristosThe
4035819a8c0Schristos.Fl f Ar file
4045819a8c0Schristosoption is used to read the label from the specified file.
4055819a8c0SchristosOnly the first line is read from the file and the trailing newline
4065819a8c0Schristoscharacter is stripped.
4075819a8c0SchristosIf the file name is the dash or minus sign
4085819a8c0Schristos.Pq Fl ,
4095819a8c0Schristosthe label is read from
4105819a8c0Schristosthe standard input.
4115819a8c0SchristosThe
4125819a8c0Schristos.Fl l Ar label
4135819a8c0Schristosoption is used to specify the label in the command line.
4145819a8c0SchristosThe label is assumed to be encoded in UTF-8.
4155819a8c0Schristos.\" ==== migrate ====
416b7b34325Schristos.It Nm Ic migrate Oo Fl Afs Oc Oo Fl p Ar partitions Oc
4175819a8c0SchristosThe
4185819a8c0Schristos.Ic migrate
4195819a8c0Schristoscommand allows the user to migrate an MBR-based disk partitioning into a
4205819a8c0SchristosGPT-based partitioning.
4215819a8c0SchristosBy default, the MBR is not migrated when it contains partitions of an unknown
4225819a8c0Schristostype.
4235819a8c0SchristosThis can be overridden with the
4245819a8c0Schristos.Fl f
4255819a8c0Schristosoption.
4265819a8c0SchristosSpecifying the
4275819a8c0Schristos.Fl f
4285819a8c0Schristosoption will cause unknown partitions to be ignored and any data in it
4295819a8c0Schristosto be lost.
4305819a8c0Schristos.Pp
4315819a8c0SchristosThe
432b7b34325Schristos.Fl A
4333017a7a3Schristosoptions sets the PMBR partition active.
4343017a7a3Schristos.Pp
4353017a7a3SchristosThe
4365819a8c0Schristos.Fl s
4375819a8c0Schristosoption prevents migrating
4385819a8c0Schristos.Bx
4395819a8c0Schristosdisk labels into GPT partitions by creating
4405819a8c0Schristosthe GPT equivalent of a slice.
44134523e4bSjnemethNote that the
44234523e4bSjnemeth.Fl s
443994edde5Ssevanoption is not applicable to
44434523e4bSjnemeth.Nx
44534523e4bSjnemethpartitions.
44634523e4bSjnemeth.Pp
44734523e4bSjnemethThe
4480b43d398Schristos.Fl p
4490b43d398Schristosoption changes the default number of partitions the GPT can
4500b43d398Schristosaccommodate.
4510b43d398SchristosThis is used whenever a new GPT is created.
4520b43d398SchristosBy default, the
4530b43d398Schristos.Nm
4540b43d398Schristosutility will create space for 128 partitions (or 32 sectors of 512 bytes).
4550b43d398Schristos.Pp
4560b43d398SchristosThe
45734523e4bSjnemeth.Ic migrate
45834523e4bSjnemethcommand requires space at the beginning and the end of the device outside
45934523e4bSjnemethany partitions to store the GPTs.
46034523e4bSjnemethSpace is required for the GPT header
46134523e4bSjnemeth.Pq which takes one sector
46234523e4bSjnemethand the GPT partition table.
46334523e4bSjnemethSee the
46434523e4bSjnemeth.Fl p
46534523e4bSjnemethoption
46634523e4bSjnemethfor the size of the GPT partition table.
46734523e4bSjnemethBy default, just about all devices have a minimum of 62 sectors free at the
468994edde5Ssevanbeginning of the device, but do not have any free space at the end.
46934523e4bSjnemethFor the default GPT partition table size on a 512 byte sector size device,
47034523e4bSjnemeth33 sectors at the end of the device would need to be freed.
47182c48876Swiz.\" ==== recover ====
4721c8d6ff1Schristos.It Nm Ic recover
47382c48876SwizThe
47482c48876Swiz.Ic recover
47582c48876Swizcommand tries to restore the GPT partition label from the backup
47682c48876Swiznear the end of the disk.
47782c48876SwizIt is very useful in case the primary label was deleted.
4785819a8c0Schristos.\" ==== remove ====
4791c8d6ff1Schristos.It Nm Ic remove Oo Fl a Oc
4804f22d16fSjnemeth.It Nm Ic remove Oo Fl b Ar blocknr Oc Oo Fl i Ar index Oc \
4811c8d6ff1SchristosOo Fl L Ar label Oc Oo Fl s Ar sectors Oc Oo Fl t Ar type Oc
4825819a8c0SchristosThe
4835819a8c0Schristos.Ic remove
4845819a8c0Schristoscommand allows the user to remove any and all partitions that match the
4855819a8c0Schristosselection.
4865819a8c0SchristosIt uses the same selection options as the
4875819a8c0Schristos.Ic label
4885819a8c0Schristoscommand.
4895819a8c0SchristosSee above for a description of these options.
4905819a8c0SchristosPartitions are removed by clearing the partition type.
4915819a8c0SchristosNo other information is changed.
4920a080583Sjnemeth.\" ==== resize ====
4932ee402b3Smartin.It Nm Ic resize Oo Fl i Ar index Oc Oo Fl b Ar startsec Oc Oo Fl a Ar alignment Oc \
494084befafSjmcneillOo Fl s Ar size Oc Oo Fl q Oc
4950a080583SjnemethThe
4960a080583Sjnemeth.Ic resize
4970a080583Sjnemethcommand allows the user to resize a partition.
49800996309SwizThe partition may be shrunk and if there is sufficient free space
4990a080583Sjnemethimmediately after it then it may be expanded.
5000a080583SjnemethThe
5010a080583Sjnemeth.Fl s
5020a080583Sjnemethoption allows the new size to be specified, otherwise the partition will
5030a080583Sjnemethbe increased to the maximum available size.
5042098c850SjnemethIf there is no suffix, or the suffix is
5052098c850Sjnemeth.Sq s
5062098c850Sjnemethor
5072098c850Sjnemeth.Sq S
5082098c850Sjnemeththen size is in sectors, otherwise size is in bytes which must be
5092098c850Sjnemetha multiple of the device's sector size.
5103610eeecSsborrillAccepted suffix units are
5113610eeecSsborrill.Sq b
5123610eeecSsborrillto denote bytes,
5133610eeecSsborrill.Sq k
5143610eeecSsborrillto denote kilobytes,
5153610eeecSsborrill.Sq m
5163610eeecSsborrillto denote megabytes and
5173610eeecSsborrill.Sq g
5183610eeecSsborrillto denote gigabytes.
5192098c850SjnemethThe minimum size is 1 sector.
5200a080583SjnemethIf the
5210a080583Sjnemeth.Fl a
5220a080583Sjnemethoption is specified then the size will be adjusted to be a multiple of
5230a080583Sjnemethalignment if possible.
524084befafSjmcneillIf the
525084befafSjmcneill.Fl q
526084befafSjmcneilloption is specified then the utility will not print output when a
527084befafSjmcneillresize is not required.
5282ed5cc26Sjnemeth.\" ==== resizedisk ====
529084befafSjmcneill.It Nm Ic resizedisk Oo Fl s Ar size Oc Oo Fl q Oc
5302ed5cc26SjnemethThe
5312ed5cc26Sjnemeth.Ic resizedisk
5322ed5cc26Sjnemethcommand allows the user to resize a disk.
5332ed5cc26SjnemethWith GPTs, a backup copy is stored at the end of the disk.
5342ed5cc26SjnemethIf the underlying medium changes size
5352ed5cc26Sjnemeth.Pq or is going to change size ,
5362ed5cc26Sjnemeththen the backup copy needs to be moved to the new end of the disk,
5372ed5cc26Sjnemethand the last sector available for data storage needs to be adjusted.
5382ed5cc26SjnemethThis command does that.
5392ed5cc26SjnemethIf the backup copy no longer exists due to the medium shrinking, then
5402ed5cc26Sjnemetha new backup copy will be created using the primary copy.
5412ed5cc26Sjnemeth.Pp
5422ed5cc26SjnemethThe
5432ed5cc26Sjnemeth.Fl s
5442ed5cc26Sjnemethoption allows the new size to be specified, otherwise the backup copy
5452ed5cc26Sjnemethwill automatically be placed at the current end of the disk.
5462ed5cc26SjnemethIf there is no suffix, or the suffix is
5472ed5cc26Sjnemeth.Sq s
5482ed5cc26Sjnemethor
5492ed5cc26Sjnemeth.Sq S
5502ed5cc26Sjnemeththen size is in sectors, otherwise size is in bytes which must be
5512ed5cc26Sjnemetha multiple of the device's sector size.
5523610eeecSsborrillAccepted suffix units are
5533610eeecSsborrill.Sq b
5543610eeecSsborrillto denote bytes,
5553610eeecSsborrill.Sq k
5563610eeecSsborrillto denote kilobytes,
5573610eeecSsborrill.Sq m
5583610eeecSsborrillto denote megabytes and
5593610eeecSsborrill.Sq g
5603610eeecSsborrillto denote gigabytes.
5612ed5cc26SjnemethUsing the
5622ed5cc26Sjnemeth.Fl s
5632ed5cc26Sjnemethoption allows you to move the backup copy prior to resizing the medium.
5642ed5cc26SjnemethThis is primarily useful when shrinking the medium.
565084befafSjmcneillIf the
566084befafSjmcneill.Fl q
567084befafSjmcneilloption is specified then the utility will not print output when a
568084befafSjmcneillresize is not required.
5694013e132Sjnemeth.\" ==== restore ====
5702eda9128Schristos.It Nm Ic restore Oo Fl F Oc Oo Fl i Ar infile Oc
5714013e132SjnemethThe
5724013e132Sjnemeth.Ic restore
5734013e132Sjnemethcommand restores a partition table that was previously saved using the
5744013e132Sjnemeth.Ic backup
5754013e132Sjnemethcommand.
5762eda9128SchristosThe partition table is read from standard input or a file specified in
5772eda9128Schristosthe
5782eda9128Schristos.Ar infile
5792eda9128Schristosargument and is expected to be in the format of a plist.
5804013e132SjnemethIt assumes an empty disk.
5814013e132SjnemethThe
5824013e132Sjnemeth.Fl F
5834013e132Sjnemethoption can be used to blank the disk.
5844013e132SjnemethThe new disk does not have to be the same size as the old disk as long as all
5854013e132Sjnemeththe partitions fit, as
5864013e132Sjnemeth.Ic restore
5874013e132Sjnemethwill automatically adjust.
5884013e132SjnemethHowever, the new disk must use the same sector size as the old disk.
5891cb2b941Sjnemeth.\" ==== set ====
59017565838Smartin.It Nm Ic set Oo Fl a Ar attribute Oc Oo Fl N Oc Oo Fl i Ar index Oc \
59117565838SmartinOo Fl b Ar startsec Oc
5924d523900Schristos.It Nm Ic set Fl l
5931cb2b941SjnemethThe
5941cb2b941Sjnemeth.Ic set
5951cb2b941Sjnemethcommand sets various partition attributes.
5961cb2b941SjnemethThe
5974d523900Schristos.Fl l
5984d523900Schristosflag lists all available attributes.
5994d523900SchristosThe
6001cb2b941Sjnemeth.Fl a
6014d523900Schristosoption specifies which attributes to set and may be specified more than once,
6024d523900Schristosor the attributes can be comma-separated.
60317565838SmartinIf the
60417565838Smartin.Fl N
60517565838Smartinoption and no
60617565838Smartin.Fl a
60717565838Smartinoption are specified, all attributes are removed.
6081cb2b941SjnemethThe
6091cb2b941Sjnemeth.Fl i
61017565838Smartinor the
61117565838Smartin.Fl b
61217565838Smartinoption specify which entry to update.
6131cb2b941SjnemethThe possible attributes are
6141cb2b941Sjnemeth.Do biosboot Dc ,
6151cb2b941Sjnemeth.Do bootme Dc ,
6164d523900Schristos.Do bootonce Dc ,
6174d523900Schristos.Do bootfailed Dc ,
6184d523900Schristos.Do noblockio Dc , and
6194d523900Schristos.Do required Dc .
6201cb2b941SjnemethThe biosboot flag is used to indicate which partition should be booted
6211cb2b941Sjnemethby legacy BIOS boot code.
6221cb2b941SjnemethSee the
6231cb2b941Sjnemeth.Ic biosboot
6241cb2b941Sjnemethcommand for more information.
6257cd73c92SkreThe bootme flag is used to indicate which partition should be booted
6261848778bSmsaitohby UEFI boot code.
6274d523900SchristosThe other attributes are for compatibility with
6281cb2b941Sjnemeth.Fx
6297cd73c92Skreand are not currently used by
6307cd73c92Skre.Nx .
6311cb2b941SjnemethThey may be used by
6321cb2b941Sjnemeth.Nx
6337cd73c92Skrein the future.
6345819a8c0Schristos.\" ==== show ====
63587b4c5e3Schristos.It Nm Ic show Oo Fl aglux Oc Oo Fl i Ar index Oc Oo Fl b Ar startsec Oc
6365819a8c0SchristosThe
6375819a8c0Schristos.Ic show
6385819a8c0Schristoscommand displays the current partitioning on the listed devices and gives
6395819a8c0Schristosan overall view of the disk contents.
6405819a8c0SchristosWith the
641925666efSjnemeth.Fl g
642925666efSjnemethoption the GPT partition GUID will be displayed instead of the GPT partition
643925666efSjnemethtype.
644925666efSjnemethWith the
6455819a8c0Schristos.Fl l
6465819a8c0Schristosoption the GPT partition label will be displayed instead of the GPT partition
6475819a8c0Schristostype.
6485819a8c0SchristosWith the
6495819a8c0Schristos.Fl u
6501b683709Sgutteridgeoption the GPT partition type is displayed as a UUID instead of in a
6515819a8c0Schristosuser friendly form.
652925666efSjnemethWith the
653925666efSjnemeth.Fl i
6542ee402b3Smartinor the
6552ee402b3Smartin.Fl b
656925666efSjnemethoption, all the details of a particular GPT partition will be displayed.
65766ad0e75SjnemethThe format of this display is subject to change.
65853078a20SmartinWith the
65953078a20Smartin.Fl a
66053078a20Smartinoption, all information for all GPT partitions (just like with
66153078a20Smartin.Fl i Ar index )
66253078a20Smartinwill be printed.
66387b4c5e3SchristosThe
66487b4c5e3Schristos.Fl x
66587b4c5e3Schristosoption prints start/size in hex.
666925666efSjnemethNone of the options have any effect on non-GPT partitions.
66784d8f080SgutteridgeThe order of precedence for the options is:
66853078a20Smartin.Fl a ,
669925666efSjnemeth.Fl i ,
670925666efSjnemeth.Fl l ,
671925666efSjnemeth.Fl g ,
67287b4c5e3Schristos.Fl u ,
67387b4c5e3Schristos.Fl x .
67488085c2fSjnemeth.\" ==== type ====
6751c8d6ff1Schristos.It Nm Ic type Oo Fl a Oc Fl T Ar newtype
67688085c2fSjnemeth.It Nm Ic type Oo Fl b Ar blocknr Oc Oo Fl i Ar index Oc \
677ac204e48SjnemethOo Fl L Ar label Oc Oo Fl s Ar sectors Oc Oo Fl t Ar type Oc \
6781c8d6ff1SchristosFl T Ar newtype
6794d523900Schristos.It Nm Ic type Fl l
68088085c2fSjnemethThe
68188085c2fSjnemeth.Ic type
68288085c2fSjnemethcommand allows the user to change the type of any and all partitions
68388085c2fSjnemeththat match the selection.
68488085c2fSjnemethIt uses the same selection options as the
68588085c2fSjnemeth.Ic label
68688085c2fSjnemethcommand.
68788085c2fSjnemethSee above for a description of these options.
6884d523900SchristosThe
6894d523900Schristos.Fl l
6904d523900Schristosflag lists available types.
6911cb2b941Sjnemeth.\" ==== unset ====
692d48fad1dSmartin.It Nm Ic unset Fl a Ar attribute Oo Fl i Ar index Oc Oo Fl b Ar startsec Oc
6934d523900Schristos.It Nm Ic unset Fl l
6941cb2b941SjnemethThe
6951cb2b941Sjnemeth.Ic unset
6961cb2b941Sjnemethcommand unsets various partition attributes.
6971cb2b941SjnemethThe
6984d523900Schristos.Fl l
6994d523900Schristosflag lists all available attributes.
7004d523900SchristosThe
7011cb2b941Sjnemeth.Fl a
702918b300eSwizoption specifies which attributes to unset and may be specified more than once.
703d48fad1dSmartinAlternatively a comma separated list of attributes can be used.
7041cb2b941SjnemethThe
7051cb2b941Sjnemeth.Fl i
706d48fad1dSmartinor the
707d48fad1dSmartin.Fl b
7081cb2b941Sjnemethoption specifies which entry to update.
7091cb2b941SjnemethThe possible attributes are
7101cb2b941Sjnemeth.Do biosboot Dc ,
7111cb2b941Sjnemeth.Do bootme Dc ,
7124d523900Schristos.Do bootonce Dc ,
7134d523900Schristos.Do bootfailed Dc ,
7144d523900Schristos.Do noblockio Dc , and
7154d523900Schristos.Do required Dc .
7161cb2b941SjnemethThe biosboot flag is used to indicate which partition should be booted
7171cb2b941Sjnemethby legacy BIOS boot code.
7181cb2b941SjnemethSee the
7191cb2b941Sjnemeth.Ic biosboot
7201cb2b941Sjnemethcommand for more information.
7214d523900SchristosThe other attributes are for compatibility with
7221cb2b941Sjnemeth.Fx
7231cb2b941Sjnemethand are not currently used by any
7241cb2b941Sjnemeth.Nx
7251cb2b941Sjnemethcode.
7261cb2b941SjnemethThey may be used by
7271cb2b941Sjnemeth.Nx
7281cb2b941Sjnemethcode in the future.
7297d442200Sjnemeth.\" ==== uuid ====
7307d442200Sjnemeth.It Nm Ic uuid Oo Fl a Oc
731197ad859Schristos.It Nm Ic uuid Oo Fl b Ar blocknr Oc Oo Fl i Ar index Ar Oc \
732197ad859SchristosOo Fl L Ar label Oc Oo Fl s Ar sectors Oc Oo Fl t Ar type Oc \
733197ad859SchristosOo Fl U Ar newuuid Oc
7347d442200SjnemethThe
7357d442200Sjnemeth.Ic uuid
7367d442200Sjnemethcommand allows the user to change the UUID of any and all partitions
7377d442200Sjnemeththat match the selection.
7387d442200SjnemethIt uses the same selection options as the
7397d442200Sjnemeth.Ic label
7407d442200Sjnemethcommand.
7417d442200SjnemethSee above for a description of these options.
7427d442200SjnemethIf
743197ad859Schristos.Ar newuuid
744197ad859Schristosis not specified, a random UUID value is derived from the timestamp
745197ad859Schristos.Po see the
746197ad859Schristos.Fl T
747197ad859Schristosoption
748197ad859Schristos.Pc .
749197ad859SchristosIf
7507d442200Sjnemeth.Fl a
7517d442200Sjnemethis used, then the header UUID is changed as well.
7527d442200Sjnemeth.Pp
7537d442200SjnemethThe primary purpose of this command is for use after cloning a disk to
7547d442200Sjnemethprevent collisions when both disks are used in the same system.
7557d442200Sjnemeth.\" ==== end of commands ====
7565819a8c0Schristos.El
75732e2530eSwiz.Sh EXIT STATUS
75832e2530eSwizThe
75932e2530eSwiz.Nm
76032e2530eSwizcommand exits with a failure status (1) when the header command
76132e2530eSwizis used and no GPT header is found.
7621c825c2cSkreThis can be used to check for the existence of a GPT in shell scripts.
7637b2c1e97Swiz.Sh EXAMPLES
7647b2c1e97Swiz.Bd -literal
7657b2c1e97Swiznas# gpt show wd3
7667b2c1e97Swiz       start        size  index  contents
7677b2c1e97Swiz           0           1         PMBR
7687b2c1e97Swiz           1  3907029167
7697b2c1e97Swiznas# gpt create wd3
7707b2c1e97Swiznas# gpt show wd3
7717b2c1e97Swiz       start        size  index  contents
7727b2c1e97Swiz           0           1         PMBR
7737b2c1e97Swiz           1           1         Pri GPT header
7747b2c1e97Swiz           2          32         Pri GPT table
7757b2c1e97Swiz          34  3907029101
7767b2c1e97Swiz  3907029135          32         Sec GPT table
7777b2c1e97Swiz  3907029167           1         Sec GPT header
7787b2c1e97Swiznas# gpt add -s 10486224 -t swap -i 1 wd3
7797b2c1e97Swiznas# gpt label -i 1 -l swap_1 wd3
780d468dc41Sabhinavpartition 1 on rwd3d labeled swap_1
7817b2c1e97Swiznas# gpt show wd3
7827b2c1e97Swiz       start        size  index  contents
7837b2c1e97Swiz           0           1         PMBR
7847b2c1e97Swiz           1           1         Pri GPT header
7857b2c1e97Swiz           2          32         Pri GPT table
7867b2c1e97Swiz          34    10486224      1  GPT part - NetBSD swap
7877b2c1e97Swiz    10486258  3896542877
7887b2c1e97Swiz  3907029135          32         Sec GPT table
7897b2c1e97Swiz  3907029167           1         Sec GPT header
79034523e4bSjnemethnas# gpt show -l wd3
79134523e4bSjnemeth       start        size  index  contents
79234523e4bSjnemeth           0           1         PMBR
79334523e4bSjnemeth           1           1         Pri GPT header
79434523e4bSjnemeth           2          32         Pri GPT table
79534523e4bSjnemeth          34    10486224      1  GPT part - "swap_1"
79634523e4bSjnemeth    10486258  3896542877
79734523e4bSjnemeth  3907029135          32         Sec GPT table
79834523e4bSjnemeth  3907029167           1         Sec GPT header
7997b2c1e97Swiznas#
8007b2c1e97Swiz.Ed
801d144e17dSmrg.Pp
8028e17bc1aSmartinBooting from GPT on a BIOS system: this creates a bootable partition.
803d144e17dSmrg.Bd -literal
804d144e17dSmrgxotica# gpt create wd1
805d144e17dSmrgxotica# gpt add -b 1024 -l bootroot -t ffs -s 1g wd1
806d144e17dSmrg/dev/rwd1: Partition 1 added: 49f48d5a-b10e-11dc-b99b-0019d1879648 1024 2097152
807d144e17dSmrgxotica ~# dmesg | tail -2
808d144e17dSmrgwd1: GPT GUID: 660e0630-0a3f-47c0-bc52-c88bcec79392
809d144e17dSmrgdk0 at wd1: "bootroot", 2097152 blocks at 1024, type: ffs
810d144e17dSmrgxotica# gpt biosboot -L bootroot wd1
811d144e17dSmrgxotica# newfs dk0
812d144e17dSmrgxotica# installboot /dev/rdk0 /usr/mdec/bootxx_ffsv1
813d144e17dSmrgxotica# mount /dev/dk0 /mnt
814d144e17dSmrgxotica# cp /usr/mdec/boot /mnt
815d144e17dSmrg.Ed
8168e17bc1aSmartin.Pp
8178e17bc1aSmartinNote that
8188e17bc1aSmartin.Ic biosboot
8198e17bc1aSmartinis not needed for UEFI systems.
8205819a8c0Schristos.Sh SEE ALSO
8218049d1e8Sjym.Xr boot 8 ,
822e4ed2565Schristos.Xr dkctl 8 ,
8235819a8c0Schristos.Xr fdisk 8 ,
8248049d1e8Sjym.Xr installboot 8 ,
8255819a8c0Schristos.Xr mount 8 ,
8265819a8c0Schristos.Xr newfs 8 ,
827d144e17dSmrg.Xr swapctl 8
8285819a8c0Schristos.Sh HISTORY
8295819a8c0SchristosThe
8305819a8c0Schristos.Nm
8315819a8c0Schristosutility appeared in
8325819a8c0Schristos.Fx 5.0
8335819a8c0Schristosfor ia64.
834994edde5Ssevan.Nm
835994edde5Ssevanutility first appeared in
836994edde5Ssevan.Nx 5.0 .
8375819a8c0Schristos.Sh BUGS
8385819a8c0SchristosThe development of the
8395819a8c0Schristos.Nm
8405819a8c0Schristosutility is still work in progress.
8415819a8c0SchristosMany necessary features are missing or partially implemented.
8425819a8c0SchristosIn practice this means that the manual page, supposed to describe these
8435819a8c0Schristosfeatures, is farther removed from being complete or useful.
8445819a8c0SchristosAs such, missing functionality is not even documented as missing.
8455819a8c0SchristosHowever, it is believed that the currently present functionality is reliable
8465819a8c0Schristosand stable enough that this tool can be used without bullet-proof footware if
8475819a8c0Schristosone thinks one does not make mistakes.
8485819a8c0Schristos.Pp
8491b683709SgutteridgeIt is expected that the basic usage model will not change, but it is
8505819a8c0Schristospossible that future versions will not be compatible in the strictest sense
8515819a8c0Schristosof the word.
8525819a8c0SchristosAlso, options primarily intended for diagnostic or debug purposes may be
8535819a8c0Schristosremoved in future versions.
8545819a8c0Schristos.Pp
8555819a8c0SchristosAnother possibility is that the current usage model is accompanied by
8565819a8c0Schristosother interfaces to make the tool usable as a back-end.
8575819a8c0SchristosThis all depends on demand and thus feedback.
858