]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - sbin/geom/class/part/gpart.8
MFC r267667:
[FreeBSD/stable/10.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 December 10, 2015
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-core-storage
663 An Apple Mac OS X partition used by logical volume manager known as
664 Core Storage.
665 The scheme-specific type is
666 .Qq Li "!53746f72-6167-11aa-aa11-00306543ecac"
667 for GPT.
668 .It Cm apple-hfs
669 An Apple Mac OS X partition that contains a HFS or HFS+ filesystem.
670 The scheme-specific types are
671 .Qq Li "!175"
672 for MBR,
673 .Qq Li "!Apple_HFS"
674 for APM and
675 .Qq Li "!48465300-0000-11aa-aa11-00306543ecac"
676 for GPT.
677 .It Cm apple-label
678 An Apple Mac OS X partition dedicated to partition metadata that descibes
679 disk device.
680 The scheme-specific type is
681 .Qq Li "!4c616265-6c00-11aa-aa11-00306543ecac"
682 for GPT.
683 .It Cm apple-raid
684 An Apple Mac OS X partition used in a software RAID configuration.
685 The scheme-specific type is
686 .Qq Li "!52414944-0000-11aa-aa11-00306543ecac"
687 for GPT.
688 .It Cm apple-raid-offline
689 An Apple Mac OS X partition used in a software RAID configuration.
690 The scheme-specific type is
691 .Qq Li "!52414944-5f4f-11aa-aa11-00306543ecac"
692 for GPT.
693 .It Cm apple-tv-recovery
694 An Apple Mac OS X partition used by Apple TV.
695 The scheme-specific type is
696 .Qq Li "!5265636f-7665-11aa-aa11-00306543ecac"
697 for GPT.
698 .It Cm apple-ufs
699 An Apple Mac OS X partition that contains a UFS filesystem.
700 The scheme-specific types are
701 .Qq Li "!168"
702 for MBR,
703 .Qq Li "!Apple_UNIX_SVR2"
704 for APM and
705 .Qq Li "!55465300-0000-11aa-aa11-00306543ecac"
706 for GPT.
707 .It Cm dragonfly-label32
708 A DragonFlyBSD partition subdivided into filesystems with a
709 .Bx
710 disklabel.
711 The scheme-specific type is
712 .Qq Li "!9d087404-1ca5-11dc-8817-01301bb8a9f5"
713 for GPT.
714 .It Cm dragonfly-label64
715 A DragonFlyBSD partition subdivided into filesystems with a
716 disklabel64.
717 The scheme-specific type is
718 .Qq Li "!3d48ce54-1d16-11dc-8696-01301bb8a9f5"
719 for GPT.
720 .It Cm dragonfly-legacy
721 A legacy partition type used in DragonFlyBSD.
722 The scheme-specific type is
723 .Qq Li "!bd215ab2-1d16-11dc-8696-01301bb8a9f5"
724 for GPT.
725 .It Cm dragonfly-ccd
726 A DragonFlyBSD partition used with Concatenated Disk driver.
727 The scheme-specific type is
728 .Qq Li "!dbd5211b-1ca5-11dc-8817-01301bb8a9f5"
729 for GPT.
730 .It Cm dragonfly-hammer
731 A DragonFlyBSD partition that contains a Hammer filesystem.
732 The scheme-specific type is
733 .Qq Li "!61dc63ac-6e38-11dc-8513-01301bb8a9f5"
734 for GPT.
735 .It Cm dragonfly-hammer2
736 A DragonFlyBSD partition that contains a Hammer2 filesystem.
737 The scheme-specific type is
738 .Qq Li "!5cbb9ad1-862d-11dc-a94d-01301bb8a9f5"
739 for GPT.
740 .It Cm dragonfly-swap
741 A DragonFlyBSD partition dedicated to swap space.
742 The scheme-specific type is
743 .Qq Li "!9d58fdbd-1ca5-11dc-8817-01301bb8a9f5"
744 for GPT.
745 .It Cm dragonfly-ufs
746 A DragonFlyBSD partition that contains an UFS1 filesystem.
747 The scheme-specific type is
748 .Qq Li "!9d94ce7c-1ca5-11dc-8817-01301bb8a9f5"
749 for GPT.
750 .It Cm dragonfly-vinum
751 A DragonFlyBSD partition used with Logical Volume Manager.
752 The scheme-specific type is
753 .Qq Li "!9dd4478f-1ca5-11dc-8817-01301bb8a9f5"
754 for GPT.
755 .It Cm ebr
756 A partition subdivided into filesystems with a EBR.
757 The scheme-specific type is
758 .Qq Li "!5"
759 for MBR.
760 .It Cm fat16
761 A partition that contains a FAT16 filesystem.
762 The scheme-specific type is
763 .Qq Li "!6"
764 for MBR.
765 .It Cm fat32
766 A partition that contains a FAT32 filesystem.
767 The scheme-specific type is
768 .Qq Li "!11"
769 for MBR.
770 .It Cm linux-data
771 A Linux partition that contains some filesystem with data.
772 The scheme-specific types are
773 .Qq Li "!131"
774 for MBR and
775 .Qq Li "!0fc63daf-8483-4772-8e79-3d69d8477de4"
776 for GPT.
777 .It Cm linux-lvm
778 A Linux partition dedicated to Logical Volume Manager.
779 The scheme-specific types are
780 .Qq Li "!142"
781 for MBR and
782 .Qq Li "!e6d6d379-f507-44c2-a23c-238f2a3df928"
783 for GPT.
784 .It Cm linux-raid
785 A Linux partition used in a software RAID configuration.
786 The scheme-specific types are
787 .Qq Li "!253"
788 for MBR and
789 .Qq Li "!a19d880f-05fc-4d3b-a006-743f0f84911e"
790 for GPT.
791 .It Cm linux-swap
792 A Linux partition dedicated to swap space.
793 The scheme-specific types are
794 .Qq Li "!130"
795 for MBR and
796 .Qq Li "!0657fd6d-a4ab-43c4-84e5-0933c84b4f4f"
797 for GPT.
798 .It Cm mbr
799 A partition that is sub-partitioned by a Master Boot Record (MBR).
800 This type is known as
801 .Qq Li "!024dee41-33e7-11d3-9d69-0008c781f39f"
802 by GPT.
803 .It Cm ms-basic-data
804 A basic data partition (BDP) for Microsoft operating systems.
805 In the GPT this type is the equivalent to partition types
806 .Cm fat16 , fat32
807 and
808 .Cm ntfs
809 in MBR.
810 The scheme-specific type is
811 .Qq Li "!ebd0a0a2-b9e5-4433-87c0-68b6b72699c7"
812 for GPT.
813 .It Cm ms-ldm-data
814 A partition that contains Logical Disk Manager (LDM) volumes.
815 The scheme-specific types are
816 .Qq Li "!66"
817 for MBR,
818 .Qq Li "!af9b60a0-1431-4f62-bc68-3311714a69ad"
819 for GPT.
820 .It Cm ms-ldm-metadata
821 A partition that contains Logical Disk Manager (LDM) database.
822 The scheme-specific type is
823 .Qq Li "!5808c8aa-7e8f-42e0-85d2-e1e90434cfb3"
824 for GPT.
825 .It Cm netbsd-ccd
826 A NetBSD partition used with Concatenated Disk driver.
827 The scheme-specific type is
828 .Qq Li "!2db519c4-b10f-11dc-b99b-0019d1879648"
829 for GPT.
830 .It Cm netbsd-cgd
831 An encrypted NetBSD partition.
832 The scheme-specific type is
833 .Qq Li "!2db519ec-b10f-11dc-b99b-0019d1879648"
834 for GPT.
835 .It Cm netbsd-ffs
836 A NetBSD partition that contains an UFS filesystem.
837 The scheme-specific type is
838 .Qq Li "!49f48d5a-b10e-11dc-b99b-0019d1879648"
839 for GPT.
840 .It Cm netbsd-lfs
841 A NetBSD partition that contains an LFS filesystem.
842 The scheme-specific type is
843 .Qq Li "!49f48d82-b10e-11dc-b99b-0019d1879648"
844 for GPT.
845 .It Cm netbsd-raid
846 A NetBSD partition used in a software RAID configuration.
847 The scheme-specific type is
848 .Qq Li "!49f48daa-b10e-11dc-b99b-0019d1879648"
849 for GPT.
850 .It Cm netbsd-swap
851 A NetBSD partition dedicated to swap space.
852 The scheme-specific type is
853 .Qq Li "!49f48d32-b10e-11dc-b99b-0019d1879648"
854 for GPT.
855 .It Cm ntfs
856 A partition that contains a NTFS or exFAT filesystem.
857 The scheme-specific type is
858 .Qq Li "!7"
859 for MBR.
860 .It Cm prep-boot
861 The system partition dedicated to storing boot loaders on some PowerPC systems,
862 notably those made by IBM.
863 The scheme-specific types are
864 .Qq Li "!65"
865 for MBR and
866 .Qq Li "!0x9e1a2d38-c612-4316-aa26-8b49521e5a8b"
867 for GPT.
868 .It Cm vmware-vmfs
869 A partition that contains a VMware File System (VMFS).
870 The scheme-specific types are
871 .Qq Li "!251"
872 for MBR and
873 .Qq Li "!aa31e02a-400f-11db-9590-000c2911d1b8"
874 for GPT.
875 .It Cm vmware-vmkdiag
876 A partition that contains a VMware diagostic filesystem.
877 The scheme-specific types are
878 .Qq Li "!252"
879 for MBR and
880 .Qq Li "!9d275380-40ad-11db-bf97-000c2911d1b8"
881 for GPT.
882 .It Cm vmware-reserved
883 A VMware reserved partition.
884 The scheme-specific type is
885 .Qq Li "!9198effc-31c0-11db-8f-78-000c2911d1b8"
886 for GPT.
887 .It Cm vmware-vsanhdr
888 A partition claimed by VMware VSAN.
889 The scheme-specific type is
890 .Qq Li "!381cfccc-7288-11e0-92ee-000c2911d0b2"
891 for GPT.
892 .El
893 .Sh ATTRIBUTES
894 The scheme-specific attributes for EBR:
895 .Bl -tag -width ".Cm active"
896 .It Cm active
897 .El
898 .Pp
899 The scheme-specific attributes for GPT:
900 .Bl -tag -width ".Cm bootfailed"
901 .It Cm bootme
902 When set, the
903 .Nm gptboot
904 stage 1 boot loader will try to boot the system from this partition.
905 Multiple partitions can be marked with the
906 .Cm bootme
907 attribute.
908 See
909 .Xr gptboot 8
910 for more details.
911 .It Cm bootonce
912 Setting this attribute automatically sets the
913 .Cm bootme
914 attribute.
915 When set, the
916 .Nm gptboot
917 stage 1 boot loader will try to boot the system from this partition only once.
918 Multiple partitions can be marked with the
919 .Cm bootonce
920 and
921 .Cm bootme
922 attribute pairs.
923 See
924 .Xr gptboot 8
925 for more details.
926 .It Cm bootfailed
927 This attribute should not be manually managed.
928 It is managed by the
929 .Nm gptboot
930 stage 1 boot loader and the
931 .Pa /etc/rc.d/gptboot
932 start-up script.
933 See
934 .Xr gptboot 8
935 for more details.
936 .It Cm lenovofix
937 Setting this attribute overwrites the Protective MBR with a new one where
938 the 0xee partition is the second, rather than the first record.
939 This resolves a BIOS compatibility issue with some Lenovo models including the
940 X220, T420, and T520, allowing them to boot from GPT partitioned disks
941 without using EFI.
942 .El
943 .Pp
944 The scheme-specific attributes for MBR:
945 .Bl -tag -width ".Cm active"
946 .It Cm active
947 .El
948 .Pp
949 The scheme-specific attributes for PC98:
950 .Bl -tag -width ".Cm bootable"
951 .It Cm active
952 .It Cm bootable
953 .El
954 .Sh BOOTSTRAPPING
955 .Fx
956 supports several partitioning schemes and each scheme uses different
957 bootstrap code.
958 The bootstrap code is located in a specific disk area for each partitioning
959 scheme, and may vary in size for different schemes.
960 .Pp
961 Bootstrap code can be separated into two types.
962 The first type is embedded in the partitioning scheme's metadata, while the
963 second type is located on a specific partition.
964 Embedding bootstrap code should only be done with the
965 .Cm gpart bootcode
966 command with the
967 .Fl b Ar bootcode
968 option.
969 The GEOM PART class knows how to safely embed bootstrap code into
970 specific partitioning scheme metadata without causing any damage.
971 .Pp
972 The Master Boot Record (MBR) uses a 512-byte bootstrap code image, embedded
973 into the partition table's metadata area.
974 There are two variants of this bootstrap code:
975 .Pa /boot/mbr
976 and
977 .Pa /boot/boot0 .
978 .Pa /boot/mbr
979 searches for a partition with the
980 .Cm active
981 attribute (see the
982 .Sx ATTRIBUTES
983 section) in the partition table.
984 Then it runs next bootstrap stage.
985 The
986 .Pa /boot/boot0
987 image contains a boot manager with some additional interactive functions
988 for multi-booting from a user-selected partition.
989 .Pp
990 A BSD disklabel is usually created inside an MBR partition (slice)
991 with type
992 .Cm freebsd
993 (see the
994 .Sx "PARTITION TYPES"
995 section).
996 It uses 8 KB size bootstrap code image
997 .Pa /boot/boot ,
998 embedded into the partition table's metadata area.
999 .Pp
1000 Both types of bootstrap code are used to boot from the GUID Partition Table.
1001 First, a protective MBR is embedded into the first disk sector from the
1002 .Pa /boot/pmbr
1003 image.
1004 It searches through the GPT for a
1005 .Cm freebsd-boot
1006 partition (see the
1007 .Sx "PARTITION TYPES"
1008 section) and runs the next bootstrap stage from it.
1009 The
1010 .Cm freebsd-boot
1011 partition should be smaller than 545 KB.
1012 It can be located either before or after other
1013 .Fx
1014 partitions on the disk.
1015 There are two variants of bootstrap code to write to this partition:
1016 .Pa /boot/gptboot
1017 and
1018 .Pa /boot/gptzfsboot .
1019 .Pp
1020 .Pa /boot/gptboot
1021 is used to boot from UFS partitions.
1022 .Cm gptboot
1023 searches through
1024 .Cm freebsd-ufs
1025 partitions in the GPT and selects one to boot based on the
1026 .Cm bootonce
1027 and
1028 .Cm bootme
1029 attributes.
1030 If neither attribute is found,
1031 .Pa /boot/gptboot
1032 boots from the first
1033 .Cm freebsd-ufs
1034 partition.
1035 .Pa /boot/loader
1036 .Pq the third bootstrap stage
1037 is loaded from the first partition that matches these conditions.
1038 See
1039 .Xr gptboot 8
1040 for more information.
1041 .Pp
1042 .Pa /boot/gptzfsboot
1043 is used to boot from ZFS.
1044 It searches through the GPT for
1045 .Cm freebsd-zfs
1046 partitions, trying to detect ZFS pools.
1047 After all pools are detected,
1048 .Pa /boot/zfsloader
1049 is started from the first one found.
1050 .Pp
1051 The VTOC8 scheme does not support embedding bootstrap code.
1052 Instead, the 8 KBytes bootstrap code image
1053 .Pa /boot/boot1
1054 should be written with the
1055 .Cm gpart bootcode
1056 command with the
1057 .Fl p Ar bootcode
1058 option to all sufficiently large VTOC8 partitions.
1059 To do this the
1060 .Fl i Ar index
1061 option could be omitted.
1062 .Pp
1063 The APM scheme also does not support embedding bootstrap code.
1064 Instead, the 800 KBytes bootstrap code image
1065 .Pa /boot/boot1.hfs
1066 should be written with the
1067 .Cm gpart bootcode
1068 command to a partition of type
1069 .Cm apple-boot ,
1070 which should also be 800 KB in size.
1071 .Sh OPERATIONAL FLAGS
1072 Actions other than the
1073 .Cm commit
1074 and
1075 .Cm undo
1076 actions take an optional
1077 .Fl f Ar flags
1078 option.
1079 This option is used to specify action-specific operational flags.
1080 By default, the
1081 .Nm
1082 utility defines the
1083 .Ql C
1084 flag so that the action is immediately
1085 committed.
1086 The user can specify
1087 .Dq Fl f Cm x
1088 to have the action result in a pending change that can later, with
1089 other pending changes, be committed as a single compound change with
1090 the
1091 .Cm commit
1092 action or reverted with the
1093 .Cm undo
1094 action.
1095 .Sh RECOVERING
1096 The GEOM PART class supports recovering of partition tables only for GPT.
1097 The GPT primary metadata is stored at the beginning of the device.
1098 For redundancy, a secondary
1099 .Pq backup
1100 copy of the metadata is stored at the end of the device.
1101 As a result of having two copies, some corruption of metadata is not
1102 fatal to the working of GPT.
1103 When the kernel detects corrupt metadata, it marks this table as corrupt
1104 and reports the problem.
1105 .Cm destroy
1106 and
1107 .Cm recover
1108 are the only operations allowed on corrupt tables.
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 geom 4 ,
1325 .Xr boot0cfg 8 ,
1326 .Xr geom 8 ,
1327 .Xr gptboot 8
1328 .Sh HISTORY
1329 The
1330 .Nm
1331 utility appeared in
1332 .Fx 7.0 .
1333 .Sh AUTHORS
1334 .An Marcel Moolenaar Aq Mt marcel@FreeBSD.org