]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/geom/part/gpart.8
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[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 December 23, 2019
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 A 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 A 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 Don't 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 allows to skip the preservation to help with some versions of
224 .Xr boot0 8
225 that don't 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 A 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 disklabel, usually used to subdivide MBR partitions.
555 .Po
556 This scheme can also be used as the sole partitioning method, without
557 an MBR.
558 Partition editing tools from other operating systems often do not
559 understand the bare disklabel partition layout, so this is sometimes
560 called
561 .Dq dangerously dedicated .
562 .Pc
563 Requires the
564 .Cm GEOM_PART_BSD
565 kernel option.
566 .It Cm BSD64
567 64-bit implementation of BSD disklabel used in DragonFlyBSD to subdivide MBR
568 or GPT partitions.
569 Requires the
570 .Cm GEOM_PART_BSD64
571 kernel option.
572 .It Cm LDM
573 The Logical Disk Manager is an implementation of volume manager for
574 Microsoft Windows NT.
575 Requires the
576 .Cd GEOM_PART_LDM
577 kernel option.
578 .It Cm GPT
579 GUID Partition Table is used on Intel-based Macintosh computers and
580 gradually replacing MBR on most PCs and other systems.
581 Requires the
582 .Cm GEOM_PART_GPT
583 kernel option.
584 .It Cm MBR
585 Master Boot Record is used on PCs and removable media.
586 Requires the
587 .Cm GEOM_PART_MBR
588 kernel option.
589 The
590 .Cm GEOM_PART_EBR
591 option adds support for the Extended Boot Record (EBR),
592 which is used to define a logical partition.
593 The
594 .Cm GEOM_PART_EBR_COMPAT
595 option enables backward compatibility for partition names
596 in the EBR scheme.
597 It also prevents any type of actions on such partitions.
598 .It Cm VTOC8
599 Sun's SMI Volume Table Of Contents, used by
600 .Tn SPARC64
601 and
602 .Tn UltraSPARC
603 computers.
604 Requires the
605 .Cm GEOM_PART_VTOC8
606 kernel option.
607 .El
608 .Sh PARTITION TYPES
609 Partition types are identified on disk by particular strings or magic
610 values.
611 The
612 .Nm
613 utility uses symbolic names for common partition types so the user
614 does not need to know these values or other details of the partitioning
615 scheme in question.
616 The
617 .Nm
618 utility also allows the user to specify scheme-specific partition types
619 for partition types that do not have symbolic names.
620 Symbolic names currently understood and used by
621 .Fx
622 are:
623 .Bl -tag -width ".Cm dragonfly-disklabel64"
624 .It Cm apple-boot
625 The system partition dedicated to storing boot loaders on some Apple
626 systems.
627 The scheme-specific types are
628 .Qq Li "!171"
629 for MBR,
630 .Qq Li "!Apple_Bootstrap"
631 for APM, and
632 .Qq Li "!426f6f74-0000-11aa-aa11-00306543ecac"
633 for GPT.
634 .It Cm bios-boot
635 The system partition dedicated to second stage of the boot loader program.
636 Usually it is used by the GRUB 2 loader for GPT partitioning schemes.
637 The scheme-specific type is
638 .Qq Li "!21686148-6449-6E6F-744E-656564454649" .
639 .It Cm efi
640 The system partition for computers that use the Extensible Firmware
641 Interface (EFI).
642 The scheme-specific types are
643 .Qq Li "!239"
644 for MBR, and
645 .Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93b"
646 for GPT.
647 .It Cm freebsd
648 A
649 .Fx
650 partition subdivided into filesystems with a
651 .Bx
652 disklabel.
653 This is a legacy partition type and should not be used for the APM
654 or GPT schemes.
655 The scheme-specific types are
656 .Qq Li "!165"
657 for MBR,
658 .Qq Li "!FreeBSD"
659 for APM, and
660 .Qq Li "!516e7cb4-6ecf-11d6-8ff8-00022d09712b"
661 for GPT.
662 .It Cm freebsd-boot
663 A
664 .Fx
665 partition dedicated to bootstrap code.
666 The scheme-specific type is
667 .Qq Li "!83bd6b9d-7f41-11dc-be0b-001560b84f0f"
668 for GPT.
669 .It Cm freebsd-swap
670 A
671 .Fx
672 partition dedicated to swap space.
673 The scheme-specific types are
674 .Qq Li "!FreeBSD-swap"
675 for APM,
676 .Qq Li "!516e7cb5-6ecf-11d6-8ff8-00022d09712b"
677 for GPT, and tag 0x0901 for VTOC8.
678 .It Cm freebsd-ufs
679 A
680 .Fx
681 partition that contains a UFS or UFS2 filesystem.
682 The scheme-specific types are
683 .Qq Li "!FreeBSD-UFS"
684 for APM,
685 .Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b"
686 for GPT, and tag 0x0902 for VTOC8.
687 .It Cm freebsd-vinum
688 A
689 .Fx
690 partition that contains a Vinum volume.
691 The scheme-specific types are
692 .Qq Li "!FreeBSD-Vinum"
693 for APM,
694 .Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b"
695 for GPT, and tag 0x0903 for VTOC8.
696 .It Cm freebsd-zfs
697 A
698 .Fx
699 partition that contains a ZFS volume.
700 The scheme-specific types are
701 .Qq Li "!FreeBSD-ZFS"
702 for APM,
703 .Qq Li "!516e7cba-6ecf-11d6-8ff8-00022d09712b"
704 for GPT, and 0x0904 for VTOC8.
705 .El
706 .Pp
707 Other symbolic names that can be used with the
708 .Nm
709 utility are:
710 .Bl -tag -width ".Cm dragonfly-disklabel64"
711 .It Cm apple-apfs
712 An Apple macOS partition used for the Apple file system, APFS.
713 .It Cm apple-core-storage
714 An Apple Mac OS X partition used by logical volume manager known as
715 Core Storage.
716 The scheme-specific type is
717 .Qq Li "!53746f72-6167-11aa-aa11-00306543ecac"
718 for GPT.
719 .It Cm apple-hfs
720 An Apple Mac OS X partition that contains a HFS or HFS+ filesystem.
721 The scheme-specific types are
722 .Qq Li "!175"
723 for MBR,
724 .Qq Li "!Apple_HFS"
725 for APM and
726 .Qq Li "!48465300-0000-11aa-aa11-00306543ecac"
727 for GPT.
728 .It Cm apple-label
729 An Apple Mac OS X partition dedicated to partition metadata that descibes
730 disk device.
731 The scheme-specific type is
732 .Qq Li "!4c616265-6c00-11aa-aa11-00306543ecac"
733 for GPT.
734 .It Cm apple-raid
735 An Apple Mac OS X partition used in a software RAID configuration.
736 The scheme-specific type is
737 .Qq Li "!52414944-0000-11aa-aa11-00306543ecac"
738 for GPT.
739 .It Cm apple-raid-offline
740 An Apple Mac OS X partition used in a software RAID configuration.
741 The scheme-specific type is
742 .Qq Li "!52414944-5f4f-11aa-aa11-00306543ecac"
743 for GPT.
744 .It Cm apple-tv-recovery
745 An Apple Mac OS X partition used by Apple TV.
746 The scheme-specific type is
747 .Qq Li "!5265636f-7665-11aa-aa11-00306543ecac"
748 for GPT.
749 .It Cm apple-ufs
750 An Apple Mac OS X partition that contains a UFS filesystem.
751 The scheme-specific types are
752 .Qq Li "!168"
753 for MBR,
754 .Qq Li "!Apple_UNIX_SVR2"
755 for APM and
756 .Qq Li "!55465300-0000-11aa-aa11-00306543ecac"
757 for GPT.
758 .It Cm dragonfly-label32
759 A DragonFlyBSD partition subdivided into filesystems with a
760 .Bx
761 disklabel.
762 The scheme-specific type is
763 .Qq Li "!9d087404-1ca5-11dc-8817-01301bb8a9f5"
764 for GPT.
765 .It Cm dragonfly-label64
766 A DragonFlyBSD partition subdivided into filesystems with a
767 disklabel64.
768 The scheme-specific type is
769 .Qq Li "!3d48ce54-1d16-11dc-8696-01301bb8a9f5"
770 for GPT.
771 .It Cm dragonfly-legacy
772 A legacy partition type used in DragonFlyBSD.
773 The scheme-specific type is
774 .Qq Li "!bd215ab2-1d16-11dc-8696-01301bb8a9f5"
775 for GPT.
776 .It Cm dragonfly-ccd
777 A DragonFlyBSD partition used with Concatenated Disk driver.
778 The scheme-specific type is
779 .Qq Li "!dbd5211b-1ca5-11dc-8817-01301bb8a9f5"
780 for GPT.
781 .It Cm dragonfly-hammer
782 A DragonFlyBSD partition that contains a Hammer filesystem.
783 The scheme-specific type is
784 .Qq Li "!61dc63ac-6e38-11dc-8513-01301bb8a9f5"
785 for GPT.
786 .It Cm dragonfly-hammer2
787 A DragonFlyBSD partition that contains a Hammer2 filesystem.
788 The scheme-specific type is
789 .Qq Li "!5cbb9ad1-862d-11dc-a94d-01301bb8a9f5"
790 for GPT.
791 .It Cm dragonfly-swap
792 A DragonFlyBSD partition dedicated to swap space.
793 The scheme-specific type is
794 .Qq Li "!9d58fdbd-1ca5-11dc-8817-01301bb8a9f5"
795 for GPT.
796 .It Cm dragonfly-ufs
797 A DragonFlyBSD partition that contains an UFS1 filesystem.
798 The scheme-specific type is
799 .Qq Li "!9d94ce7c-1ca5-11dc-8817-01301bb8a9f5"
800 for GPT.
801 .It Cm dragonfly-vinum
802 A DragonFlyBSD partition used with Logical Volume Manager.
803 The scheme-specific type is
804 .Qq Li "!9dd4478f-1ca5-11dc-8817-01301bb8a9f5"
805 for GPT.
806 .It Cm ebr
807 A partition subdivided into filesystems with a EBR.
808 The scheme-specific type is
809 .Qq Li "!5"
810 for MBR.
811 .It Cm fat16
812 A partition that contains a FAT16 filesystem.
813 The scheme-specific type is
814 .Qq Li "!6"
815 for MBR.
816 .It Cm fat32
817 A partition that contains a FAT32 filesystem.
818 The scheme-specific type is
819 .Qq Li "!11"
820 for MBR.
821 .It Cm fat32lba
822 A partition that contains a FAT32 (LBA) filesystem.
823 The scheme-specific type is
824 .Qq Li "!12"
825 for MBR.
826 .It Cm linux-data
827 A Linux partition that contains some filesystem with data.
828 The scheme-specific types are
829 .Qq Li "!131"
830 for MBR and
831 .Qq Li "!0fc63daf-8483-4772-8e79-3d69d8477de4"
832 for GPT.
833 .It Cm linux-lvm
834 A Linux partition dedicated to Logical Volume Manager.
835 The scheme-specific types are
836 .Qq Li "!142"
837 for MBR and
838 .Qq Li "!e6d6d379-f507-44c2-a23c-238f2a3df928"
839 for GPT.
840 .It Cm linux-raid
841 A Linux partition used in a software RAID configuration.
842 The scheme-specific types are
843 .Qq Li "!253"
844 for MBR and
845 .Qq Li "!a19d880f-05fc-4d3b-a006-743f0f84911e"
846 for GPT.
847 .It Cm linux-swap
848 A Linux partition dedicated to swap space.
849 The scheme-specific types are
850 .Qq Li "!130"
851 for MBR and
852 .Qq Li "!0657fd6d-a4ab-43c4-84e5-0933c84b4f4f"
853 for GPT.
854 .It Cm mbr
855 A partition that is sub-partitioned by a Master Boot Record (MBR).
856 This type is known as
857 .Qq Li "!024dee41-33e7-11d3-9d69-0008c781f39f"
858 by GPT.
859 .It Cm ms-basic-data
860 A basic data partition (BDP) for Microsoft operating systems.
861 In the GPT this type is the equivalent to partition types
862 .Cm fat16 , fat32
863 and
864 .Cm ntfs
865 in MBR.
866 This type is used for GPT exFAT partitions.
867 The scheme-specific type is
868 .Qq Li "!ebd0a0a2-b9e5-4433-87c0-68b6b72699c7"
869 for GPT.
870 .It Cm ms-ldm-data
871 A partition that contains Logical Disk Manager (LDM) volumes.
872 The scheme-specific types are
873 .Qq Li "!66"
874 for MBR,
875 .Qq Li "!af9b60a0-1431-4f62-bc68-3311714a69ad"
876 for GPT.
877 .It Cm ms-ldm-metadata
878 A partition that contains Logical Disk Manager (LDM) database.
879 The scheme-specific type is
880 .Qq Li "!5808c8aa-7e8f-42e0-85d2-e1e90434cfb3"
881 for GPT.
882 .It Cm netbsd-ccd
883 A NetBSD partition used with Concatenated Disk driver.
884 The scheme-specific type is
885 .Qq Li "!2db519c4-b10f-11dc-b99b-0019d1879648"
886 for GPT.
887 .It Cm netbsd-cgd
888 An encrypted NetBSD partition.
889 The scheme-specific type is
890 .Qq Li "!2db519ec-b10f-11dc-b99b-0019d1879648"
891 for GPT.
892 .It Cm netbsd-ffs
893 A NetBSD partition that contains an UFS filesystem.
894 The scheme-specific type is
895 .Qq Li "!49f48d5a-b10e-11dc-b99b-0019d1879648"
896 for GPT.
897 .It Cm netbsd-lfs
898 A NetBSD partition that contains an LFS filesystem.
899 The scheme-specific type is
900 .Qq Li "!49f48d82-b10e-11dc-b99b-0019d1879648"
901 for GPT.
902 .It Cm netbsd-raid
903 A NetBSD partition used in a software RAID configuration.
904 The scheme-specific type is
905 .Qq Li "!49f48daa-b10e-11dc-b99b-0019d1879648"
906 for GPT.
907 .It Cm netbsd-swap
908 A NetBSD partition dedicated to swap space.
909 The scheme-specific type is
910 .Qq Li "!49f48d32-b10e-11dc-b99b-0019d1879648"
911 for GPT.
912 .It Cm ntfs
913 A partition that contains a NTFS or exFAT filesystem.
914 The scheme-specific type is
915 .Qq Li "!7"
916 for MBR.
917 .It Cm prep-boot
918 The system partition dedicated to storing boot loaders on some PowerPC systems,
919 notably those made by IBM.
920 The scheme-specific types are
921 .Qq Li "!65"
922 for MBR and
923 .Qq Li "!0x9e1a2d38-c612-4316-aa26-8b49521e5a8b"
924 for GPT.
925 .It Cm vmware-vmfs
926 A partition that contains a VMware File System (VMFS).
927 The scheme-specific types are
928 .Qq Li "!251"
929 for MBR and
930 .Qq Li "!aa31e02a-400f-11db-9590-000c2911d1b8"
931 for GPT.
932 .It Cm vmware-vmkdiag
933 A partition that contains a VMware diagostic filesystem.
934 The scheme-specific types are
935 .Qq Li "!252"
936 for MBR and
937 .Qq Li "!9d275380-40ad-11db-bf97-000c2911d1b8"
938 for GPT.
939 .It Cm vmware-reserved
940 A VMware reserved partition.
941 The scheme-specific type is
942 .Qq Li "!9198effc-31c0-11db-8f-78-000c2911d1b8"
943 for GPT.
944 .It Cm vmware-vsanhdr
945 A partition claimed by VMware VSAN.
946 The scheme-specific type is
947 .Qq Li "!381cfccc-7288-11e0-92ee-000c2911d0b2"
948 for GPT.
949 .El
950 .Sh ATTRIBUTES
951 The scheme-specific attributes for EBR:
952 .Bl -tag -width ".Cm active"
953 .It Cm active
954 .El
955 .Pp
956 The scheme-specific attributes for GPT:
957 .Bl -tag -width ".Cm bootfailed"
958 .It Cm bootme
959 When set, the
960 .Nm gptboot
961 stage 1 boot loader will try to boot the system from this partition.
962 Multiple partitions can be marked with the
963 .Cm bootme
964 attribute.
965 See
966 .Xr gptboot 8
967 for more details.
968 .It Cm bootonce
969 Setting this attribute automatically sets the
970 .Cm bootme
971 attribute.
972 When set, the
973 .Nm gptboot
974 stage 1 boot loader will try to boot the system from this partition only once.
975 Multiple partitions can be marked with the
976 .Cm bootonce
977 and
978 .Cm bootme
979 attribute pairs.
980 See
981 .Xr gptboot 8
982 for more details.
983 .It Cm bootfailed
984 This attribute should not be manually managed.
985 It is managed by the
986 .Nm gptboot
987 stage 1 boot loader and the
988 .Pa /etc/rc.d/gptboot
989 start-up script.
990 See
991 .Xr gptboot 8
992 for more details.
993 .It Cm lenovofix
994 Setting this attribute overwrites the Protective MBR with a new one where
995 the 0xee partition is the second, rather than the first record.
996 This resolves a BIOS compatibility issue with some Lenovo models including the
997 X220, T420, and T520, allowing them to boot from GPT partitioned disks
998 without using EFI.
999 .El
1000 .Pp
1001 The scheme-specific attributes for MBR:
1002 .Bl -tag -width ".Cm active"
1003 .It Cm active
1004 .El
1005 .Sh BOOTSTRAPPING
1006 .Fx
1007 supports several partitioning schemes and each scheme uses different
1008 bootstrap code.
1009 The bootstrap code is located in a specific disk area for each partitioning
1010 scheme, and may vary in size for different schemes.
1011 .Pp
1012 Bootstrap code can be separated into two types.
1013 The first type is embedded in the partitioning scheme's metadata, while the
1014 second type is located on a specific partition.
1015 Embedding bootstrap code should only be done with the
1016 .Cm gpart bootcode
1017 command with the
1018 .Fl b Ar bootcode
1019 option.
1020 The GEOM PART class knows how to safely embed bootstrap code into
1021 specific partitioning scheme metadata without causing any damage.
1022 .Pp
1023 The Master Boot Record (MBR) uses a 512-byte bootstrap code image, embedded
1024 into the partition table's metadata area.
1025 There are two variants of this bootstrap code:
1026 .Pa /boot/mbr
1027 and
1028 .Pa /boot/boot0 .
1029 .Pa /boot/mbr
1030 searches for a partition with the
1031 .Cm active
1032 attribute (see the
1033 .Sx ATTRIBUTES
1034 section) in the partition table.
1035 Then it runs next bootstrap stage.
1036 The
1037 .Pa /boot/boot0
1038 image contains a boot manager with some additional interactive functions
1039 for multi-booting from a user-selected partition.
1040 .Pp
1041 A BSD disklabel is usually created inside an MBR partition (slice)
1042 with type
1043 .Cm freebsd
1044 (see the
1045 .Sx "PARTITION TYPES"
1046 section).
1047 It uses 8 KB size bootstrap code image
1048 .Pa /boot/boot ,
1049 embedded into the partition table's metadata area.
1050 .Pp
1051 Both types of bootstrap code are used to boot from the GUID Partition Table.
1052 First, a protective MBR is embedded into the first disk sector from the
1053 .Pa /boot/pmbr
1054 image.
1055 It searches through the GPT for a
1056 .Cm freebsd-boot
1057 partition (see the
1058 .Sx "PARTITION TYPES"
1059 section) and runs the next bootstrap stage from it.
1060 The
1061 .Cm freebsd-boot
1062 partition should be smaller than 545 KB.
1063 It can be located either before or after other
1064 .Fx
1065 partitions on the disk.
1066 There are two variants of bootstrap code to write to this partition:
1067 .Pa /boot/gptboot
1068 and
1069 .Pa /boot/gptzfsboot .
1070 .Pp
1071 .Pa /boot/gptboot
1072 is used to boot from UFS partitions.
1073 .Cm gptboot
1074 searches through
1075 .Cm freebsd-ufs
1076 partitions in the GPT and selects one to boot based on the
1077 .Cm bootonce
1078 and
1079 .Cm bootme
1080 attributes.
1081 If neither attribute is found,
1082 .Pa /boot/gptboot
1083 boots from the first
1084 .Cm freebsd-ufs
1085 partition.
1086 .Pa /boot/loader
1087 .Pq the third bootstrap stage
1088 is loaded from the first partition that matches these conditions.
1089 See
1090 .Xr gptboot 8
1091 for more information.
1092 .Pp
1093 .Pa /boot/gptzfsboot
1094 is used to boot from ZFS.
1095 It searches through the GPT for
1096 .Cm freebsd-zfs
1097 partitions, trying to detect ZFS pools.
1098 After all pools are detected,
1099 .Pa /boot/loader
1100 is started from the first one found set as bootable.
1101 .Pp
1102 The VTOC8 scheme does not support embedding bootstrap code.
1103 Instead, the 8 KBytes bootstrap code image
1104 .Pa /boot/boot1
1105 should be written with the
1106 .Cm gpart bootcode
1107 command with the
1108 .Fl p Ar bootcode
1109 option to all sufficiently large VTOC8 partitions.
1110 To do this the
1111 .Fl i Ar index
1112 option could be omitted.
1113 .Pp
1114 The APM scheme also does not support embedding bootstrap code.
1115 Instead, the 800 KBytes bootstrap code image
1116 .Pa /boot/boot1.hfs
1117 should be written with the
1118 .Cm gpart bootcode
1119 command to a partition of type
1120 .Cm apple-boot ,
1121 which should also be 800 KB in size.
1122 .Sh OPERATIONAL FLAGS
1123 Actions other than the
1124 .Cm commit
1125 and
1126 .Cm undo
1127 actions take an optional
1128 .Fl f Ar flags
1129 option.
1130 This option is used to specify action-specific operational flags.
1131 By default, the
1132 .Nm
1133 utility defines the
1134 .Ql C
1135 flag so that the action is immediately
1136 committed.
1137 The user can specify
1138 .Dq Fl f Cm x
1139 to have the action result in a pending change that can later, with
1140 other pending changes, be committed as a single compound change with
1141 the
1142 .Cm commit
1143 action or reverted with the
1144 .Cm undo
1145 action.
1146 .Sh RECOVERING
1147 The GEOM PART class supports recovering of partition tables only for GPT.
1148 The GPT primary metadata is stored at the beginning of the device.
1149 For redundancy, a secondary
1150 .Pq backup
1151 copy of the metadata is stored at the end of the device.
1152 As a result of having two copies, some corruption of metadata is not
1153 fatal to the working of GPT.
1154 When the kernel detects corrupt metadata, it marks this table as corrupt
1155 and reports the problem.
1156 .Cm destroy
1157 and
1158 .Cm recover
1159 are the only operations allowed on corrupt tables.
1160 .Pp
1161 If one GPT header appears to be corrupt but the other copy remains intact,
1162 the kernel will log the following:
1163 .Bd -literal -offset indent
1164 GEOM: provider: the primary GPT table is corrupt or invalid.
1165 GEOM: provider: using the secondary instead -- recovery strongly advised.
1166 .Ed
1167 .Pp
1168 or
1169 .Bd -literal -offset indent
1170 GEOM: provider: the secondary GPT table is corrupt or invalid.
1171 GEOM: provider: using the primary only -- recovery suggested.
1172 .Ed
1173 .Pp
1174 Also
1175 .Nm
1176 commands such as
1177 .Cm show , status
1178 and
1179 .Cm list
1180 will report about corrupt tables.
1181 .Pp
1182 If the size of the device has changed (e.g.,\& volume expansion) the
1183 secondary GPT header will no longer be located in the last sector.
1184 This is not a metadata corruption, but it is dangerous because any
1185 corruption of the primary GPT will lead to loss of the partition table.
1186 This problem is reported by the kernel with the message:
1187 .Bd -literal -offset indent
1188 GEOM: provider: the secondary GPT header is not in the last LBA.
1189 .Ed
1190 .Pp
1191 This situation can be recovered with the
1192 .Cm recover
1193 command.
1194 This command reconstructs the corrupt metadata using known valid
1195 metadata and relocates the secondary GPT to the end of the device.
1196 .Pp
1197 .Em NOTE :
1198 The GEOM PART class can detect the same partition table visible through
1199 different GEOM providers, and some of them will be marked as corrupt.
1200 Be careful when choosing a provider for recovery.
1201 If you choose incorrectly you can destroy the metadata of another GEOM class,
1202 e.g.,\& GEOM MIRROR or GEOM LABEL.
1203 .Sh SYSCTL VARIABLES
1204 The following
1205 .Xr sysctl 8
1206 variables can be used to control the behavior of the
1207 .Nm PART
1208 GEOM class.
1209 The default value is shown next to each variable.
1210 .Bl -tag -width indent
1211 .It Va kern.geom.part.allow_nesting : No 0
1212 By default, some schemes (currently BSD, BSD64 and VTOC8) do not permit
1213 further nested partitioning.
1214 This variable overrides this restriction and allows arbitrary nesting (except
1215 within partitions created at offset 0).
1216 Some schemes have their own separate checks, for which see below.
1217 .It Va kern.geom.part.auto_resize : No 1
1218 This variable controls automatic resize behavior of the
1219 .Nm PART
1220 GEOM class.
1221 When this variable is enable and new size of provider is detected, the schema
1222 metadata is resized but all changes are not saved to disk, until
1223 .Cm gpart commit
1224 is run to confirm changes.
1225 This behavior is also reported with diagnostic message:
1226 .Sy "GEOM_PART: (provider) was automatically resized."
1227 .Sy "Use `gpart commit (provider)` to save changes or `gpart undo (provider)`"
1228 .Sy "to revert them."
1229 .It Va kern.geom.part.check_integrity : No 1
1230 This variable controls the behaviour of metadata integrity checks.
1231 When integrity checks are enabled, the
1232 .Nm PART
1233 GEOM class verifies all generic partition parameters obtained from the
1234 disk metadata.
1235 If some inconsistency is detected, the partition table will be
1236 rejected with a diagnostic message:
1237 .Sy "GEOM_PART: Integrity check failed (provider, scheme)" .
1238 .It Va kern.geom.part.gpt.allow_nesting : No 0
1239 By default the GPT scheme is allowed only at the outermost nesting level.
1240 This variable allows this restriction to be removed.
1241 .It Va kern.geom.part.ldm.debug : No 0
1242 Debug level of the Logical Disk Manager (LDM) module.
1243 This can be set to a number between 0 and 2 inclusive.
1244 If set to 0 minimal debug information is printed,
1245 and if set to 2 the maximum amount of debug information is printed.
1246 .It Va kern.geom.part.ldm.show_mirrors : No 0
1247 This variable controls how the Logical Disk Manager (LDM) module handles
1248 mirrored volumes.
1249 By default mirrored volumes are shown as partitions with type
1250 .Cm ms-ldm-data
1251 (see the
1252 .Sx "PARTITION TYPES"
1253 section).
1254 If this variable set to 1 each component of the mirrored volume will be
1255 present as independent partition.
1256 .Em NOTE :
1257 This may break a mirrored volume and lead to data damage.
1258 .It Va kern.geom.part.mbr.enforce_chs : No 0
1259 Specify how the Master Boot Record (MBR) module does alignment.
1260 If this variable is set to a non-zero value, the module will automatically
1261 recalculate the user-specified offset and size for alignment with the CHS
1262 geometry.
1263 Otherwise the values will be left unchanged.
1264 .It Va kern.geom.part.separator : No ""
1265 Specify an optional separator that will be inserted between the GEOM name
1266 and partition name.
1267 This variable is a
1268 .Xr loader 8
1269 tunable.
1270 Note that setting this variable may break software which assumes a particular
1271 naming scheme.
1272 .El
1273 .Sh EXIT STATUS
1274 Exit status is 0 on success, and 1 if the command fails.
1275 .Sh EXAMPLES
1276 The examples below assume that the disk's logical block size is 512
1277 bytes, regardless of its physical block size.
1278 .Ss GPT
1279 In this example, we will format
1280 .Pa ada0
1281 with the GPT scheme and create boot, swap and root partitions.
1282 First, we need to create the partition table:
1283 .Bd -literal -offset indent
1284 /sbin/gpart create -s GPT ada0
1285 .Ed
1286 .Pp
1287 Next, we install a protective MBR with the first-stage bootstrap code.
1288 The protective MBR lists a single, bootable partition spanning the
1289 entire disk, thus allowing non-GPT-aware BIOSes to boot from the disk
1290 and preventing tools which do not understand the GPT scheme from
1291 considering the disk to be unformatted.
1292 .Bd -literal -offset indent
1293 /sbin/gpart bootcode -b /boot/pmbr ada0
1294 .Ed
1295 .Pp
1296 We then create a dedicated
1297 .Cm freebsd-boot
1298 partition to hold the second-stage boot loader, which will load the
1299 .Fx
1300 kernel and modules from a UFS or ZFS filesystem.
1301 This partition must be larger than the bootstrap code
1302 .Po
1303 either
1304 .Pa /boot/gptboot
1305 for UFS or
1306 .Pa /boot/gptzfsboot
1307 for ZFS
1308 .Pc ,
1309 but smaller than 545 kB since the first-stage loader will load the
1310 entire partition into memory during boot, regardless of how much data
1311 it actually contains.
1312 We create a 472-block (236 kB) boot partition at offset 40, which is
1313 the size of the partition table (34 blocks or 17 kB) rounded up to the
1314 nearest 4 kB boundary.
1315 .Bd -literal -offset indent
1316 /sbin/gpart add -b 40 -s 472 -t freebsd-boot ada0
1317 /sbin/gpart bootcode -p /boot/gptboot -i 1 ada0
1318 .Ed
1319 .Pp
1320 We now create a 4 GB swap partition at the first available offset,
1321 which is 40 + 472 = 512 blocks (256 kB).
1322 .Bd -literal -offset indent
1323 /sbin/gpart add -s 4G -t freebsd-swap ada0
1324 .Ed
1325 .Pp
1326 Aligning the swap partition and all subsequent partitions on a 256 kB
1327 boundary ensures optimal performance on a wide range of media, from
1328 plain old disks with 512-byte blocks, through modern
1329 .Dq advanced format
1330 disks with 4096-byte physical blocks, to RAID volumes with stripe
1331 sizes of up to 256 kB.
1332 .Pp
1333 Finally, we create and format an 8 GB
1334 .Cm freebsd-ufs
1335 partition for the root filesystem, leaving the rest of the slice free
1336 for additional filesystems:
1337 .Bd -literal -offset indent
1338 /sbin/gpart add -s 8G -t freebsd-ufs ada0
1339 /sbin/newfs -Uj /dev/ada0p3
1340 .Ed
1341 .Ss MBR
1342 In this example, we will format
1343 .Pa ada0
1344 with the MBR scheme and create a single partition which we subdivide
1345 using a traditional
1346 .Bx
1347 disklabel.
1348 .Pp
1349 First, we create the partition table and a single 64 GB partition,
1350 then we mark that partition active (bootable) and install the
1351 first-stage boot loader:
1352 .Bd -literal -offset indent
1353 /sbin/gpart create -s MBR ada0
1354 /sbin/gpart add -t freebsd -s 64G ada0
1355 /sbin/gpart set -a active -i 1 ada0
1356 /sbin/gpart bootcode -b /boot/boot0 ada0
1357 .Ed
1358 .Pp
1359 Next, we create a disklabel in that partition
1360 .Po
1361 .Dq slice
1362 in disklabel terminology
1363 .Pc
1364 with room for up to 20 partitions:
1365 .Bd -literal -offset indent
1366 /sbin/gpart create -s BSD -n 20 ada0s1
1367 .Ed
1368 .Pp
1369 We then create an 8 GB root partition and a 4 GB swap partition:
1370 .Bd -literal -offset indent
1371 /sbin/gpart add -t freebsd-ufs -s 8G ada0s1
1372 /sbin/gpart add -t freebsd-swap -s 4G ada0s1
1373 .Ed
1374 .Pp
1375 Finally, we install the appropriate boot loader for the
1376 .Bx
1377 label:
1378 .Bd -literal -offset indent
1379 /sbin/gpart bootcode -b /boot/boot ada0s1
1380 .Ed
1381 .Ss VTOC8
1382 .Pp
1383 Create a VTOC8 scheme on
1384 .Pa da0 :
1385 .Bd -literal -offset indent
1386 /sbin/gpart create -s VTOC8 da0
1387 .Ed
1388 .Pp
1389 Create a 512MB-sized
1390 .Cm freebsd-ufs
1391 partition to contain a UFS filesystem from which the system can boot.
1392 .Bd -literal -offset indent
1393 /sbin/gpart add -s 512M -t freebsd-ufs da0
1394 .Ed
1395 .Pp
1396 Create a 15GB-sized
1397 .Cm freebsd-ufs
1398 partition to contain a UFS filesystem and aligned on 4KB boundaries:
1399 .Bd -literal -offset indent
1400 /sbin/gpart add -s 15G -t freebsd-ufs -a 4k da0
1401 .Ed
1402 .Pp
1403 After creating all required partitions, embed bootstrap code into them:
1404 .Bd -literal -offset indent
1405 /sbin/gpart bootcode -p /boot/boot1 da0
1406 .Ed
1407 .Ss Deleting Partitions and Destroying the Partitioning Scheme
1408 If a
1409 .Em "Device busy"
1410 error is shown when trying to destroy a partition table, remember that
1411 all of the partitions must be deleted first with the
1412 .Cm delete
1413 action.
1414 In this example,
1415 .Pa da0
1416 has three partitions:
1417 .Bd -literal -offset indent
1418 /sbin/gpart delete -i 3 da0
1419 /sbin/gpart delete -i 2 da0
1420 /sbin/gpart delete -i 1 da0
1421 /sbin/gpart destroy da0
1422 .Ed
1423 .Pp
1424 Rather than deleting each partition and then destroying the partitioning
1425 scheme, the
1426 .Fl F
1427 option can be given with
1428 .Cm destroy
1429 to delete all of the partitions before destroying the partitioning scheme.
1430 This is equivalent to the previous example:
1431 .Bd -literal -offset indent
1432 /sbin/gpart destroy -F da0
1433 .Ed
1434 .Ss Backup and Restore
1435 .Pp
1436 Create a backup of the partition table from
1437 .Pa da0 :
1438 .Bd -literal -offset indent
1439 /sbin/gpart backup da0 > da0.backup
1440 .Ed
1441 .Pp
1442 Restore the partition table from the backup to
1443 .Pa da0 :
1444 .Bd -literal -offset indent
1445 /sbin/gpart restore -l da0 < /mnt/da0.backup
1446 .Ed
1447 .Pp
1448 Clone the partition table from
1449 .Pa ada0
1450 to
1451 .Pa ada1
1452 and
1453 .Pa ada2 :
1454 .Bd -literal -offset indent
1455 /sbin/gpart backup ada0 | /sbin/gpart restore -F ada1 ada2
1456 .Ed
1457 .Sh SEE ALSO
1458 .Xr geom 4 ,
1459 .Xr boot0cfg 8 ,
1460 .Xr geom 8 ,
1461 .Xr gptboot 8
1462 .Sh HISTORY
1463 The
1464 .Nm
1465 utility appeared in
1466 .Fx 7.0 .
1467 .Sh AUTHORS
1468 .An Marcel Moolenaar Aq Mt marcel@FreeBSD.org