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