]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/geom/part/gpart.8
Merge llvm-project release/16.x llvmorg-16.0.2-0-g18ddebe1a1a9
[FreeBSD/FreeBSD.git] / lib / geom / 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 June 1, 2023
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 N
53 .Op Fl b Ar bootcode
54 .Op Fl p Ar partcode Fl i Ar index
55 .Op Fl f Ar flags
56 .Ar geom
57 .\" ==== COMMIT ====
58 .Nm
59 .Cm commit
60 .Ar geom
61 .\" ==== CREATE ====
62 .Nm
63 .Cm create
64 .Fl s Ar scheme
65 .Op Fl n Ar entries
66 .Op Fl f Ar flags
67 .Ar provider
68 .\" ==== DELETE ====
69 .Nm
70 .Cm delete
71 .Fl i Ar index
72 .Op Fl f Ar flags
73 .Ar geom
74 .\" ==== DESTROY ====
75 .Nm
76 .Cm destroy
77 .Op Fl F
78 .Op Fl f Ar flags
79 .Ar geom
80 .\" ==== MODIFY ====
81 .Nm
82 .Cm modify
83 .Fl i Ar index
84 .Op Fl l Ar label
85 .Op Fl t Ar type
86 .Op Fl f Ar flags
87 .Ar geom
88 .\" ==== RECOVER ====
89 .Nm
90 .Cm recover
91 .Op Fl f Ar flags
92 .Ar geom
93 .\" ==== RESIZE ====
94 .Nm
95 .Cm resize
96 .Fl i Ar index
97 .Op Fl a Ar alignment
98 .Op Fl s Ar size
99 .Op Fl f Ar flags
100 .Ar geom
101 .\" ==== RESTORE ====
102 .Nm
103 .Cm restore
104 .Op Fl lF
105 .Op Fl f Ar flags
106 .Ar provider
107 .Op Ar ...
108 .\" ==== SET ====
109 .Nm
110 .Cm set
111 .Fl a Ar attrib
112 .Fl i Ar index
113 .Op Fl f Ar flags
114 .Ar geom
115 .\" ==== SHOW ====
116 .Nm
117 .Cm show
118 .Op Fl l | r
119 .Op Fl p
120 .Op Ar geom ...
121 .\" ==== UNDO ====
122 .Nm
123 .Cm undo
124 .Ar geom
125 .\" ==== UNSET ====
126 .Nm
127 .Cm unset
128 .Fl a Ar attrib
129 .Fl i Ar index
130 .Op Fl f Ar flags
131 .Ar geom
132 .\"
133 .Nm
134 .Cm list
135 .Nm
136 .Cm status
137 .Nm
138 .Cm load
139 .Nm
140 .Cm unload
141 .Sh DESCRIPTION
142 The
143 .Nm
144 utility is used to partition GEOM providers, normally disks.
145 The first argument is the action to be taken:
146 .Bl -tag -width ".Cm bootcode"
147 .\" ==== ADD ====
148 .It Cm add
149 Add a new partition to the partitioning scheme given by
150 .Ar geom .
151 The partition type must be specified with
152 .Fl t Ar type .
153 The partition's location, size, and other attributes will be calculated
154 automatically if the corresponding options are not specified.
155 .Pp
156 The
157 .Cm add
158 command accepts these options:
159 .Bl -tag -width 12n
160 .It Fl a Ar alignment
161 If specified, then the
162 .Nm
163 utility tries to align
164 .Ar start
165 offset and partition
166 .Ar size
167 to be multiple of
168 .Ar alignment
169 value.
170 .It Fl b Ar start
171 The logical block address where the partition will begin.
172 An SI unit suffix is allowed.
173 .It Fl f Ar flags
174 Additional operational flags.
175 See the section entitled
176 .Sx "OPERATIONAL FLAGS"
177 below for a discussion
178 about its use.
179 .It Fl i Ar index
180 The index in the partition table at which the new partition is to be
181 placed.
182 The index determines the name of the device special file used
183 to represent the partition.
184 .It Fl l Ar label
185 The label attached to the partition.
186 This option is only valid when used on partitioning schemes that support
187 partition labels.
188 .It Fl s Ar size
189 Create a partition of size
190 .Ar size .
191 An SI unit suffix is allowed.
192 .It Fl t Ar type
193 Create a partition of type
194 .Ar type .
195 Partition types are discussed below in the section entitled
196 .Sx "PARTITION TYPES" .
197 .El
198 .\" ==== BACKUP ====
199 .It Cm backup
200 Dump a partition table to standard output in a special format used by the
201 .Cm restore
202 action.
203 .\" ==== BOOTCODE ====
204 .It Cm bootcode
205 Embed bootstrap code into the partitioning scheme's metadata on the
206 .Ar geom
207 (using
208 .Fl b Ar bootcode )
209 or write bootstrap code into a partition (using
210 .Fl p Ar partcode
211 and
212 .Fl i Ar index ) .
213 .Pp
214 The
215 .Cm bootcode
216 command accepts these options:
217 .Bl -tag -width 10n
218 .It Fl N
219 Do not preserve the Volume Serial Number for MBR.
220 MBR bootcode contains Volume Serial Number by default, and
221 .Nm
222 tries to preserve it when installing new bootstrap code.
223 This option skips preservation to help with some versions of
224 .Xr boot0cfg 8
225 that do not support Volume Serial Number.
226 .It Fl b Ar bootcode
227 Embed bootstrap code from the file
228 .Ar bootcode
229 into the partitioning scheme's metadata for
230 .Ar geom .
231 Not all partitioning schemes have embedded bootstrap code, so the
232 .Fl b Ar bootcode
233 option is scheme-specific in nature (see the section entitled
234 .Sx BOOTSTRAPPING
235 below).
236 The
237 .Ar bootcode
238 file must match the partitioning scheme's requirements for file content
239 and size.
240 .It Fl f Ar flags
241 Additional operational flags.
242 See the section entitled
243 .Sx "OPERATIONAL FLAGS"
244 below for a discussion
245 about its use.
246 .It Fl i Ar index
247 Specify the target partition for
248 .Fl p Ar partcode .
249 .It Fl p Ar partcode
250 Write the bootstrap code from the file
251 .Ar partcode
252 into the
253 .Ar geom
254 partition specified by
255 .Fl i Ar index .
256 The size of the file must be smaller than the size of the partition.
257 .El
258 .\" ==== COMMIT ====
259 .It Cm commit
260 Commit any pending changes for geom
261 .Ar geom .
262 All actions are committed by default and will not result in
263 pending changes.
264 Actions can be modified with the
265 .Fl f Ar flags
266 option so that they are not committed, but become pending.
267 Pending changes are reflected by the geom and the
268 .Nm
269 utility, but they are not actually written to disk.
270 The
271 .Cm commit
272 action will write all pending changes to disk.
273 .\" ==== CREATE ====
274 .It Cm create
275 Create a new partitioning scheme on a provider given by
276 .Ar provider .
277 The scheme to use must be specified with the
278 .Fl s Ar scheme
279 option.
280 .Pp
281 The
282 .Cm create
283 command accepts these options:
284 .Bl -tag -width 10n
285 .It Fl f Ar flags
286 Additional operational flags.
287 See the section entitled
288 .Sx "OPERATIONAL FLAGS"
289 below for a discussion
290 about its use.
291 .It Fl n Ar entries
292 The number of entries in the partition table.
293 Every partitioning scheme has a minimum and maximum number of entries.
294 This option allows tables to be created with a number of entries
295 that is within the limits.
296 Some schemes have a maximum equal to the minimum and some schemes have
297 a maximum large enough to be considered unlimited.
298 By default, partition tables are created with the minimum number of
299 entries.
300 .It Fl s Ar scheme
301 Specify the partitioning scheme to use.
302 The kernel must have support for a particular scheme before
303 that scheme can be used to partition a disk.
304 .El
305 .\" ==== DELETE ====
306 .It Cm delete
307 Delete a partition from geom
308 .Ar geom
309 and further identified by the
310 .Fl i Ar index
311 option.
312 The partition cannot be actively used by the kernel.
313 .Pp
314 The
315 .Cm delete
316 command accepts these options:
317 .Bl -tag -width 10n
318 .It Fl f Ar flags
319 Additional operational flags.
320 See the section entitled
321 .Sx "OPERATIONAL FLAGS"
322 below for a discussion
323 about its use.
324 .It Fl i Ar index
325 Specifies the index of the partition to be deleted.
326 .El
327 .\" ==== DESTROY ====
328 .It Cm destroy
329 Destroy the partitioning scheme as implemented by geom
330 .Ar geom .
331 .Pp
332 The
333 .Cm destroy
334 command accepts these options:
335 .Bl -tag -width 10n
336 .It Fl F
337 Forced destroying of the partition table even if it is not empty.
338 .It Fl f Ar flags
339 Additional operational flags.
340 See the section entitled
341 .Sx "OPERATIONAL FLAGS"
342 below for a discussion
343 about its use.
344 .El
345 .\" ==== MODIFY ====
346 .It Cm modify
347 Modify a partition from geom
348 .Ar geom
349 and further identified by the
350 .Fl i Ar index
351 option.
352 Only the type and/or label of the partition can be modified.
353 Not all partitioning schemes support labels and it is invalid to
354 try to change a partition label in such cases.
355 .Pp
356 The
357 .Cm modify
358 command accepts these options:
359 .Bl -tag -width 10n
360 .It Fl f Ar flags
361 Additional operational flags.
362 See the section entitled
363 .Sx "OPERATIONAL FLAGS"
364 below for a discussion
365 about its use.
366 .It Fl i Ar index
367 Specifies the index of the partition to be modified.
368 .It Fl l Ar label
369 Change the partition label to
370 .Ar label .
371 .It Fl t Ar type
372 Change the partition type to
373 .Ar type .
374 .El
375 .\" ==== RECOVER ====
376 .It Cm recover
377 Recover a corrupt partition's scheme metadata on the geom
378 .Ar geom .
379 See the section entitled
380 .Sx RECOVERING
381 below for the additional information.
382 .Pp
383 The
384 .Cm recover
385 command accepts these options:
386 .Bl -tag -width 10n
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 .\" ==== RESIZE ====
395 .It Cm resize
396 Resize a partition from geom
397 .Ar geom
398 and further identified by the
399 .Fl i Ar index
400 option.
401 If the new size is not specified it is automatically calculated
402 to be the maximum available from
403 .Ar geom .
404 .Pp
405 The
406 .Cm resize
407 command accepts these options:
408 .Bl -tag -width 12n
409 .It Fl a Ar alignment
410 If specified, then the
411 .Nm
412 utility tries to align partition
413 .Ar size
414 to be a multiple of the
415 .Ar alignment
416 value.
417 .It Fl f Ar flags
418 Additional operational flags.
419 See the section entitled
420 .Sx "OPERATIONAL FLAGS"
421 below for a discussion
422 about its use.
423 .It Fl i Ar index
424 Specifies the index of the partition to be resized.
425 .It Fl s Ar size
426 Specifies the new size of the partition, in logical blocks.
427 An SI unit suffix is allowed.
428 .El
429 .\" ==== RESTORE ====
430 .It Cm restore
431 Restore the partition table from a backup previously created by the
432 .Cm backup
433 action and read from standard input.
434 Only the partition table is restored.
435 This action does not affect the content of partitions.
436 After restoring the partition table and writing bootcode if needed,
437 user data must be restored from backup.
438 .Pp
439 The
440 .Cm restore
441 command accepts these options:
442 .Bl -tag -width 10n
443 .It Fl F
444 Destroy partition table on the given
445 .Ar provider
446 before doing restore.
447 .It Fl f Ar flags
448 Additional operational flags.
449 See the section entitled
450 .Sx "OPERATIONAL FLAGS"
451 below for a discussion
452 about its use.
453 .It Fl l
454 Restore partition labels for partitioning schemes that support them.
455 .El
456 .\" ==== SET ====
457 .It Cm set
458 Set the named attribute on the partition entry.
459 See the section entitled
460 .Sx ATTRIBUTES
461 below for a list of available attributes.
462 .Pp
463 The
464 .Cm set
465 command accepts these options:
466 .Bl -tag -width 10n
467 .It Fl a Ar attrib
468 Specifies the attribute to set.
469 .It Fl f Ar flags
470 Additional operational flags.
471 See the section entitled
472 .Sx "OPERATIONAL FLAGS"
473 below for a discussion
474 about its use.
475 .It Fl i Ar index
476 Specifies the index of the partition on which the attribute will be set.
477 .El
478 .\" ==== SHOW ====
479 .It Cm show
480 Show current partition information for the specified geoms, or all
481 geoms if none are specified.
482 The default output includes the logical starting block of each
483 partition, the partition size in blocks, the partition index number,
484 the partition type, and a human readable partition size.
485 Block sizes and locations are based on the device's Sectorsize
486 as shown by
487 .Cm gpart list .
488 .Pp
489 The
490 .Cm show
491 command accepts these options:
492 .Bl -tag -width 10n
493 .It Fl l
494 For partitioning schemes that support partition labels, print them
495 instead of partition type.
496 .It Fl p
497 Show provider names instead of partition indexes.
498 .It Fl r
499 Show raw partition type instead of symbolic name.
500 .El
501 .\" ==== UNDO ====
502 .It Cm undo
503 Revert any pending changes for geom
504 .Ar geom .
505 This action is the opposite of the
506 .Cm commit
507 action and can be used to undo any changes that have not been committed.
508 .\" ==== UNSET ====
509 .It Cm unset
510 Clear the named attribute on the partition entry.
511 See the section entitled
512 .Sx ATTRIBUTES
513 below for a list of available attributes.
514 .Pp
515 The
516 .Cm unset
517 command accepts these options:
518 .Bl -tag -width 10n
519 .It Fl a Ar attrib
520 Specifies the attribute to clear.
521 .It Fl f Ar flags
522 Additional operational flags.
523 See the section entitled
524 .Sx "OPERATIONAL FLAGS"
525 below for a discussion
526 about its use.
527 .It Fl i Ar index
528 Specifies the index of the partition on which the attribute will be cleared.
529 .El
530 .It Cm list
531 See
532 .Xr geom 8 .
533 .It Cm status
534 See
535 .Xr geom 8 .
536 .It Cm load
537 See
538 .Xr geom 8 .
539 .It Cm unload
540 See
541 .Xr geom 8 .
542 .El
543 .Sh PARTITIONING SCHEMES
544 Several partitioning schemes are supported by the
545 .Nm
546 utility:
547 .Bl -tag -width ".Cm VTOC8"
548 .It Cm APM
549 Apple Partition Map, used by PowerPC(R) Macintosh(R) computers.
550 Requires the
551 .Cd GEOM_PART_APM
552 kernel option.
553 .It Cm BSD
554 Traditional BSD
555 .Xr disklabel 8 ,
556 usually used to subdivide MBR partitions.
557 .Po
558 This scheme can also be used as the sole partitioning method, without
559 an MBR.
560 Partition editing tools from other operating systems often do not
561 understand the bare disklabel partition layout, so this is sometimes
562 called
563 .Dq dangerously dedicated .
564 .Pc
565 Requires the
566 .Cm GEOM_PART_BSD
567 kernel option.
568 .It Cm BSD64
569 64-bit implementation of BSD disklabel used in
570 .Dx
571 to subdivide MBR
572 or GPT partitions.
573 Requires the
574 .Cm GEOM_PART_BSD64
575 kernel option.
576 .It Cm LDM
577 The Logical Disk Manager is an implementation of volume manager for
578 Microsoft Windows NT.
579 Requires the
580 .Cd GEOM_PART_LDM
581 kernel option.
582 .It Cm GPT
583 GUID Partition Table is used on Intel-based Macintosh computers and
584 gradually replacing MBR on most PCs and other systems.
585 Requires the
586 .Cm GEOM_PART_GPT
587 kernel option.
588 .It Cm MBR
589 Master Boot Record is used on PCs and removable media.
590 Requires the
591 .Cm GEOM_PART_MBR
592 kernel option.
593 The
594 .Cm GEOM_PART_EBR
595 option adds support for the Extended Boot Record (EBR),
596 which is used to define a logical partition.
597 The
598 .Cm GEOM_PART_EBR_COMPAT
599 option enables backward compatibility for partition names
600 in the EBR scheme.
601 It also prevents any type of actions on such partitions.
602 .It Cm VTOC8
603 Sun's SMI Volume Table Of Contents, used by
604 .Tn SPARC64
605 and
606 .Tn UltraSPARC
607 computers.
608 Requires the
609 .Cm GEOM_PART_VTOC8
610 kernel option.
611 .El
612 .Pp
613 See
614 .Xr glabel 8
615 for additional information on labelization of devices and partitions.
616 .Sh PARTITION TYPES
617 Partition types are identified on disk by particular strings or magic
618 values.
619 The
620 .Nm
621 utility uses symbolic names for common partition types so the user
622 does not need to know these values or other details of the partitioning
623 scheme in question.
624 The
625 .Nm
626 utility also allows the user to specify scheme-specific partition types
627 for partition types that do not have symbolic names.
628 Symbolic names currently understood and used by
629 .Fx
630 are:
631 .Bl -tag -width ".Cm dragonfly-disklabel64"
632 .It Cm apple-boot
633 The system partition dedicated to storing boot loaders on some Apple
634 systems.
635 The scheme-specific types are
636 .Qq Li "!171"
637 for MBR,
638 .Qq Li "!Apple_Bootstrap"
639 for APM, and
640 .Qq Li "!426f6f74-0000-11aa-aa11-00306543ecac"
641 for GPT.
642 .It Cm bios-boot
643 The system partition dedicated to second stage of the boot loader program.
644 Usually it is used by the GRUB 2 loader for GPT partitioning schemes.
645 The scheme-specific type is
646 .Qq Li "!21686148-6449-6E6F-744E-656564454649" .
647 .It Cm efi
648 The system partition for computers that use the Extensible Firmware
649 Interface (EFI).
650 The scheme-specific types are
651 .Qq Li "!239"
652 for MBR, and
653 .Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93b"
654 for GPT.
655 .It Cm freebsd
656 A
657 .Fx
658 partition subdivided into filesystems with a
659 .Bx
660 disklabel.
661 This is a legacy partition type and should not be used for the APM
662 or GPT schemes.
663 The scheme-specific types are
664 .Qq Li "!165"
665 for MBR,
666 .Qq Li "!FreeBSD"
667 for APM, and
668 .Qq Li "!516e7cb4-6ecf-11d6-8ff8-00022d09712b"
669 for GPT.
670 .It Cm freebsd-boot
671 A
672 .Fx
673 partition dedicated to bootstrap code.
674 The scheme-specific type is
675 .Qq Li "!83bd6b9d-7f41-11dc-be0b-001560b84f0f"
676 for GPT.
677 .It Cm freebsd-swap
678 A
679 .Fx
680 partition dedicated to swap space.
681 The scheme-specific types are
682 .Qq Li "!FreeBSD-swap"
683 for APM,
684 .Qq Li "!516e7cb5-6ecf-11d6-8ff8-00022d09712b"
685 for GPT, and tag 0x0901 for VTOC8.
686 .It Cm freebsd-ufs
687 A
688 .Fx
689 partition that contains a UFS or UFS2 filesystem.
690 The scheme-specific types are
691 .Qq Li "!FreeBSD-UFS"
692 for APM,
693 .Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b"
694 for GPT, and tag 0x0902 for VTOC8.
695 .It Cm freebsd-vinum
696 A
697 .Fx
698 partition that contains a Vinum volume.
699 The scheme-specific types are
700 .Qq Li "!FreeBSD-Vinum"
701 for APM,
702 .Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b"
703 for GPT, and tag 0x0903 for VTOC8.
704 .It Cm freebsd-zfs
705 A
706 .Fx
707 partition that contains a ZFS volume.
708 The scheme-specific types are
709 .Qq Li "!FreeBSD-ZFS"
710 for APM,
711 .Qq Li "!516e7cba-6ecf-11d6-8ff8-00022d09712b"
712 for GPT, and 0x0904 for VTOC8.
713 .El
714 .Pp
715 Other symbolic names that can be used with the
716 .Nm
717 utility are:
718 .Bl -tag -width ".Cm dragonfly-disklabel64"
719 .It Cm apple-apfs
720 An Apple macOS partition used for the Apple file system, APFS.
721 .It Cm apple-core-storage
722 An Apple Mac OS X partition used by logical volume manager known as
723 Core Storage.
724 The scheme-specific type is
725 .Qq Li "!53746f72-6167-11aa-aa11-00306543ecac"
726 for GPT.
727 .It Cm apple-hfs
728 An Apple Mac OS X partition that contains a HFS or HFS+ filesystem.
729 The scheme-specific types are
730 .Qq Li "!175"
731 for MBR,
732 .Qq Li "!Apple_HFS"
733 for APM and
734 .Qq Li "!48465300-0000-11aa-aa11-00306543ecac"
735 for GPT.
736 .It Cm apple-label
737 An Apple Mac OS X partition dedicated to partition metadata that descibes
738 disk device.
739 The scheme-specific type is
740 .Qq Li "!4c616265-6c00-11aa-aa11-00306543ecac"
741 for GPT.
742 .It Cm apple-raid
743 An Apple Mac OS X partition used in a software RAID configuration.
744 The scheme-specific type is
745 .Qq Li "!52414944-0000-11aa-aa11-00306543ecac"
746 for GPT.
747 .It Cm apple-raid-offline
748 An Apple Mac OS X partition used in a software RAID configuration.
749 The scheme-specific type is
750 .Qq Li "!52414944-5f4f-11aa-aa11-00306543ecac"
751 for GPT.
752 .It Cm apple-tv-recovery
753 An Apple Mac OS X partition used by Apple TV.
754 The scheme-specific type is
755 .Qq Li "!5265636f-7665-11aa-aa11-00306543ecac"
756 for GPT.
757 .It Cm apple-ufs
758 An Apple Mac OS X partition that contains a UFS filesystem.
759 The scheme-specific types are
760 .Qq Li "!168"
761 for MBR,
762 .Qq Li "!Apple_UNIX_SVR2"
763 for APM and
764 .Qq Li "!55465300-0000-11aa-aa11-00306543ecac"
765 for GPT.
766 .It Cm apple-zfs
767 An Apple Mac OS X partition that contains a ZFS volume.
768 The scheme-specific type is
769 .Qq Li "!6a898cc3-1dd2-11b2-99a6-080020736631"
770 for GPT.
771 The same GUID is being used also for
772 .Sy illumos/Solaris /usr partition .
773 See
774 .Sx CAVEATS
775 section below.
776 .It Cm dragonfly-label32
777 A
778 .Dx
779 partition subdivided into filesystems with a
780 .Bx
781 disklabel.
782 The scheme-specific type is
783 .Qq Li "!9d087404-1ca5-11dc-8817-01301bb8a9f5"
784 for GPT.
785 .It Cm dragonfly-label64
786 A
787 .Dx
788 partition subdivided into filesystems with a
789 disklabel64.
790 The scheme-specific type is
791 .Qq Li "!3d48ce54-1d16-11dc-8696-01301bb8a9f5"
792 for GPT.
793 .It Cm dragonfly-legacy
794 A legacy partition type used in
795 .Dx .
796 The scheme-specific type is
797 .Qq Li "!bd215ab2-1d16-11dc-8696-01301bb8a9f5"
798 for GPT.
799 .It Cm dragonfly-ccd
800 A
801 .Dx
802 partition used with Concatenated Disk driver.
803 The scheme-specific type is
804 .Qq Li "!dbd5211b-1ca5-11dc-8817-01301bb8a9f5"
805 for GPT.
806 .It Cm dragonfly-hammer
807 A
808 .Dx
809 partition that contains a Hammer filesystem.
810 The scheme-specific type is
811 .Qq Li "!61dc63ac-6e38-11dc-8513-01301bb8a9f5"
812 for GPT.
813 .It Cm dragonfly-hammer2
814 A
815 .Dx
816 partition that contains a Hammer2 filesystem.
817 The scheme-specific type is
818 .Qq Li "!5cbb9ad1-862d-11dc-a94d-01301bb8a9f5"
819 for GPT.
820 .It Cm dragonfly-swap
821 A
822 .Dx
823 partition dedicated to swap space.
824 The scheme-specific type is
825 .Qq Li "!9d58fdbd-1ca5-11dc-8817-01301bb8a9f5"
826 for GPT.
827 .It Cm dragonfly-ufs
828 A
829 .Dx
830 partition that contains an UFS1 filesystem.
831 The scheme-specific type is
832 .Qq Li "!9d94ce7c-1ca5-11dc-8817-01301bb8a9f5"
833 for GPT.
834 .It Cm dragonfly-vinum
835 A
836 .Dx
837 partition used with Logical Volume Manager.
838 The scheme-specific type is
839 .Qq Li "!9dd4478f-1ca5-11dc-8817-01301bb8a9f5"
840 for GPT.
841 .It Cm ebr
842 A partition subdivided into filesystems with a EBR.
843 The scheme-specific type is
844 .Qq Li "!5"
845 for MBR.
846 .It Cm fat16
847 A partition that contains a FAT16 filesystem.
848 The scheme-specific type is
849 .Qq Li "!6"
850 for MBR.
851 .It Cm fat32
852 A partition that contains a FAT32 filesystem.
853 The scheme-specific type is
854 .Qq Li "!11"
855 for MBR.
856 .It Cm fat32lba
857 A partition that contains a FAT32 (LBA) filesystem.
858 The scheme-specific type is
859 .Qq Li "!12"
860 for MBR.
861 .It Cm hifive-fsbl
862 A raw partition containing a HiFive first stage bootloader.
863 The scheme-specific type is
864 .Qq Li "!5b193300-fc78-40cd-8002-e86c45580b47"
865 for GPT.
866 .It Cm hifive-bbl
867 A raw partition containing a HiFive second stage bootloader.
868 The scheme-specific type is
869 .Qq Li "!2e54b353-1271-4842-806f-e436d6af6985"
870 for GPT.
871 .It Cm linux-data
872 A Linux partition that contains some filesystem with data.
873 The scheme-specific types are
874 .Qq Li "!131"
875 for MBR and
876 .Qq Li "!0fc63daf-8483-4772-8e79-3d69d8477de4"
877 for GPT.
878 .It Cm linux-lvm
879 A Linux partition dedicated to Logical Volume Manager.
880 The scheme-specific types are
881 .Qq Li "!142"
882 for MBR and
883 .Qq Li "!e6d6d379-f507-44c2-a23c-238f2a3df928"
884 for GPT.
885 .It Cm linux-raid
886 A Linux partition used in a software RAID configuration.
887 The scheme-specific types are
888 .Qq Li "!253"
889 for MBR and
890 .Qq Li "!a19d880f-05fc-4d3b-a006-743f0f84911e"
891 for GPT.
892 .It Cm linux-swap
893 A Linux partition dedicated to swap space.
894 The scheme-specific types are
895 .Qq Li "!130"
896 for MBR and
897 .Qq Li "!0657fd6d-a4ab-43c4-84e5-0933c84b4f4f"
898 for GPT.
899 .It Cm mbr
900 A partition that is sub-partitioned by a Master Boot Record (MBR).
901 This type is known as
902 .Qq Li "!024dee41-33e7-11d3-9d69-0008c781f39f"
903 by GPT.
904 .It Cm ms-basic-data
905 A basic data partition (BDP) for Microsoft operating systems.
906 In the GPT this type is the equivalent to partition types
907 .Cm fat16 , fat32
908 and
909 .Cm ntfs
910 in MBR.
911 This type is used for GPT exFAT partitions.
912 The scheme-specific type is
913 .Qq Li "!ebd0a0a2-b9e5-4433-87c0-68b6b72699c7"
914 for GPT.
915 .It Cm ms-ldm-data
916 A partition that contains Logical Disk Manager (LDM) volumes.
917 The scheme-specific types are
918 .Qq Li "!66"
919 for MBR,
920 .Qq Li "!af9b60a0-1431-4f62-bc68-3311714a69ad"
921 for GPT.
922 .It Cm ms-ldm-metadata
923 A partition that contains Logical Disk Manager (LDM) database.
924 The scheme-specific type is
925 .Qq Li "!5808c8aa-7e8f-42e0-85d2-e1e90434cfb3"
926 for GPT.
927 .It Cm netbsd-ccd
928 A
929 .Nx
930 partition used with Concatenated Disk driver.
931 The scheme-specific type is
932 .Qq Li "!2db519c4-b10f-11dc-b99b-0019d1879648"
933 for GPT.
934 .It Cm netbsd-cgd
935 An encrypted
936 .Nx
937 partition.
938 The scheme-specific type is
939 .Qq Li "!2db519ec-b10f-11dc-b99b-0019d1879648"
940 for GPT.
941 .It Cm netbsd-ffs
942 A
943 .Nx
944 partition that contains an UFS filesystem.
945 The scheme-specific type is
946 .Qq Li "!49f48d5a-b10e-11dc-b99b-0019d1879648"
947 for GPT.
948 .It Cm netbsd-lfs
949 A
950 .Nx
951 partition that contains an LFS filesystem.
952 The scheme-specific type is
953 .Qq Li "!49f48d82-b10e-11dc-b99b-0019d1879648"
954 for GPT.
955 .It Cm netbsd-raid
956 A
957 .Nx
958 partition used in a software RAID configuration.
959 The scheme-specific type is
960 .Qq Li "!49f48daa-b10e-11dc-b99b-0019d1879648"
961 for GPT.
962 .It Cm netbsd-swap
963 A
964 .Nx
965 partition dedicated to swap space.
966 The scheme-specific type is
967 .Qq Li "!49f48d32-b10e-11dc-b99b-0019d1879648"
968 for GPT.
969 .It Cm ntfs
970 A partition that contains a NTFS or exFAT filesystem.
971 The scheme-specific type is
972 .Qq Li "!7"
973 for MBR.
974 .It Cm prep-boot
975 The system partition dedicated to storing boot loaders on some PowerPC systems,
976 notably those made by IBM.
977 The scheme-specific types are
978 .Qq Li "!65"
979 for MBR and
980 .Qq Li "!9e1a2d38-c612-4316-aa26-8b49521e5a8b"
981 for GPT.
982 .It Cm solaris-boot
983 A illumos/Solaris partition dedicated to boot loader.
984 The scheme-specific type is
985 .Qq Li "!6a82cb45-1dd2-11b2-99a6-080020736631"
986 for GPT.
987 .It Cm solaris-root
988 A illumos/Solaris partition dedicated to root filesystem.
989 The scheme-specific type is
990 .Qq Li "!6a85cf4d-1dd2-11b2-99a6-080020736631"
991 for GPT.
992 .It Cm solaris-swap
993 A illumos/Solaris partition dedicated to swap.
994 The scheme-specific type is
995 .Qq Li "!6a87c46f-1dd2-11b2-99a6-080020736631"
996 for GPT.
997 .It Cm solaris-backup
998 A illumos/Solaris partition dedicated to backup.
999 The scheme-specific type is
1000 .Qq Li "!6a8b642b-1dd2-11b2-99a6-080020736631"
1001 for GPT.
1002 .It Cm solaris-var
1003 A illumos/Solaris partition dedicated to /var filesystem.
1004 The scheme-specific type is
1005 .Qq Li "!6a8ef2e9-1dd2-11b2-99a6-080020736631"
1006 for GPT.
1007 .It Cm solaris-home
1008 A illumos/Solaris partition dedicated to /home filesystem.
1009 The scheme-specific type is
1010 .Qq Li "!6a90ba39-1dd2-11b2-99a6-080020736631"
1011 for GPT.
1012 .It Cm solaris-altsec
1013 A illumos/Solaris partition dedicated to alternate sector.
1014 The scheme-specific type is
1015 .Qq Li "!6a9283a5-1dd2-11b2-99a6-080020736631"
1016 for GPT.
1017 .It Cm solaris-reserved
1018 A illumos/Solaris partition dedicated to reserved space.
1019 The scheme-specific type is
1020 .Qq Li "!6a945a3b-1dd2-11b2-99a6-080020736631"
1021 for GPT.
1022 .It Cm vmware-vmfs
1023 A partition that contains a VMware File System (VMFS).
1024 The scheme-specific types are
1025 .Qq Li "!251"
1026 for MBR and
1027 .Qq Li "!aa31e02a-400f-11db-9590-000c2911d1b8"
1028 for GPT.
1029 .It Cm vmware-vmkdiag
1030 A partition that contains a VMware diagostic filesystem.
1031 The scheme-specific types are
1032 .Qq Li "!252"
1033 for MBR and
1034 .Qq Li "!9d275380-40ad-11db-bf97-000c2911d1b8"
1035 for GPT.
1036 .It Cm vmware-reserved
1037 A VMware reserved partition.
1038 The scheme-specific type is
1039 .Qq Li "!9198effc-31c0-11db-8f-78-000c2911d1b8"
1040 for GPT.
1041 .It Cm vmware-vsanhdr
1042 A partition claimed by VMware VSAN.
1043 The scheme-specific type is
1044 .Qq Li "!381cfccc-7288-11e0-92ee-000c2911d0b2"
1045 for GPT.
1046 .El
1047 .Sh ATTRIBUTES
1048 The scheme-specific attributes for EBR:
1049 .Bl -tag -width ".Cm active"
1050 .It Cm active
1051 .El
1052 .Pp
1053 The scheme-specific attributes for GPT:
1054 .Bl -tag -width ".Cm bootfailed"
1055 .It Cm bootme
1056 When set, the
1057 .Nm gptboot
1058 stage 1 boot loader will try to boot the system from this partition.
1059 Multiple partitions can be marked with the
1060 .Cm bootme
1061 attribute.
1062 See
1063 .Xr gptboot 8
1064 for more details.
1065 .It Cm bootonce
1066 Setting this attribute automatically sets the
1067 .Cm bootme
1068 attribute.
1069 When set, the
1070 .Nm gptboot
1071 stage 1 boot loader will try to boot the system from this partition only once.
1072 Multiple partitions can be marked with the
1073 .Cm bootonce
1074 and
1075 .Cm bootme
1076 attribute pairs.
1077 See
1078 .Xr gptboot 8
1079 for more details.
1080 .It Cm bootfailed
1081 This attribute should not be manually managed.
1082 It is managed by the
1083 .Nm gptboot
1084 stage 1 boot loader and the
1085 .Pa /etc/rc.d/gptboot
1086 start-up script.
1087 See
1088 .Xr gptboot 8
1089 for more details.
1090 .It Cm lenovofix
1091 Setting this attribute overwrites the Protective MBR with a new one where
1092 the 0xee partition is the second, rather than the first record.
1093 This resolves a BIOS compatibility issue with some Lenovo models including the
1094 X220, T420, and T520, allowing them to boot from GPT partitioned disks
1095 without using EFI.
1096 .El
1097 .Pp
1098 The scheme-specific attributes for MBR:
1099 .Bl -tag -width ".Cm active"
1100 .It Cm active
1101 .El
1102 .Sh BOOTSTRAPPING
1103 .Fx
1104 supports several partitioning schemes and each scheme uses different
1105 bootstrap code.
1106 The bootstrap code is located in a specific disk area for each partitioning
1107 scheme, and may vary in size for different schemes.
1108 .Pp
1109 Bootstrap code can be separated into two types.
1110 The first type is embedded in the partitioning scheme's metadata, while the
1111 second type is located on a specific partition.
1112 Embedding bootstrap code should only be done with the
1113 .Cm gpart bootcode
1114 command with the
1115 .Fl b Ar bootcode
1116 option.
1117 The GEOM PART class knows how to safely embed bootstrap code into
1118 specific partitioning scheme metadata without causing any damage.
1119 .Pp
1120 The Master Boot Record (MBR) uses a 512-byte bootstrap code image, embedded
1121 into the partition table's metadata area.
1122 There are two variants of this bootstrap code:
1123 .Pa /boot/mbr
1124 and
1125 .Pa /boot/boot0 .
1126 .Pa /boot/mbr
1127 searches for a partition with the
1128 .Cm active
1129 attribute (see the
1130 .Sx ATTRIBUTES
1131 section) in the partition table.
1132 Then it runs next bootstrap stage.
1133 The
1134 .Pa /boot/boot0
1135 image contains a boot manager with some additional interactive functions
1136 for multi-booting from a user-selected partition.
1137 .Pp
1138 A BSD disklabel is usually created inside an MBR partition (slice)
1139 with type
1140 .Cm freebsd
1141 (see the
1142 .Sx "PARTITION TYPES"
1143 section).
1144 It uses 8 KB size bootstrap code image
1145 .Pa /boot/boot ,
1146 embedded into the partition table's metadata area.
1147 .Pp
1148 Both types of bootstrap code are used to boot from the GUID Partition Table.
1149 First, a protective MBR is embedded into the first disk sector from the
1150 .Pa /boot/pmbr
1151 image.
1152 It searches through the GPT for a
1153 .Cm freebsd-boot
1154 partition (see the
1155 .Sx "PARTITION TYPES"
1156 section) and runs the next bootstrap stage from it.
1157 The
1158 .Cm freebsd-boot
1159 partition should be smaller than 545 KB.
1160 It can be located either before or after other
1161 .Fx
1162 partitions on the disk.
1163 There are two variants of bootstrap code to write to this partition:
1164 .Pa /boot/gptboot
1165 and
1166 .Pa /boot/gptzfsboot .
1167 .Pp
1168 .Pa /boot/gptboot
1169 is used to boot from UFS partitions.
1170 .Cm gptboot
1171 searches through
1172 .Cm freebsd-ufs
1173 partitions in the GPT and selects one to boot based on the
1174 .Cm bootonce
1175 and
1176 .Cm bootme
1177 attributes.
1178 If neither attribute is found,
1179 .Pa /boot/gptboot
1180 boots from the first
1181 .Cm freebsd-ufs
1182 partition.
1183 .Pa /boot/loader
1184 .Pq the third bootstrap stage
1185 is loaded from the first partition that matches these conditions.
1186 See
1187 .Xr gptboot 8
1188 for more information.
1189 .Pp
1190 .Pa /boot/gptzfsboot
1191 is used to boot from ZFS.
1192 It searches through the GPT for
1193 .Cm freebsd-zfs
1194 partitions, trying to detect ZFS pools.
1195 After all pools are detected,
1196 .Pa /boot/loader
1197 is started from the first one found set as bootable.
1198 .Pp
1199 The VTOC8 scheme does not support embedding bootstrap code.
1200 Instead, the 8 KBytes bootstrap code image
1201 .Pa /boot/boot1
1202 should be written with the
1203 .Cm gpart bootcode
1204 command with the
1205 .Fl p Ar bootcode
1206 option to all sufficiently large VTOC8 partitions.
1207 To do this the
1208 .Fl i Ar index
1209 option could be omitted.
1210 .Pp
1211 The APM scheme also does not support embedding bootstrap code.
1212 Instead, the 800 KBytes bootstrap code image
1213 .Pa /boot/boot1.hfs
1214 should be written with the
1215 .Cm gpart bootcode
1216 command to a partition of type
1217 .Cm apple-boot ,
1218 which should also be 800 KB in size.
1219 .Sh OPERATIONAL FLAGS
1220 Actions other than the
1221 .Cm commit
1222 and
1223 .Cm undo
1224 actions take an optional
1225 .Fl f Ar flags
1226 option.
1227 This option is used to specify action-specific operational flags.
1228 By default, the
1229 .Nm
1230 utility defines the
1231 .Ql C
1232 flag so that the action is immediately
1233 committed.
1234 The user can specify
1235 .Dq Fl f Cm x
1236 to have the action result in a pending change that can later, with
1237 other pending changes, be committed as a single compound change with
1238 the
1239 .Cm commit
1240 action or reverted with the
1241 .Cm undo
1242 action.
1243 .Sh RECOVERING
1244 The GEOM PART class supports recovering of partition tables only for GPT.
1245 The GPT primary metadata is stored at the beginning of the device.
1246 For redundancy, a secondary
1247 .Pq backup
1248 copy of the metadata is stored at the end of the device.
1249 As a result of having two copies, some corruption of metadata is not
1250 fatal to the working of GPT.
1251 When the kernel detects corrupt metadata, it marks this table as corrupt
1252 and reports the problem.
1253 .Cm destroy
1254 and
1255 .Cm recover
1256 are the only operations allowed on corrupt tables.
1257 .Pp
1258 If one GPT header appears to be corrupt but the other copy remains intact,
1259 the kernel will log the following:
1260 .Bd -literal -offset indent
1261 GEOM: provider: the primary GPT table is corrupt or invalid.
1262 GEOM: provider: using the secondary instead -- recovery strongly advised.
1263 .Ed
1264 .Pp
1265 or
1266 .Bd -literal -offset indent
1267 GEOM: provider: the secondary GPT table is corrupt or invalid.
1268 GEOM: provider: using the primary only -- recovery suggested.
1269 .Ed
1270 .Pp
1271 Also
1272 .Nm
1273 commands such as
1274 .Cm show , status
1275 and
1276 .Cm list
1277 will report about corrupt tables.
1278 .Pp
1279 If the size of the device has changed (e.g.,\& volume expansion) the
1280 secondary GPT header will no longer be located in the last sector.
1281 This is not a metadata corruption, but it is dangerous because any
1282 corruption of the primary GPT will lead to loss of the partition table.
1283 This problem is reported by the kernel with the message:
1284 .Bd -literal -offset indent
1285 GEOM: provider: the secondary GPT header is not in the last LBA.
1286 .Ed
1287 .Pp
1288 This situation can be recovered with the
1289 .Cm recover
1290 command.
1291 This command reconstructs the corrupt metadata using known valid
1292 metadata and relocates the secondary GPT to the end of the device.
1293 .Pp
1294 .Em NOTE :
1295 The GEOM PART class can detect the same partition table visible through
1296 different GEOM providers, and some of them will be marked as corrupt.
1297 Be careful when choosing a provider for recovery.
1298 If you choose incorrectly you can destroy the metadata of another GEOM class,
1299 e.g.,\& GEOM MIRROR or GEOM LABEL.
1300 .Sh SYSCTL VARIABLES
1301 The following
1302 .Xr sysctl 8
1303 variables can be used to control the behavior of the
1304 .Nm PART
1305 GEOM class.
1306 The default value is shown next to each variable.
1307 .Bl -tag -width indent
1308 .It Va kern.geom.part.allow_nesting : No 0
1309 By default, some schemes (currently BSD, BSD64 and VTOC8) do not permit
1310 further nested partitioning.
1311 This variable overrides this restriction and allows arbitrary nesting (except
1312 within partitions created at offset 0).
1313 Some schemes have their own separate checks, for which see below.
1314 .It Va kern.geom.part.auto_resize : No 1
1315 This variable controls automatic resize behavior of the
1316 .Nm PART
1317 GEOM class.
1318 When this variable is enable and new size of provider is detected, the schema
1319 metadata is resized but all changes are not saved to disk, until
1320 .Cm gpart commit
1321 is run to confirm changes.
1322 This behavior is also reported with diagnostic message:
1323 .Sy "GEOM_PART: (provider) was automatically resized."
1324 .Sy "Use `gpart commit (provider)` to save changes or `gpart undo (provider)`"
1325 .Sy "to revert them."
1326 .It Va kern.geom.part.check_integrity : No 1
1327 This variable controls the behaviour of metadata integrity checks.
1328 When integrity checks are enabled, the
1329 .Nm PART
1330 GEOM class verifies all generic partition parameters obtained from the
1331 disk metadata.
1332 If some inconsistency is detected, the partition table will be
1333 rejected with a diagnostic message:
1334 .Sy "GEOM_PART: Integrity check failed (provider, scheme)" .
1335 .It Va kern.geom.part.gpt.allow_nesting : No 0
1336 By default the GPT scheme is allowed only at the outermost nesting level.
1337 This variable allows this restriction to be removed.
1338 .It Va kern.geom.part.ldm.debug : No 0
1339 Debug level of the Logical Disk Manager (LDM) module.
1340 This can be set to a number between 0 and 2 inclusive.
1341 If set to 0 minimal debug information is printed,
1342 and if set to 2 the maximum amount of debug information is printed.
1343 .It Va kern.geom.part.ldm.show_mirrors : No 0
1344 This variable controls how the Logical Disk Manager (LDM) module handles
1345 mirrored volumes.
1346 By default mirrored volumes are shown as partitions with type
1347 .Cm ms-ldm-data
1348 (see the
1349 .Sx "PARTITION TYPES"
1350 section).
1351 If this variable set to 1 each component of the mirrored volume will be
1352 present as independent partition.
1353 .Em NOTE :
1354 This may break a mirrored volume and lead to data damage.
1355 .It Va kern.geom.part.mbr.enforce_chs : No 0
1356 Specify how the Master Boot Record (MBR) module does alignment.
1357 If this variable is set to a non-zero value, the module will automatically
1358 recalculate the user-specified offset and size for alignment with the CHS
1359 geometry.
1360 Otherwise the values will be left unchanged.
1361 .It Va kern.geom.part.separator : No ""
1362 Specify an optional separator that will be inserted between the GEOM name
1363 and partition name.
1364 This variable is a
1365 .Xr loader 8
1366 tunable.
1367 Note that setting this variable may break software which assumes a particular
1368 naming scheme.
1369 .El
1370 .Sh EXIT STATUS
1371 Exit status is 0 on success, and 1 if the command fails.
1372 .Sh EXAMPLES
1373 The examples below assume that the disk's logical block size is 512
1374 bytes, regardless of its physical block size.
1375 .Ss GPT
1376 In this example, we will format
1377 .Pa ada0
1378 with the GPT scheme and create boot, swap and root partitions.
1379 First, we need to create the partition table:
1380 .Bd -literal -offset indent
1381 /sbin/gpart create -s GPT ada0
1382 .Ed
1383 .Pp
1384 Next, we install a protective MBR with the first-stage bootstrap code.
1385 The protective MBR lists a single, bootable partition spanning the
1386 entire disk, thus allowing non-GPT-aware BIOSes to boot from the disk
1387 and preventing tools which do not understand the GPT scheme from
1388 considering the disk to be unformatted.
1389 .Bd -literal -offset indent
1390 /sbin/gpart bootcode -b /boot/pmbr ada0
1391 .Ed
1392 .Pp
1393 We then create a dedicated
1394 .Cm freebsd-boot
1395 partition to hold the second-stage boot loader, which will load the
1396 .Fx
1397 kernel and modules from a UFS or ZFS filesystem.
1398 This partition must be larger than the bootstrap code
1399 .Po
1400 either
1401 .Pa /boot/gptboot
1402 for UFS or
1403 .Pa /boot/gptzfsboot
1404 for ZFS
1405 .Pc ,
1406 but smaller than 545 kB since the first-stage loader will load the
1407 entire partition into memory during boot, regardless of how much data
1408 it actually contains.
1409 We create a 472-block (236 kB) boot partition at offset 40, which is
1410 the size of the partition table (34 blocks or 17 kB) rounded up to the
1411 nearest 4 kB boundary.
1412 .Bd -literal -offset indent
1413 /sbin/gpart add -b 40 -s 472 -t freebsd-boot ada0
1414 /sbin/gpart bootcode -p /boot/gptboot -i 1 ada0
1415 .Ed
1416 .Pp
1417 We now create a 4 GB swap partition at the first available offset,
1418 which is 40 + 472 = 512 blocks (256 kB).
1419 .Bd -literal -offset indent
1420 /sbin/gpart add -s 4G -t freebsd-swap ada0
1421 .Ed
1422 .Pp
1423 Aligning the swap partition and all subsequent partitions on a 256 kB
1424 boundary ensures optimal performance on a wide range of media, from
1425 plain old disks with 512-byte blocks, through modern
1426 .Dq advanced format
1427 disks with 4096-byte physical blocks, to RAID volumes with stripe
1428 sizes of up to 256 kB.
1429 .Pp
1430 Finally, we create and format an 8 GB
1431 .Cm freebsd-ufs
1432 partition for the root filesystem, leaving the rest of the slice free
1433 for additional filesystems:
1434 .Bd -literal -offset indent
1435 /sbin/gpart add -s 8G -t freebsd-ufs ada0
1436 /sbin/newfs -Uj /dev/ada0p3
1437 .Ed
1438 .Ss MBR
1439 In this example, we will format
1440 .Pa ada0
1441 with the MBR scheme and create a single partition which we subdivide
1442 using a traditional
1443 .Bx
1444 disklabel.
1445 .Pp
1446 First, we create the partition table and a single 64 GB partition,
1447 then we mark that partition active (bootable) and install the
1448 first-stage boot loader:
1449 .Bd -literal -offset indent
1450 /sbin/gpart create -s MBR ada0
1451 /sbin/gpart add -t freebsd -s 64G ada0
1452 /sbin/gpart set -a active -i 1 ada0
1453 /sbin/gpart bootcode -b /boot/boot0 ada0
1454 .Ed
1455 .Pp
1456 Next, we create a disklabel in that partition
1457 .Po
1458 .Dq slice
1459 in disklabel terminology
1460 .Pc
1461 with room for up to 20 partitions:
1462 .Bd -literal -offset indent
1463 /sbin/gpart create -s BSD -n 20 ada0s1
1464 .Ed
1465 .Pp
1466 We then create an 8 GB root partition and a 4 GB swap partition:
1467 .Bd -literal -offset indent
1468 /sbin/gpart add -t freebsd-ufs -s 8G ada0s1
1469 /sbin/gpart add -t freebsd-swap -s 4G ada0s1
1470 .Ed
1471 .Pp
1472 Finally, we install the appropriate boot loader for the
1473 .Bx
1474 label:
1475 .Bd -literal -offset indent
1476 /sbin/gpart bootcode -b /boot/boot ada0s1
1477 .Ed
1478 .Ss VTOC8
1479 Create a VTOC8 scheme on
1480 .Pa da0 :
1481 .Bd -literal -offset indent
1482 /sbin/gpart create -s VTOC8 da0
1483 .Ed
1484 .Pp
1485 Create a 512MB-sized
1486 .Cm freebsd-ufs
1487 partition to contain a UFS filesystem from which the system can boot.
1488 .Bd -literal -offset indent
1489 /sbin/gpart add -s 512M -t freebsd-ufs da0
1490 .Ed
1491 .Pp
1492 Create a 15GB-sized
1493 .Cm freebsd-ufs
1494 partition to contain a UFS filesystem and aligned on 4KB boundaries:
1495 .Bd -literal -offset indent
1496 /sbin/gpart add -s 15G -t freebsd-ufs -a 4k da0
1497 .Ed
1498 .Pp
1499 After creating all required partitions, embed bootstrap code into them:
1500 .Bd -literal -offset indent
1501 /sbin/gpart bootcode -p /boot/boot1 da0
1502 .Ed
1503 .Ss Deleting Partitions and Destroying the Partitioning Scheme
1504 If a
1505 .Em "Device busy"
1506 error is shown when trying to destroy a partition table, remember that
1507 all of the partitions must be deleted first with the
1508 .Cm delete
1509 action.
1510 In this example,
1511 .Pa da0
1512 has three partitions:
1513 .Bd -literal -offset indent
1514 /sbin/gpart delete -i 3 da0
1515 /sbin/gpart delete -i 2 da0
1516 /sbin/gpart delete -i 1 da0
1517 /sbin/gpart destroy da0
1518 .Ed
1519 .Pp
1520 Rather than deleting each partition and then destroying the partitioning
1521 scheme, the
1522 .Fl F
1523 option can be given with
1524 .Cm destroy
1525 to delete all of the partitions before destroying the partitioning scheme.
1526 This is equivalent to the previous example:
1527 .Bd -literal -offset indent
1528 /sbin/gpart destroy -F da0
1529 .Ed
1530 .Ss Backup and Restore
1531 Create a backup of the partition table from
1532 .Pa da0 :
1533 .Bd -literal -offset indent
1534 /sbin/gpart backup da0 > da0.backup
1535 .Ed
1536 .Pp
1537 Restore the partition table from the backup to
1538 .Pa da0 :
1539 .Bd -literal -offset indent
1540 /sbin/gpart restore -l da0 < /mnt/da0.backup
1541 .Ed
1542 .Pp
1543 Clone the partition table from
1544 .Pa ada0
1545 to
1546 .Pa ada1
1547 and
1548 .Pa ada2 :
1549 .Bd -literal -offset indent
1550 /sbin/gpart backup ada0 | /sbin/gpart restore -F ada1 ada2
1551 .Ed
1552 .Sh SEE ALSO
1553 .Xr geom 4 ,
1554 .Xr boot0cfg 8 ,
1555 .Xr geom 8 ,
1556 .Xr glabel 8 ,
1557 .Xr gptboot 8
1558 .Sh HISTORY
1559 The
1560 .Nm
1561 utility appeared in
1562 .Fx 7.0 .
1563 .Sh AUTHORS
1564 .An Marcel Moolenaar Aq Mt marcel@FreeBSD.org
1565 .Sh CAVEATS
1566 Partition type
1567 .Em apple-zfs
1568 (6a898cc3-1dd2-11b2-99a6-080020736631) is also being used
1569 on illumos/Solaris platforms for ZFS volumes.