xref: /netbsd-src/sbin/gpt/gpt.8 (revision a5847cc334d9a7029f6352b847e9e8d71a0f9e0c)
1.\" $NetBSD: gpt.8,v 1.9 2011/11/11 13:26:45 wiz Exp $
2.\"
3.\" Copyright (c) 2002 Marcel Moolenaar
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\"
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26.\"
27.\" $FreeBSD: src/sbin/gpt/gpt.8,v 1.17 2006/06/22 22:22:32 marcel Exp $
28.\"
29.Dd November 11, 2011
30.Dt GPT 8
31.Os
32.Sh NAME
33.Nm gpt
34.Nd GUID partition table maintenance utility
35.Sh SYNOPSIS
36.Nm
37.Op Ar general_options
38.Ar command
39.Op Ar command_options
40.Ar device ...
41.Sh DESCRIPTION
42The
43.Nm
44utility provides the necessary functionality to manipulate GUID partition
45tables (GPTs), but see
46.Sx BUGS
47below for how and where functionality is missing.
48The basic usage model of the
49.Nm
50tool follows that of the
51.Xr cvs 1
52tool.
53The general options are described in the following paragraph.
54The remaining paragraphs describe the individual commands with their options.
55Here we conclude by mentioning that a
56.Ar device
57is either a special file
58corresponding to a disk-like device or a regular file.
59The command is applied to each
60.Ar device
61listed on the command line.
62.Ss General Options
63The general options allow the user to change default settings or otherwise
64change the behaviour that is applicable to all commands.
65Not all commands use all default settings, so some general options may not
66have an effect on all commands.
67.Pp
68The
69.Fl p Ar count
70option allows the user to change the number of partitions the GPT can
71accommodate.
72This is used whenever a new GPT is created.
73By default, the
74.Nm
75utility will create space for 128 partitions (or 32 sectors of 512 bytes).
76.Pp
77The
78.Fl r
79option causes the
80.Nm
81utility to open the device for reading only.
82Currently this option is primarily useful for the
83.Ic show
84command, but the intent
85is to use it to implement dry-run behaviour.
86.Pp
87The
88.Fl v
89option controls the verbosity level.
90The level increases with every occurrence of this option.
91There is no formalized definition of the different levels yet.
92.Ss Commands
93.Bl -tag -width indent
94.\" ==== add ====
95.It Nm Ic add Oo Fl b Ar number Oc Oo Fl i Ar index Oc Oo Fl s Ar count Oc \
96Oo Fl t Ar type Oc Ar device ...
97The
98.Ic add
99command allows the user to add a new partition to an existing table.
100By default, it will create a UFS partition covering the first available block
101of an unused disk space.
102The command-specific options can be used to control this behaviour.
103.Pp
104The
105.Fl b Ar number
106option allows the user to specify the starting (beginning) sector number of
107the partition.
108The minimum sector number is 1, but has to fall inside an unused region of
109disk space that is covered by the GPT.
110.Pp
111The
112.Fl i Ar index
113option allows the user to specify which (free) entry in the GPT table is to
114be used for the new partition.
115By default, the first free entry is selected.
116.Pp
117The
118.Fl s Ar count
119option allows the user to specify the size of the partition in sectors.
120The minimum size is 1.
121.Pp
122The
123.Fl t Ar type
124option allows the user to specify the partition type.
125The type is given as an UUID, but
126.Nm
127accepts
128.Cm efi , swap , ufs , hfs , linux ,
129.Cm raid , lfs , ccd , cgd , bios ,
130.Cm ffs ,
131and
132.Cm windows
133as aliases for the most commonly used partition types.
134.\" ==== biosboot ====
135.It Nm Ic biosboot Oo Fl c Ar bootcode Oc Oo Fl i Ar index Oc Ar device ...
136The
137.Ic biosboot
138command allows the user to configure the partition that contains the
139primary bootstrap program, used during
140.Xr boot 8 .
141.Pp
142The
143.Fl c
144option allows the user to specify the filename that
145.Nm
146should read the bootcode from.
147The default is to read from
148.Pa /usr/mdec/mbr_gpt .
149.Pp
150The
151.Fl i
152option selects the partition that should contain the primary
153bootstrap code, as installed via
154.Xr installboot 8 .
155.\" ==== create ====
156.It Nm Ic create Oo Fl fp Oc Ar device ...
157The
158.Ic create
159command allows the user to create a new (empty) GPT.
160By default, one cannot create a GPT when the device contains a MBR,
161however this can be overridden with the
162.Fl f
163option.
164If the
165.Fl f
166option is specified, an existing MBR is destroyed and any partitions
167described by the MBR are lost.
168.Pp
169The
170.Fl p
171option tells
172.Nm
173to create only the primary table and not the backup table.
174This option is only useful for debugging and should not be used otherwise.
175.\" ==== destroy ====
176.It Nm Ic destroy Oo Fl r Oc Ar device ...
177The
178.Ic destroy
179command allows the user to destroy an existing, possibly not empty GPT.
180.Pp
181The
182.Fl r
183option instructs
184.Nm
185to destroy the table in a way that it can be recovered.
186.\" ==== label ====
187.It Nm Ic label Oo Fl a Oc Ao Fl f Ar file | Fl l Ar label Ac Ar device ...
188.It Nm Ic label Oo Fl b Ar number Oc Oo Fl i Ar index Oc \
189Oo Fl s Ar count Oc Oo Fl t Ar type Oc \
190Ao Fl f Ar file | Fl l Ar label Ac Ar device ...
191The
192.Ic label
193command allows the user to label any partitions that match the selection.
194At least one of the following selection options must be specified.
195.Pp
196The
197.Fl a
198option specifies that all partitions should be labeled.
199It is mutually exclusive with all other selection options.
200.Pp
201The
202.Fl b Ar number
203option selects the partition that starts at the given block number.
204.Pp
205The
206.Fl i Ar index
207option selects the partition with the given partition number.
208.Pp
209The
210.Fl s Ar count
211option selects all partitions that have the given size.
212This can cause multiple partitions to be removed.
213.Pp
214The
215.Fl t Ar type
216option selects all partitions that have the given type.
217The type is given as an UUID or by the aliases that the
218.Ic add
219command accepts.
220This can cause multiple partitions to be removed.
221.Pp
222The
223.Fl f Ar file
224or
225.Fl l Ar label
226options specify the new label to be assigned to the selected partitions.
227The
228.Fl f Ar file
229option is used to read the label from the specified file.
230Only the first line is read from the file and the trailing newline
231character is stripped.
232If the file name is the dash or minus sign
233.Pq Fl ,
234the label is read from
235the standard input.
236The
237.Fl l Ar label
238option is used to specify the label in the command line.
239The label is assumed to be encoded in UTF-8.
240.\" ==== migrate ====
241.It Nm Ic migrate Oo Fl fs Oc Ar device ...
242The
243.Ic migrate
244command allows the user to migrate an MBR-based disk partitioning into a
245GPT-based partitioning.
246By default, the MBR is not migrated when it contains partitions of an unknown
247type.
248This can be overridden with the
249.Fl f
250option.
251Specifying the
252.Fl f
253option will cause unknown partitions to be ignored and any data in it
254to be lost.
255.Pp
256The
257.Fl s
258option prevents migrating
259.Bx
260disk labels into GPT partitions by creating
261the GPT equivalent of a slice.
262.\" ==== recover ====
263.It Nm Ic recover Ar device ...
264The
265.Ic recover
266command tries to restore the GPT partition label from the backup
267near the end of the disk.
268It is very useful in case the primary label was deleted.
269.\" ==== remove ====
270.It Nm Ic remove Oo Fl a Oc Ar device ...
271.It Nm Ic remove Oo Fl b Ar number Oc Oo Fl i Ar index Oc \
272Oo Fl s Ar count Oc Oo Fl t Ar type Oc Ar device ...
273The
274.Ic remove
275command allows the user to remove any and all partitions that match the
276selection.
277It uses the same selection options as the
278.Ic label
279command.
280See above for a description of these options.
281Partitions are removed by clearing the partition type.
282No other information is changed.
283.\" ==== show ====
284.It Nm Ic show Oo Fl lu Oc Ar device ...
285The
286.Ic show
287command displays the current partitioning on the listed devices and gives
288an overall view of the disk contents.
289With the
290.Fl l
291option the GPT partition label will be displayed instead of the GPT partition
292type.
293The option has no effect on non-GPT partitions.
294With the
295.Fl u
296option the GPT partition type is displayed as an UUID instead of in a
297user friendly form.
298The
299.Fl l
300option takes precedence over the
301.Fl u
302option.
303.El
304.Sh EXAMPLES
305.Bd -literal
306nas# gpt show wd3
307       start        size  index  contents
308           0           1         PMBR
309           1  3907029167
310nas# gpt create wd3
311nas# gpt show wd3
312       start        size  index  contents
313           0           1         PMBR
314           1           1         Pri GPT header
315           2          32         Pri GPT table
316          34  3907029101
317  3907029135          32         Sec GPT table
318  3907029167           1         Sec GPT header
319nas# gpt add -s 10486224 -t swap -i 1 wd3
320Partition added, use:
321        dkctl rwd3d addwedge dk<N> 34 10486224 <type>
322to create a wedge for it
323nas# gpt label -i 1 -l swap_1 wd3
324parition 1 on rwd3d labeled swap_1
325nas# gpt show wd3
326       start        size  index  contents
327           0           1         PMBR
328           1           1         Pri GPT header
329           2          32         Pri GPT table
330          34    10486224      1  GPT part - NetBSD swap
331    10486258  3896542877
332  3907029135          32         Sec GPT table
333  3907029167           1         Sec GPT header
334nas#
335.Ed
336.Sh SEE ALSO
337.Xr boot 8 ,
338.Xr fdisk 8 ,
339.Xr installboot 8 ,
340.Xr mount 8 ,
341.Xr newfs 8 ,
342.Xr swapon 8
343.Sh HISTORY
344The
345.Nm
346utility appeared in
347.Fx 5.0
348for ia64.
349.Sh BUGS
350The development of the
351.Nm
352utility is still work in progress.
353Many necessary features are missing or partially implemented.
354In practice this means that the manual page, supposed to describe these
355features, is farther removed from being complete or useful.
356As such, missing functionality is not even documented as missing.
357However, it is believed that the currently present functionality is reliable
358and stable enough that this tool can be used without bullet-proof footware if
359one thinks one does not make mistakes.
360.Pp
361It is expected that the basic usage model does not change, but it is
362possible that future versions will not be compatible in the strictest sense
363of the word.
364For example, the
365.Fl p Ar count
366option may be changed to a command option rather than a generic option.
367There are only two commands that use it so there is a chance that the natural
368tendency for people is to use it as a command option.
369Also, options primarily intended for diagnostic or debug purposes may be
370removed in future versions.
371.Pp
372Another possibility is that the current usage model is accompanied by
373other interfaces to make the tool usable as a back-end.
374This all depends on demand and thus feedback.
375