]> CyberLeo.Net >> Repos - FreeBSD/releng/10.1.git/blob - sbin/geom/class/part/gpart.8
Copy stable/10@r272459 to releng/10.1 as part of
[FreeBSD/releng/10.1.git] / sbin / geom / class / part / gpart.8
1 .\" Copyright (c) 2007, 2008 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 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD$
26 .\"
27 .Dd August 12, 2014
28 .Dt GPART 8
29 .Os
30 .Sh NAME
31 .Nm gpart
32 .Nd "control utility for the disk partitioning GEOM class"
33 .Sh SYNOPSIS
34 .\" ==== ADD ====
35 .Nm
36 .Cm add
37 .Fl t Ar type
38 .Op Fl a Ar alignment
39 .Op Fl b Ar start
40 .Op Fl s Ar size
41 .Op Fl i Ar index
42 .Op Fl l Ar label
43 .Op Fl f Ar flags
44 .Ar geom
45 .\" ==== BACKUP ====
46 .Nm
47 .Cm backup
48 .Ar geom
49 .\" ==== BOOTCODE ====
50 .Nm
51 .Cm bootcode
52 .Op Fl b Ar bootcode
53 .Op Fl p Ar partcode Fl i Ar index
54 .Op Fl f Ar flags
55 .Ar geom
56 .\" ==== COMMIT ====
57 .Nm
58 .Cm commit
59 .Ar geom
60 .\" ==== CREATE ====
61 .Nm
62 .Cm create
63 .Fl s Ar scheme
64 .Op Fl n Ar entries
65 .Op Fl f Ar flags
66 .Ar provider
67 .\" ==== DELETE ====
68 .Nm
69 .Cm delete
70 .Fl i Ar index
71 .Op Fl f Ar flags
72 .Ar geom
73 .\" ==== DESTROY ====
74 .Nm
75 .Cm destroy
76 .Op Fl F
77 .Op Fl f Ar flags
78 .Ar geom
79 .\" ==== MODIFY ====
80 .Nm
81 .Cm modify
82 .Fl i Ar index
83 .Op Fl l Ar label
84 .Op Fl t Ar type
85 .Op Fl f Ar flags
86 .Ar geom
87 .\" ==== RECOVER ====
88 .Nm
89 .Cm recover
90 .Op Fl f Ar flags
91 .Ar geom
92 .\" ==== RESIZE ====
93 .Nm
94 .Cm resize
95 .Fl i Ar index
96 .Op Fl a Ar alignment
97 .Op Fl s Ar size
98 .Op Fl f Ar flags
99 .Ar geom
100 .\" ==== RESTORE ====
101 .Nm
102 .Cm restore
103 .Op Fl lF
104 .Op Fl f Ar flags
105 .Ar provider
106 .Op Ar ...
107 .\" ==== SET ====
108 .Nm
109 .Cm set
110 .Fl a Ar attrib
111 .Fl i Ar index
112 .Op Fl f Ar flags
113 .Ar geom
114 .\" ==== SHOW ====
115 .Nm
116 .Cm show
117 .Op Fl l | r
118 .Op Fl p
119 .Op Ar geom ...
120 .\" ==== UNDO ====
121 .Nm
122 .Cm undo
123 .Ar geom
124 .\" ==== UNSET ====
125 .Nm
126 .Cm unset
127 .Fl a Ar attrib
128 .Fl i Ar index
129 .Op Fl f Ar flags
130 .Ar geom
131 .\"
132 .Nm
133 .Cm list
134 .Nm
135 .Cm status
136 .Nm
137 .Cm load
138 .Nm
139 .Cm unload
140 .Sh DESCRIPTION
141 The
142 .Nm
143 utility is used to partition GEOM providers, normally disks.
144 The first argument is the action to be taken:
145 .Bl -tag -width ".Cm bootcode"
146 .\" ==== ADD ====
147 .It Cm add
148 Add a new partition to the partitioning scheme given by
149 .Ar geom .
150 The partition begins on the logical block address given by the
151 .Fl b Ar start
152 option.
153 Its size is given by the
154 .Fl s Ar size
155 option.
156 SI unit suffixes are allowed.
157 One or both
158 .Fl b
159 and
160 .Fl s
161 options can be omitted.
162 If so they are automatically calculated.
163 The type of the partition is given by the
164 .Fl t Ar type
165 option.
166 Partition types are discussed below in the section entitled
167 .Sx "PARTITION TYPES" .
168 .Pp
169 Additional options include:
170 .Bl -tag -width 12n
171 .It Fl a Ar alignment
172 If specified, then
173 .Nm
174 utility tries to align
175 .Ar start
176 offset and partition
177 .Ar size
178 to be multiple of
179 .Ar alignment
180 value.
181 .It Fl i Ar index
182 The index in the partition table at which the new partition is to be
183 placed.
184 The index determines the name of the device special file used
185 to represent the partition.
186 .It Fl l Ar label
187 The label attached to the partition.
188 This option is only valid when used on partitioning schemes that support
189 partition labels.
190 .It Fl f Ar flags
191 Additional operational flags.
192 See the section entitled
193 .Sx "OPERATIONAL FLAGS"
194 below for a discussion
195 about its use.
196 .El
197 .\" ==== BACKUP ====
198 .It Cm backup
199 Dump a partition table to standard output in a special format used by the
200 .Cm restore
201 action.
202 .\" ==== BOOTCODE ====
203 .It Cm bootcode
204 Embed bootstrap code into the partitioning scheme's metadata on the
205 .Ar geom
206 (using
207 .Fl b Ar bootcode )
208 or write bootstrap code into a partition (using
209 .Fl p Ar partcode
210 and
211 .Fl i Ar index ) .
212 Not all partitioning schemes have embedded bootstrap code, so the
213 .Fl b Ar bootcode
214 option is scheme-specific in nature (see the section entitled
215 .Sx BOOTSTRAPPING
216 below).
217 The
218 .Fl b Ar bootcode
219 option specifies a file that contains the bootstrap code.
220 The contents and size of the file are determined by the partitioning
221 scheme.
222 The
223 .Fl p Ar partcode
224 option specifies a file that contains the bootstrap code intended to be
225 written to a partition.
226 The partition is specified by the
227 .Fl i Ar index
228 option.
229 The size of the file must be smaller than the size of the partition.
230 .Pp
231 Additional options include:
232 .Bl -tag -width 10n
233 .It Fl f Ar flags
234 Additional operational flags.
235 See the section entitled
236 .Sx "OPERATIONAL FLAGS"
237 below for a discussion
238 about its use.
239 .El
240 .\" ==== COMMIT ====
241 .It Cm commit
242 Commit any pending changes for geom
243 .Ar geom .
244 All actions are committed by default and will not result in
245 pending changes.
246 Actions can be modified with the
247 .Fl f Ar flags
248 option so that they are not committed, but become pending.
249 Pending changes are reflected by the geom and the
250 .Nm
251 utility, but they are not actually written to disk.
252 The
253 .Cm commit
254 action will write all pending changes to disk.
255 .\" ==== CREATE ====
256 .It Cm create
257 Create a new partitioning scheme on a provider given by
258 .Ar provider .
259 The
260 .Fl s Ar scheme
261 option determines the scheme to use.
262 The kernel must have support for a particular scheme before
263 that scheme can be used to partition a disk.
264 .Pp
265 Additional options include:
266 .Bl -tag -width 10n
267 .It Fl n Ar entries
268 The number of entries in the partition table.
269 Every partitioning scheme has a minimum and maximum number of entries.
270 This option allows tables to be created with a number of entries
271 that is within the limits.
272 Some schemes have a maximum equal to the minimum and some schemes have
273 a maximum large enough to be considered unlimited.
274 By default, partition tables are created with the minimum number of
275 entries.
276 .It Fl f Ar flags
277 Additional operational flags.
278 See the section entitled
279 .Sx "OPERATIONAL FLAGS"
280 below for a discussion
281 about its use.
282 .El
283 .\" ==== DELETE ====
284 .It Cm delete
285 Delete a partition from geom
286 .Ar geom
287 and further identified by the
288 .Fl i Ar index
289 option.
290 The partition cannot be actively used by the kernel.
291 .Pp
292 Additional options include:
293 .Bl -tag -width 10n
294 .It Fl f Ar flags
295 Additional operational flags.
296 See the section entitled
297 .Sx "OPERATIONAL FLAGS"
298 below for a discussion
299 about its use.
300 .El
301 .\" ==== DESTROY ====
302 .It Cm destroy
303 Destroy the partitioning scheme as implemented by geom
304 .Ar geom .
305 .Pp
306 Additional options include:
307 .Bl -tag -width 10n
308 .It Fl F
309 Forced destroying of the partition table even if it is not empty.
310 .It Fl f Ar flags
311 Additional operational flags.
312 See the section entitled
313 .Sx "OPERATIONAL FLAGS"
314 below for a discussion
315 about its use.
316 .El
317 .\" ==== MODIFY ====
318 .It Cm modify
319 Modify a partition from geom
320 .Ar geom
321 and further identified by the
322 .Fl i Ar index
323 option.
324 Only the type and/or label of the partition can be modified.
325 To change the type of a partition, specify the new type with the
326 .Fl t Ar type
327 option.
328 To change the label of a partition, specify the new label with the
329 .Fl l Ar label
330 option.
331 Not all partitioning schemes support labels and it is invalid to
332 try to change a partition label in such cases.
333 .Pp
334 Additional options include:
335 .Bl -tag -width 10n
336 .It Fl f Ar flags
337 Additional operational flags.
338 See the section entitled
339 .Sx "OPERATIONAL FLAGS"
340 below for a discussion
341 about its use.
342 .El
343 .\" ==== RECOVER ====
344 .It Cm recover
345 Recover a corrupt partition's scheme metadata on the geom
346 .Ar geom .
347 See the section entitled
348 .Sx RECOVERING
349 below for the additional information.
350 .Pp
351 Additional options include:
352 .Bl -tag -width 10n
353 .It Fl f Ar flags
354 Additional operational flags.
355 See the section entitled
356 .Sx "OPERATIONAL FLAGS"
357 below for a discussion
358 about its use.
359 .El
360 .\" ==== RESIZE ====
361 .It Cm resize
362 Resize a partition from geom
363 .Ar geom
364 and further identified by the
365 .Fl i Ar index
366 option.
367 New partition size is expressed in logical block
368 numbers and can be given by the
369 .Fl s Ar size
370 option.
371 If
372 .Fl s
373 option is omitted then new size is automatically calculated
374 to maximum available from given geom
375 .Ar geom .
376 .Pp
377 Additional options include:
378 .Bl -tag -width 12n
379 .It Fl a Ar alignment
380 If specified, then
381 .Nm
382 utility tries to align partition
383 .Ar size
384 to be multiple of
385 .Ar alignment
386 value.
387 .It Fl f Ar flags
388 Additional operational flags.
389 See the section entitled
390 .Sx "OPERATIONAL FLAGS"
391 below for a discussion
392 about its use.
393 .El
394 .\" ==== RESTORE ====
395 .It Cm restore
396 Restore the partition table from a backup previously created by the
397 .Cm backup
398 action and read from standard input.
399 Only the partition table is restored.
400 This action does not affect the content of partitions.
401 After restoring the partition table and writing bootcode if needed,
402 user data must be restored from backup.
403 .Pp
404 Additional options include:
405 .Bl -tag -width 10n
406 .It Fl F
407 Destroy partition table on the given
408 .Ar provider
409 before doing restore.
410 .It Fl l
411 Restore partition labels for partitioning schemes that support them.
412 .It Fl f Ar flags
413 Additional operational flags.
414 See the section entitled
415 .Sx "OPERATIONAL FLAGS"
416 below for a discussion
417 about its use.
418 .El
419 .\" ==== SET ====
420 .It Cm set
421 Set the named attribute on the partition entry.
422 See the section entitled
423 .Sx ATTRIBUTES
424 below for a list of available attributes.
425 .Pp
426 Additional options include:
427 .Bl -tag -width 10n
428 .It Fl f Ar flags
429 Additional operational flags.
430 See the section entitled
431 .Sx "OPERATIONAL FLAGS"
432 below for a discussion
433 about its use.
434 .El
435 .\" ==== SHOW ====
436 .It Cm show
437 Show current partition information for the specified geoms, or all
438 geoms if none are specified.
439 The default output includes the logical starting block of each
440 partition, the partition size in blocks, the partition index number,
441 the partition type, and a human readable partition size.
442 Block sizes and locations are based on the device's Sectorsize
443 as shown by
444 .Cm gpart list .
445 Additional options include:
446 .Bl -tag -width 10n
447 .It Fl l
448 For partitioning schemes that support partition labels, print them
449 instead of partition type.
450 .It Fl p
451 Show provider names instead of partition indexes.
452 .It Fl r
453 Show raw partition type instead of symbolic name.
454 .El
455 .\" ==== UNDO ====
456 .It Cm undo
457 Revert any pending changes for geom
458 .Ar geom .
459 This action is the opposite of the
460 .Cm commit
461 action and can be used to undo any changes that have not been committed.
462 .\" ==== UNSET ====
463 .It Cm unset
464 Clear the named attribute on the partition entry.
465 See the section entitled
466 .Sx ATTRIBUTES
467 below for a list of available attributes.
468 .Pp
469 Additional options include:
470 .Bl -tag -width 10n
471 .It Fl f Ar flags
472 Additional operational flags.
473 See the section entitled
474 .Sx "OPERATIONAL FLAGS"
475 below for a discussion
476 about its use.
477 .El
478 .It Cm list
479 See
480 .Xr geom 8 .
481 .It Cm status
482 See
483 .Xr geom 8 .
484 .It Cm load
485 See
486 .Xr geom 8 .
487 .It Cm unload
488 See
489 .Xr geom 8 .
490 .El
491 .Sh PARTITIONING SCHEMES
492 Several partitioning schemes are supported by the
493 .Nm
494 utility:
495 .Bl -tag -width ".Cm VTOC8"
496 .It Cm APM
497 Apple Partition Map, used by PowerPC(R) Macintosh(R) computers.
498 Requires the
499 .Cd GEOM_PART_APM
500 kernel option.
501 .It Cm BSD
502 Traditional BSD disklabel, usually used to subdivide MBR partitions.
503 .Po
504 This scheme can also be used as the sole partitioning method, without
505 an MBR.
506 Partition editing tools from other operating systems often do not
507 understand the bare disklabel partition layout, so this is sometimes
508 called
509 .Dq dangerously dedicated .
510 .Pc
511 Requires the
512 .Cm GEOM_PART_BSD
513 kernel option.
514 .It Cm BSD64
515 64-bit implementation of BSD disklabel used in DragonFlyBSD to subdivide MBR
516 or GPT partitions.
517 Requires the
518 .Cm GEOM_PART_BSD64
519 kernel option.
520 .It Cm LDM
521 The Logical Disk Manager is an implementation of volume manager for
522 Microsoft Windows NT.
523 Requires the
524 .Cd GEOM_PART_LDM
525 kernel option.
526 .It Cm GPT
527 GUID Partition Table is used on Intel-based Macintosh computers and
528 gradually replacing MBR on most PCs and other systems.
529 Requires the
530 .Cm GEOM_PART_GPT
531 kernel option.
532 .It Cm MBR
533 Master Boot Record is used on PCs and removable media.
534 Requires the
535 .Cm GEOM_PART_MBR
536 kernel option.
537 The
538 .Cm GEOM_PART_EBR
539 option adds support for the Extended Boot Record (EBR),
540 which is used to define a logical partition.
541 The
542 .Cm GEOM_PART_EBR_COMPAT
543 option enables backward compatibility for partition names
544 in the EBR scheme.
545 It also prevents any type of actions on such partitions.
546 .It Cm PC98
547 An MBR variant for NEC PC-98 and compatible computers.
548 Requires the
549 .Cm GEOM_PART_PC98
550 kernel option.
551 .It Cm VTOC8
552 Sun's SMI Volume Table Of Contents, used by
553 .Tn SPARC64
554 and
555 .Tn UltraSPARC
556 computers.
557 Requires the
558 .Cm GEOM_PART_VTOC8
559 kernel option.
560 .El
561 .Sh PARTITION TYPES
562 Partition types are identified on disk by particular strings or magic
563 values.
564 The
565 .Nm
566 utility uses symbolic names for common partition types so the user
567 does not need to know these values or other details of the partitioning
568 scheme in question.
569 The
570 .Nm
571 utility also allows the user to specify scheme-specific partition types
572 for partition types that do not have symbolic names.
573 Symbolic names currently understood and used by
574 .Fx
575 are:
576 .Bl -tag -width ".Cm dragonfly-disklabel64"
577 .It Cm apple-boot
578 The system partition dedicated to storing boot loaders on some Apple
579 systems.
580 The scheme-specific types are
581 .Qq Li "!171"
582 for MBR,
583 .Qq Li "!Apple_Bootstrap"
584 for APM, and
585 .Qq Li "!426f6f74-0000-11aa-aa11-00306543ecac"
586 for GPT.
587 .It Cm bios-boot
588 The system partition dedicated to second stage of the boot loader program.
589 Usually it is used by the GRUB 2 loader for GPT partitioning schemes.
590 The scheme-specific type is
591 .Qq Li "!21686148-6449-6E6F-744E-656564454649" .
592 .It Cm efi
593 The system partition for computers that use the Extensible Firmware
594 Interface (EFI).
595 In such cases, the GPT partitioning scheme is used and the
596 actual partition type for the system partition can also be specified as
597 .Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93b" .
598 .It Cm freebsd
599 A
600 .Fx
601 partition subdivided into filesystems with a
602 .Bx
603 disklabel.
604 This is a legacy partition type and should not be used for the APM
605 or GPT schemes.
606 The scheme-specific types are
607 .Qq Li "!165"
608 for MBR,
609 .Qq Li "!FreeBSD"
610 for APM, and
611 .Qq Li "!516e7cb4-6ecf-11d6-8ff8-00022d09712b"
612 for GPT.
613 .It Cm freebsd-boot
614 A
615 .Fx
616 partition dedicated to bootstrap code.
617 The scheme-specific type is
618 .Qq Li "!83bd6b9d-7f41-11dc-be0b-001560b84f0f"
619 for GPT.
620 .It Cm freebsd-swap
621 A
622 .Fx
623 partition dedicated to swap space.
624 The scheme-specific types are
625 .Qq Li "!FreeBSD-swap"
626 for APM,
627 .Qq Li "!516e7cb5-6ecf-11d6-8ff8-00022d09712b"
628 for GPT, and tag 0x0901 for VTOC8.
629 .It Cm freebsd-ufs
630 A
631 .Fx
632 partition that contains a UFS or UFS2 filesystem.
633 The scheme-specific types are
634 .Qq Li "!FreeBSD-UFS"
635 for APM,
636 .Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b"
637 for GPT, and tag 0x0902 for VTOC8.
638 .It Cm freebsd-vinum
639 A
640 .Fx
641 partition that contains a Vinum volume.
642 The scheme-specific types are
643 .Qq Li "!FreeBSD-Vinum"
644 for APM,
645 .Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b"
646 for GPT, and tag 0x0903 for VTOC8.
647 .It Cm freebsd-zfs
648 A
649 .Fx
650 partition that contains a ZFS volume.
651 The scheme-specific types are
652 .Qq Li "!FreeBSD-ZFS"
653 for APM,
654 .Qq Li "!516e7cba-6ecf-11d6-8ff8-00022d09712b"
655 for GPT, and 0x0904 for VTOC8.
656 .El
657 .Pp
658 Another symbolic names that can be used with
659 .Cm gpart
660 utility are:
661 .Bl -tag -width ".Cm dragonfly-disklabel64"
662 .It Cm apple-boot
663 An Apple Mac OS X partition dedicated to bootloader.
664 The scheme-specific types are
665 .Qq Li "!Apple_Bootstrap"
666 for APM and
667 .Qq Li "!426f6f74-0000-11aa-aa11-00306543ecac"
668 for GPT.
669 .It Cm apple-hfs
670 An Apple Mac OS X partition that contains a HFS or HFS+ filesystem.
671 The scheme-specific types are
672 .Qq Li "!Apple_HFS"
673 for APM and
674 .Qq Li "!48465300-0000-11aa-aa11-00306543ecac"
675 for GPT.
676 .It Cm apple-label
677 An Apple Mac OS X partition dedicated to partition metadata that descibes
678 disk device.
679 The scheme-specific type is
680 .Qq Li "!4c616265-6c00-11aa-aa11-00306543ecac"
681 for GPT.
682 .It Cm apple-raid
683 An Apple Mac OS X partition used in a software RAID configuration.
684 The scheme-specific type is
685 .Qq Li "!52414944-0000-11aa-aa11-00306543ecac"
686 for GPT.
687 .It Cm apple-raid-offline
688 An Apple Mac OS X partition used in a software RAID configuration.
689 The scheme-specific type is
690 .Qq Li "!52414944-5f4f-11aa-aa11-00306543ecac"
691 for GPT.
692 .It Cm apple-tv-recovery
693 An Apple Mac OS X partition used by Apple TV.
694 The scheme-specific type is
695 .Qq Li "!5265636f-7665-11aa-aa11-00306543ecac"
696 for GPT.
697 .It Cm apple-ufs
698 An Apple Mac OS X partition that contains a UFS filesystem.
699 The scheme-specific types are
700 .Qq Li "!Apple_UNIX_SVR2"
701 for APM and
702 .Qq Li "!55465300-0000-11aa-aa11-00306543ecac"
703 for GPT.
704 .It Cm dragonfly-label32
705 A DragonFlyBSD partition subdivided into filesystems with a
706 .Bx
707 disklabel.
708 The scheme-specific type is
709 .Qq Li "!9d087404-1ca5-11dc-8817-01301bb8a9f5"
710 for GPT.
711 .It Cm dragonfly-label64
712 A DragonFlyBSD partition subdivided into filesystems with a
713 disklabel64.
714 The scheme-specific type is
715 .Qq Li "!3d48ce54-1d16-11dc-8696-01301bb8a9f5"
716 for GPT.
717 .It Cm dragonfly-legacy
718 A legacy partition type used in DragonFlyBSD.
719 The scheme-specific type is
720 .Qq Li "!bd215ab2-1d16-11dc-8696-01301bb8a9f5"
721 for GPT.
722 .It Cm dragonfly-ccd
723 A DragonFlyBSD partition used with Concatenated Disk driver.
724 The scheme-specific type is
725 .Qq Li "!dbd5211b-1ca5-11dc-8817-01301bb8a9f5"
726 for GPT.
727 .It Cm dragonfly-hammer
728 A DragonFlyBSD partition that contains a Hammer filesystem.
729 The scheme-specific type is
730 .Qq Li "!61dc63ac-6e38-11dc-8513-01301bb8a9f5"
731 for GPT.
732 .It Cm dragonfly-hammer2
733 A DragonFlyBSD partition that contains a Hammer2 filesystem.
734 The scheme-specific type is
735 .Qq Li "!5cbb9ad1-862d-11dc-a94d-01301bb8a9f5"
736 for GPT.
737 .It Cm dragonfly-swap
738 A DragonFlyBSD partition dedicated to swap space.
739 The scheme-specific type is
740 .Qq Li "!9d58fdbd-1ca5-11dc-8817-01301bb8a9f5"
741 for GPT.
742 .It Cm dragonfly-ufs
743 A DragonFlyBSD partition that contains an UFS1 filesystem.
744 The scheme-specific type is
745 .Qq Li "!9d94ce7c-1ca5-11dc-8817-01301bb8a9f5"
746 for GPT.
747 .It Cm dragonfly-vinum
748 A DragonFlyBSD partition used with Logical Volume Manager.
749 The scheme-specific type is
750 .Qq Li "!9dd4478f-1ca5-11dc-8817-01301bb8a9f5"
751 for GPT.
752 .It Cm ebr
753 A partition subdivided into filesystems with a EBR.
754 The scheme-specific type is
755 .Qq Li "!5"
756 for MBR.
757 .It Cm fat16
758 A partition that contains a FAT16 filesystem.
759 The scheme-specific type is
760 .Qq Li "!6"
761 for MBR.
762 .It Cm fat32
763 A partition that contains a FAT32 filesystem.
764 The scheme-specific type is
765 .Qq Li "!11"
766 for MBR.
767 .It Cm linux-data
768 A Linux partition that contains some filesystem with data.
769 The scheme-specific types are
770 .Qq Li "!131"
771 for MBR and
772 .Qq Li "!0fc63daf-8483-4772-8e79-3d69d8477de4"
773 for GPT.
774 .It Cm linux-lvm
775 A Linux partition dedicated to Logical Volume Manager.
776 The scheme-specific types are
777 .Qq Li "!142"
778 for MBR and
779 .Qq Li "!e6d6d379-f507-44c2-a23c-238f2a3df928"
780 for GPT.
781 .It Cm linux-raid
782 A Linux partition used in a software RAID configuration.
783 The scheme-specific types are
784 .Qq Li "!253"
785 for MBR and
786 .Qq Li "!a19d880f-05fc-4d3b-a006-743f0f84911e"
787 for GPT.
788 .It Cm linux-swap
789 A Linux partition dedicated to swap space.
790 The scheme-specific types are
791 .Qq Li "!130"
792 for MBR and
793 .Qq Li "!0657fd6d-a4ab-43c4-84e5-0933c84b4f4f"
794 for GPT.
795 .It Cm mbr
796 A partition that is sub-partitioned by a Master Boot Record (MBR).
797 This type is known as
798 .Qq Li "!024dee41-33e7-11d3-9d69-0008c781f39f"
799 by GPT.
800 .It Cm ms-basic-data
801 A basic data partition (BDP) for Microsoft operating systems.
802 In the GPT this type is the equivalent to partition types
803 .Cm fat16 , fat32
804 and
805 .Cm ntfs
806 in MBR.
807 The scheme-specific type is
808 .Qq Li "!ebd0a0a2-b9e5-4433-87c0-68b6b72699c7"
809 for GPT.
810 .It Cm ms-ldm-data
811 A partition that contains Logical Disk Manager (LDM) volumes.
812 The scheme-specific types are
813 .Qq Li "!66"
814 for MBR,
815 .Qq Li "!af9b60a0-1431-4f62-bc68-3311714a69ad"
816 for GPT.
817 .It Cm ms-ldm-metadata
818 A partition that contains Logical Disk Manager (LDM) database.
819 The scheme-specific type is
820 .Qq Li "!5808c8aa-7e8f-42e0-85d2-e1e90434cfb3"
821 for GPT.
822 .It Cm netbsd-ccd
823 A NetBSD partition used with Concatenated Disk driver.
824 The scheme-specific type is
825 .Qq Li "!2db519c4-b10f-11dc-b99b-0019d1879648"
826 for GPT.
827 .It Cm netbsd-cgd
828 An encrypted NetBSD partition.
829 The scheme-specific type is
830 .Qq Li "!2db519ec-b10f-11dc-b99b-0019d1879648"
831 for GPT.
832 .It Cm netbsd-ffs
833 A NetBSD partition that contains an UFS filesystem.
834 The scheme-specific type is
835 .Qq Li "!49f48d5a-b10e-11dc-b99b-0019d1879648"
836 for GPT.
837 .It Cm netbsd-lfs
838 A NetBSD partition that contains an LFS filesystem.
839 The scheme-specific type is
840 .Qq Li "!49f48d82-b10e-11dc-b99b-0019d1879648"
841 for GPT.
842 .It Cm netbsd-raid
843 A NetBSD partition used in a software RAID configuration.
844 The scheme-specific type is
845 .Qq Li "!49f48daa-b10e-11dc-b99b-0019d1879648"
846 for GPT.
847 .It Cm netbsd-swap
848 A NetBSD partition dedicated to swap space.
849 The scheme-specific type is
850 .Qq Li "!49f48d32-b10e-11dc-b99b-0019d1879648"
851 for GPT.
852 .It Cm ntfs
853 A partition that contains a NTFS or exFAT filesystem.
854 The scheme-specific type is
855 .Qq Li "!7"
856 for MBR.
857 .It Cm prep-boot
858 The system partition dedicated to storing boot loaders on some PowerPC systems,
859 notably those made by IBM.
860 The scheme-specific types are
861 .Qq Li "!65"
862 for MBR and
863 .Qq Li "!0x9e1a2d38-c612-4316-aa26-8b49521e5a8b"
864 for GPT.
865 .It Cm vmware-vmfs
866 A partition that contains a VMware File System (VMFS).
867 The scheme-specific types are
868 .Qq Li "!251"
869 for MBR and
870 .Qq Li "!aa31e02a-400f-11db-9590-000c2911d1b8"
871 for GPT.
872 .It Cm vmware-vmkdiag
873 A partition that contains a VMware diagostic filesystem.
874 The scheme-specific types are
875 .Qq Li "!252"
876 for MBR and
877 .Qq Li "!9d275380-40ad-11db-bf97-000c2911d1b8"
878 for GPT.
879 .It Cm vmware-reserved
880 A VMware reserved partition.
881 The scheme-specific type is
882 .Qq Li "!9198effc-31c0-11db-8f-78-000c2911d1b8"
883 for GPT.
884 .It Cm vmware-vsanhdr
885 A partition claimed by VMware VSAN.
886 The scheme-specific type is
887 .Qq Li "!381cfccc-7288-11e0-92ee-000c2911d0b2"
888 for GPT.
889 .El
890 .Sh ATTRIBUTES
891 The scheme-specific attributes for EBR:
892 .Bl -tag -width ".Cm active"
893 .It Cm active
894 .El
895 .Pp
896 The scheme-specific attributes for GPT:
897 .Bl -tag -width ".Cm bootfailed"
898 .It Cm bootme
899 When set, the
900 .Nm gptboot
901 stage 1 boot loader will try to boot the system from this partition.
902 Multiple partitions can be marked with the
903 .Cm bootme
904 attribute.
905 See
906 .Xr gptboot 8
907 for more details.
908 .It Cm bootonce
909 Setting this attribute automatically sets the
910 .Cm bootme
911 attribute.
912 When set, the
913 .Nm gptboot
914 stage 1 boot loader will try to boot the system from this partition only once.
915 Multiple partitions can be marked with the
916 .Cm bootonce
917 and
918 .Cm bootme
919 attribute pairs.
920 See
921 .Xr gptboot 8
922 for more details.
923 .It Cm bootfailed
924 This attribute should not be manually managed.
925 It is managed by the
926 .Nm gptboot
927 stage 1 boot loader and the
928 .Pa /etc/rc.d/gptboot
929 start-up script.
930 See
931 .Xr gptboot 8
932 for more details.
933 .El
934 .Pp
935 The scheme-specific attributes for MBR:
936 .Bl -tag -width ".Cm active"
937 .It Cm active
938 .El
939 .Pp
940 The scheme-specific attributes for PC98:
941 .Bl -tag -width ".Cm bootable"
942 .It Cm active
943 .It Cm bootable
944 .El
945 .Sh BOOTSTRAPPING
946 .Fx
947 supports several partitioning schemes and each scheme uses different
948 bootstrap code.
949 The bootstrap code is located in a specific disk area for each partitioning
950 scheme, and may vary in size for different schemes.
951 .Pp
952 Bootstrap code can be separated into two types.
953 The first type is embedded in the partitioning scheme's metadata, while the
954 second type is located on a specific partition.
955 Embedding bootstrap code should only be done with the
956 .Cm gpart bootcode
957 command with the
958 .Fl b Ar bootcode
959 option.
960 The GEOM PART class knows how to safely embed bootstrap code into
961 specific partitioning scheme metadata without causing any damage.
962 .Pp
963 The Master Boot Record (MBR) uses a 512-byte bootstrap code image, embedded
964 into the partition table's metadata area.
965 There are two variants of this bootstrap code:
966 .Pa /boot/mbr
967 and
968 .Pa /boot/boot0 .
969 .Pa /boot/mbr
970 searches for a partition with the
971 .Cm active
972 attribute (see the
973 .Sx ATTRIBUTES
974 section) in the partition table.
975 Then it runs next bootstrap stage.
976 The
977 .Pa /boot/boot0
978 image contains a boot manager with some additional interactive functions
979 for multi-booting from a user-selected partition.
980 .Pp
981 A BSD disklabel is usually created inside an MBR partition (slice)
982 with type
983 .Cm freebsd
984 (see the
985 .Sx "PARTITION TYPES"
986 section).
987 It uses 8 KB size bootstrap code image
988 .Pa /boot/boot ,
989 embedded into the partition table's metadata area.
990 .Pp
991 Both types of bootstrap code are used to boot from the GUID Partition Table.
992 First, a protective MBR is embedded into the first disk sector from the
993 .Pa /boot/pmbr
994 image.
995 It searches through the GPT for a
996 .Cm freebsd-boot
997 partition (see the
998 .Sx "PARTITION TYPES"
999 section) and runs the next bootstrap stage from it.
1000 The
1001 .Cm freebsd-boot
1002 partition should be smaller than 545 KB.
1003 It can be located either before or after other
1004 .Fx
1005 partitions on the disk.
1006 There are two variants of bootstrap code to write to this partition:
1007 .Pa /boot/gptboot
1008 and
1009 .Pa /boot/gptzfsboot .
1010 .Pp
1011 .Pa /boot/gptboot
1012 is used to boot from UFS partitions.
1013 .Cm gptboot
1014 searches through
1015 .Cm freebsd-ufs
1016 partitions in the GPT and selects one to boot based on the
1017 .Cm bootonce
1018 and
1019 .Cm bootme
1020 attributes.
1021 If neither attribute is found,
1022 .Pa /boot/gptboot
1023 boots from the first
1024 .Cm freebsd-ufs
1025 partition.
1026 .Pa /boot/loader
1027 .Pq the third bootstrap stage
1028 is loaded from the first partition that matches these conditions.
1029 See
1030 .Xr gptboot 8
1031 for more information.
1032 .Pp
1033 .Pa /boot/gptzfsboot
1034 is used to boot from ZFS.
1035 It searches through the GPT for
1036 .Cm freebsd-zfs
1037 partitions, trying to detect ZFS pools.
1038 After all pools are detected,
1039 .Pa /boot/zfsloader
1040 is started from the first one found.
1041 .Pp
1042 The VTOC8 scheme does not support embedding bootstrap code.
1043 Instead, the 8 KBytes bootstrap code image
1044 .Pa /boot/boot1
1045 should be written with the
1046 .Cm gpart bootcode
1047 command with the
1048 .Fl p Ar bootcode
1049 option to all sufficiently large VTOC8 partitions.
1050 To do this the
1051 .Fl i Ar index
1052 option could be omitted.
1053 .Pp
1054 The APM scheme also does not support embedding bootstrap code.
1055 Instead, the 800 KBytes bootstrap code image
1056 .Pa /boot/boot1.hfs
1057 should be written with the
1058 .Cm gpart bootcode
1059 command to a partition of type
1060 .Cm apple-boot ,
1061 which should also be 800 KB in size.
1062 .Sh OPERATIONAL FLAGS
1063 Actions other than the
1064 .Cm commit
1065 and
1066 .Cm undo
1067 actions take an optional
1068 .Fl f Ar flags
1069 option.
1070 This option is used to specify action-specific operational flags.
1071 By default, the
1072 .Nm
1073 utility defines the
1074 .Ql C
1075 flag so that the action is immediately
1076 committed.
1077 The user can specify
1078 .Dq Fl f Cm x
1079 to have the action result in a pending change that can later, with
1080 other pending changes, be committed as a single compound change with
1081 the
1082 .Cm commit
1083 action or reverted with the
1084 .Cm undo
1085 action.
1086 .Sh RECOVERING
1087 The GEOM PART class supports recovering of partition tables only for GPT.
1088 The GPT primary metadata is stored at the beginning of the device.
1089 For redundancy, a secondary
1090 .Pq backup
1091 copy of the metadata is stored at the end of the device.
1092 As a result of having two copies, some corruption of metadata is not
1093 fatal to the working of GPT.
1094 When the kernel detects corrupt metadata, it marks this table as corrupt
1095 and reports the problem.
1096 .Cm destroy
1097 and
1098 .Cm recover
1099 are the only operations allowed on corrupt tables.
1100 .Pp
1101 If the first sector of a provider is corrupt, the kernel can not detect GPT
1102 even if the partition table itself is not corrupt.
1103 The protective MBR can be rewritten using the
1104 .Xr dd 1
1105 command, to restore the ability to detect the GPT.
1106 The copy of the protective MBR is usually located in the
1107 .Pa /boot/pmbr
1108 file.
1109 .Pp
1110 If one GPT header appears to be corrupt but the other copy remains intact,
1111 the kernel will log the following:
1112 .Bd -literal -offset indent
1113 GEOM: provider: the primary GPT table is corrupt or invalid.
1114 GEOM: provider: using the secondary instead -- recovery strongly advised.
1115 .Ed
1116 .Pp
1117 or
1118 .Bd -literal -offset indent
1119 GEOM: provider: the secondary GPT table is corrupt or invalid.
1120 GEOM: provider: using the primary only -- recovery suggested.
1121 .Ed
1122 .Pp
1123 Also
1124 .Nm
1125 commands such as
1126 .Cm show , status
1127 and
1128 .Cm list
1129 will report about corrupt tables.
1130 .Pp
1131 If the size of the device has changed (e.g.,\& volume expansion) the
1132 secondary GPT header will no longer be located in the last sector.
1133 This is not a metadata corruption, but it is dangerous because any
1134 corruption of the primary GPT will lead to loss of the partition table.
1135 This problem is reported by the kernel with the message:
1136 .Bd -literal -offset indent
1137 GEOM: provider: the secondary GPT header is not in the last LBA.
1138 .Ed
1139 .Pp
1140 This situation can be recovered with the
1141 .Cm recover
1142 command.
1143 This command reconstructs the corrupt metadata using known valid
1144 metadata and relocates the secondary GPT to the end of the device.
1145 .Pp
1146 .Em NOTE :
1147 The GEOM PART class can detect the same partition table visible through
1148 different GEOM providers, and some of them will be marked as corrupt.
1149 Be careful when choosing a provider for recovery.
1150 If you choose incorrectly you can destroy the metadata of another GEOM class,
1151 e.g.,\& GEOM MIRROR or GEOM LABEL.
1152 .Sh SYSCTL VARIABLES
1153 The following
1154 .Xr sysctl 8
1155 variables can be used to control the behavior of the
1156 .Nm PART
1157 GEOM class.
1158 The default value is shown next to each variable.
1159 .Bl -tag -width indent
1160 .It Va kern.geom.part.check_integrity : No 1
1161 This variable controls the behaviour of metadata integrity checks.
1162 When integrity checks are enabled, the
1163 .Nm PART
1164 GEOM class verifies all generic partition parameters obtained from the
1165 disk metadata.
1166 If some inconsistency is detected, the partition table will be
1167 rejected with a diagnostic message:
1168 .Sy "GEOM_PART: Integrity check failed (provider, scheme)" .
1169 .It Va kern.geom.part.ldm.debug : No 0
1170 Debug level of the Logical Disk Manager (LDM) module.
1171 This can be set to a number between 0 and 2 inclusive.
1172 If set to 0 minimal debug information is printed,
1173 and if set to 2 the maximum amount of debug information is printed.
1174 .It Va kern.geom.part.ldm.show_mirrors : No 0
1175 This variable controls how the Logical Disk Manager (LDM) module handles
1176 mirrored volumes.
1177 By default mirrored volumes are shown as partitions with type
1178 .Cm ms-ldm-data
1179 (see the
1180 .Sx "PARTITION TYPES"
1181 section).
1182 If this variable set to 1 each component of the mirrored volume will be
1183 present as independent partition.
1184 .Em NOTE :
1185 This may break a mirrored volume and lead to data damage.
1186 .It Va kern.geom.part.mbr.enforce_chs : No 1
1187 Specify how the Master Boot Record (MBR) module does alignment.
1188 If this variable is set to a non-zero value, the module will automatically
1189 recalculate the user-specified offset and size for alignment with the CHS
1190 geometry.
1191 Otherwise the values will be left unchanged.
1192 .El
1193 .Sh EXIT STATUS
1194 Exit status is 0 on success, and 1 if the command fails.
1195 .Sh EXAMPLES
1196 Create a GPT scheme on
1197 .Pa ada0 :
1198 .Bd -literal -offset indent
1199 /sbin/gpart create -s GPT ada0
1200 .Ed
1201 .Pp
1202 Embed GPT bootstrap code into a protective MBR:
1203 .Bd -literal -offset indent
1204 /sbin/gpart bootcode -b /boot/pmbr ada0
1205 .Ed
1206 .Pp
1207 Create a dedicated
1208 .Cm freebsd-boot
1209 partition that can boot
1210 .Fx
1211 from a
1212 .Cm freebsd-ufs
1213 partition, and install bootstrap code into it.
1214 This partition must be larger than the bootstrap code
1215 .Po
1216 usually either
1217 .Pa /boot/gptboot
1218 or
1219 .Pa /boot/gptzfsboot
1220 .Pc ,
1221 but smaller than 545 kB since the first-stage loader will load the
1222 entire partition into memory during boot, regardless of how much data
1223 it actually contains.
1224 This example uses 88 blocks (44 kB) so the next partition will be
1225 aligned on a 64 kB boundary without the need to specify an explicit
1226 offset or alignment.
1227 The boot partition itself is aligned on a 4 kB boundary.
1228 .Bd -literal -offset indent
1229 /sbin/gpart add -b 40 -s 88 -t freebsd-boot ada0
1230 /sbin/gpart bootcode -p /boot/gptboot -i 1 ada0
1231 .Ed
1232 .Pp
1233 Create a 512MB-sized
1234 .Cm freebsd-ufs
1235 partition to contain a UFS filesystem from which the system can boot.
1236 .Bd -literal -offset indent
1237 /sbin/gpart add -s 512M -t freebsd-ufs ada0
1238 .Ed
1239 .Pp
1240 Create an MBR scheme on
1241 .Pa ada0 ,
1242 then create a 30GB-sized
1243 .Fx
1244 slice, mark it active and
1245 install the
1246 .Nm boot0
1247 boot manager:
1248 .Bd -literal -offset indent
1249 /sbin/gpart create -s MBR ada0
1250 /sbin/gpart add -t freebsd -s 30G ada0
1251 /sbin/gpart set -a active -i 1 ada0
1252 /sbin/gpart bootcode -b /boot/boot0 ada0
1253 .Ed
1254 .Pp
1255 Now create a
1256 .Bx
1257 scheme
1258 .Pf ( Bx
1259 label) with space for up to 20 partitions:
1260 .Bd -literal -offset indent
1261 /sbin/gpart create -s BSD -n 20 ada0s1
1262 .Ed
1263 .Pp
1264 Create a 1GB-sized UFS partition and a 4GB-sized swap partition:
1265 .Bd -literal -offset indent
1266 /sbin/gpart add -t freebsd-ufs -s 1G ada0s1
1267 /sbin/gpart add -t freebsd-swap -s 4G ada0s1
1268 .Ed
1269 .Pp
1270 Install bootstrap code for the
1271 .Bx
1272 label:
1273 .Bd -literal -offset indent
1274 /sbin/gpart bootcode -b /boot/boot ada0s1
1275 .Ed
1276 .Pp
1277 Create a VTOC8 scheme on
1278 .Pa da0 :
1279 .Bd -literal -offset indent
1280 /sbin/gpart create -s VTOC8 da0
1281 .Ed
1282 .Pp
1283 Create a 512MB-sized
1284 .Cm freebsd-ufs
1285 partition to contain a UFS filesystem from which the system can boot.
1286 .Bd -literal -offset indent
1287 /sbin/gpart add -s 512M -t freebsd-ufs da0
1288 .Ed
1289 .Pp
1290 Create a 15GB-sized
1291 .Cm freebsd-ufs
1292 partition to contain a UFS filesystem and aligned on 4KB boundaries:
1293 .Bd -literal -offset indent
1294 /sbin/gpart add -s 15G -t freebsd-ufs -a 4k da0
1295 .Ed
1296 .Pp
1297 After creating all required partitions, embed bootstrap code into them:
1298 .Bd -literal -offset indent
1299 /sbin/gpart bootcode -p /boot/boot1 da0
1300 .Ed
1301 .Pp
1302 Create a backup of the partition table from
1303 .Pa da0 :
1304 .Bd -literal -offset indent
1305 /sbin/gpart backup da0 > da0.backup
1306 .Ed
1307 .Pp
1308 Restore the partition table from the backup to
1309 .Pa da0 :
1310 .Bd -literal -offset indent
1311 /sbin/gpart restore -l da0 < /mnt/da0.backup
1312 .Ed
1313 .Pp
1314 Clone the partition table from
1315 .Pa ada0
1316 to
1317 .Pa ada1
1318 and
1319 .Pa ada2 :
1320 .Bd -literal -offset indent
1321 /sbin/gpart backup ada0 | /sbin/gpart restore -F ada1 ada2
1322 .Ed
1323 .Sh SEE ALSO
1324 .Xr dd 1 ,
1325 .Xr geom 4 ,
1326 .Xr boot0cfg 8 ,
1327 .Xr geom 8 ,
1328 .Xr gptboot 8
1329 .Sh HISTORY
1330 The
1331 .Nm
1332 utility appeared in
1333 .Fx 7.0 .
1334 .Sh AUTHORS
1335 .An Marcel Moolenaar Aq marcel@FreeBSD.org