]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sbin/geom/class/part/gpart.8
Document the "bios-boot" partition type.
[FreeBSD/FreeBSD.git] / sbin / geom / class / part / gpart.8
1 .\" Copyright (c) 2007, 2008 Marcel Moolenaar
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD$
26 .\"
27 .Dd January 28, 2011
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 To add support for the disk partitioning GEOM class,
35 place one or more of the following
36 lines in your kernel configuration file:
37 .Bd -ragged -offset indent
38 .Cd "options GEOM_PART_APM"
39 .Cd "options GEOM_PART_BSD"
40 .Cd "options GEOM_PART_EBR"
41 .Cd "options GEOM_PART_GPT"
42 .Cd "options GEOM_PART_MBR"
43 .Cd "options GEOM_PART_PC98"
44 .Cd "options GEOM_PART_VTOC8"
45 .Ed
46 .Pp
47 The
48 .Dv GEOM_PART_APM
49 option adds support for the Apple Partition Map (APM)
50 found on Apple Macintosh computers.
51 The
52 .Dv GEOM_PART_BSD
53 option adds support for the traditional
54 .Bx
55 disklabel.
56 The
57 .Dv GEOM_PART_EBR
58 option adds support for the Extended Boot Record (EBR),
59 which is used to define a logical partition.
60 The
61 .Dv GEOM_PART_GPT
62 option adds support for the GUID Partition Table (GPT)
63 found on Intel Itanium computers and Intel-based Macintosh computers.
64 The
65 .Dv GEOM_PART_MBR
66 option adds support for the Master Boot Record (MBR)
67 found on PCs and used on many removable media.
68 The
69 .Dv GEOM_PART_PC98
70 option adds support for the MBR variant as used on
71 NEC PC-98 computers.
72 The
73 .Dv GEOM_PART_VTOC8
74 option adds support for Sun's SMI VTOC8 label as
75 found on computers based on
76 .Tn SPARC64
77 and
78 .Tn UltraSPARC.
79 .Pp
80 Usage of the
81 .Ns Nm
82 utility:
83 .Pp
84 .\" ==== ADD ====
85 .Nm
86 .Cm add
87 .Fl t Ar type
88 .Op Fl b Ar start
89 .Op Fl s Ar size
90 .Op Fl i Ar index
91 .Op Fl l Ar label
92 .Op Fl f Ar flags
93 .Ar geom
94 .\" ==== BACKUP ====
95 .Nm
96 .Cm backup
97 .Ar geom
98 .\" ==== BOOTCODE ====
99 .Nm
100 .Cm bootcode
101 .Op Fl b Ar bootcode
102 .Op Fl p Ar partcode Fl i Ar index
103 .Op Fl f Ar flags
104 .Ar geom
105 .\" ==== COMMIT ====
106 .Nm
107 .Cm commit
108 .Ar geom
109 .\" ==== CREATE ====
110 .Nm
111 .Cm create
112 .Fl s Ar scheme
113 .Op Fl n Ar entries
114 .Op Fl f Ar flags
115 .Ar provider
116 .\" ==== DELETE ====
117 .Nm
118 .Cm delete
119 .Fl i Ar index
120 .Op Fl f Ar flags
121 .Ar geom
122 .\" ==== DESTROY ====
123 .Nm
124 .Cm destroy
125 .Op Fl F
126 .Op Fl f Ar flags
127 .Ar geom
128 .\" ==== MODIFY ====
129 .Nm
130 .Cm modify
131 .Fl i Ar index
132 .Op Fl l Ar label
133 .Op Fl t Ar type
134 .Op Fl f Ar flags
135 .Ar geom
136 .\" ==== RECOVER ====
137 .Nm
138 .Cm recover
139 .Op Fl f Ar flags
140 .Ar geom
141 .\" ==== RESIZE ====
142 .Nm
143 .Cm resize
144 .Fl i Ar index
145 .Op Fl s Ar size
146 .Op Fl f Ar flags
147 .Ar geom
148 .\" ==== RESTORE ====
149 .Nm
150 .Cm restore
151 .Op Fl lF
152 .Op Fl f Ar flags
153 .Ar provider
154 .Op Ar ...
155 .\" ==== SET ====
156 .Nm
157 .Cm set
158 .Fl a Ar attrib
159 .Fl i Ar index
160 .Op Fl f Ar flags
161 .Ar geom
162 .\" ==== SHOW ====
163 .Nm
164 .Cm show
165 .Op Fl lr
166 .Op Ar geom ...
167 .\" ==== UNDO ====
168 .Nm
169 .Cm undo
170 .Ar geom
171 .\" ==== UNSET ====
172 .Nm
173 .Cm unset
174 .Fl a Ar attrib
175 .Fl i Ar index
176 .Op Fl f Ar flags
177 .Ar geom
178 .\"
179 .Sh DESCRIPTION
180 The
181 .Nm
182 utility is used to partition GEOM providers, normally disks.
183 The first argument of which is the action to be taken:
184 .Bl -tag -width ".Cm bootcode"
185 .\" ==== ADD ====
186 .It Cm add
187 Add a new partition to the partitioning scheme given by
188 .Ar geom .
189 The partition begins on the logical block address given by the
190 .Fl b Ar start
191 option.
192 Its size is given by the
193 .Fl s Ar size
194 option. SI unit suffixes are allowed. One or both
195 .Fl b
196 and
197 .Fl s
198 options can be omitted. If so they are automatically calculated.
199 The type of the partition is given by the
200 .Fl t Ar type
201 option.
202 Partition types are discussed below in the section entitled
203 .Sx "PARTITION TYPES" .
204 .Pp
205 Additional options include:
206 .Bl -tag -width 10n
207 .It Fl i Ar index
208 The index in the partition table at which the new partition is to be
209 placed.
210 The index determines the name of the device special file used
211 to represent the partition.
212 .It Fl l Ar label
213 The label attached to the partition.
214 This option is only valid when used on partitioning schemes that support
215 partition labels.
216 .It Fl f Ar flags
217 Additional operational flags.
218 See the section entitled
219 .Sx "OPERATIONAL FLAGS"
220 below for a discussion
221 about its use.
222 .El
223 .\" ==== BACKUP ====
224 .It Cm backup
225 Dump a partition table to standard output in special format used by
226 .Cm restore
227 action.
228 .\" ==== BOOTCODE ====
229 .It Cm bootcode
230 Embed bootstrap code into the partitioning scheme's metadata on the
231 .Ar geom
232 (using
233 .Fl b Ar bootcode )
234 or write bootstrap code into a partition (using
235 .Fl p Ar partcode
236 and
237 .Fl i Ar index ) .
238 Not all partitioning schemes have embedded bootstrap code, so the
239 .Fl b Ar bootcode
240 option is scheme-specific in nature.
241 For the GPT scheme, embedded bootstrap code is supported.
242 The bootstrap code is embedded in the protective MBR rather than the GPT.
243 The
244 .Fl b Ar bootcode
245 option specifies a file that contains the bootstrap code.
246 The contents and size of the file are determined by the partitioning
247 scheme.
248 For the MBR scheme, it is a 512 byte file of which the first 446 bytes
249 are installed as bootstrap code.
250 The
251 .Fl p Ar partcode
252 option specifies a file that contains the bootstrap code intended to be
253 written to a partition.
254 For the VTOC8 scheme, it is a 8192 byte file of which the last 7680 bytes
255 are installed as bootstrap code.
256 The partition is specified by the
257 .Fl i Ar index
258 option.
259 For the VTOC8 scheme, if the
260 .Fl i Ar index
261 option is omitted, the bootstrap code is written to all sufficiently large
262 partitions.
263 The size of the file must be smaller than the size of the partition.
264 .Pp
265 Additional options include:
266 .Bl -tag -width 10n
267 .It Fl f Ar flags
268 Additional operational flags.
269 See the section entitled
270 .Sx "OPERATIONAL FLAGS"
271 below for a discussion
272 about its use.
273 .El
274 .\" ==== COMMIT ====
275 .It Cm commit
276 Commit any pending changes for geom
277 .Ar geom .
278 All actions are being committed by default and will not result in
279 pending changes.
280 Actions can be modified with the
281 .Fl f Ar flags
282 option so that they are not being committed by default.
283 As such, they become pending.
284 Pending changes are reflected by the geom and the
285 .Nm
286 utility, but they are not actually written to disk.
287 The
288 .Cm commit
289 action will write any and all pending changes to disk.
290 .\" ==== CREATE ====
291 .It Cm create
292 Create a new partitioning scheme on a provider given by
293 .Ar provider .
294 The
295 .Fl s Ar scheme
296 option determines the scheme to use.
297 The kernel needs to have support for a particular scheme before
298 that scheme can be used to partition a disk.
299 .Pp
300 Additional options include:
301 .Bl -tag -width 10n
302 .It Fl n Ar entries
303 The number of entries in the partition table.
304 Every partitioning scheme has a minimum and a maximum number of entries
305 and this option allows tables to be created with the number of entries
306 that lies anywhere between the minimum and the maximum.
307 Some schemes have a maximum equal to the minimum and some schemes have
308 a maximum large enough to be considered unlimited.
309 By default, partition tables are created with the minimum number of
310 entries.
311 .It Fl f Ar flags
312 Additional operational flags.
313 See the section entitled
314 .Sx "OPERATIONAL FLAGS"
315 below for a discussion
316 about its use.
317 .El
318 .\" ==== DELETE ====
319 .It Cm delete
320 Delete a partition from geom
321 .Ar geom
322 and further identified by the
323 .Fl i Ar index
324 option.
325 The partition cannot be actively used by the kernel.
326 .Pp
327 Additional options include:
328 .Bl -tag -width 10n
329 .It Fl f Ar flags
330 Additional operational flags.
331 See the section entitled
332 .Sx "OPERATIONAL FLAGS"
333 below for a discussion
334 about its use.
335 .El
336 .\" ==== DESTROY ====
337 .It Cm destroy
338 Destroy the partitioning scheme as implemented by geom
339 .Ar geom .
340 .Pp
341 Additional options include:
342 .Bl -tag -width 10n
343 .It Fl F
344 Forced destroying of the partition table even if it is not empty.
345 .It Fl f Ar flags
346 Additional operational flags.
347 See the section entitled
348 .Sx "OPERATIONAL FLAGS"
349 below for a discussion
350 about its use.
351 .El
352 .\" ==== MODIFY ====
353 .It Cm modify
354 Modify a partition from geom
355 .Ar geom
356 and further identified by the
357 .Fl i Ar index
358 option.
359 Only the the type and/or label of the partition can be modified.
360 To change the type of a partition, specify the new type with the
361 .Fl t Ar type
362 option.
363 To change the label of a partition, specify the new label with the
364 .Fl l Ar label
365 option.
366 Not all partitioning schemes support labels and it is invalid to
367 try to change a partition label in such cases.
368 .Pp
369 Additional options include:
370 .Bl -tag -width 10n
371 .It Fl f Ar flags
372 Additional operational flags.
373 See the section entitled
374 .Sx "OPERATIONAL FLAGS"
375 below for a discussion
376 about its use.
377 .El
378 .\" ==== RECOVER ====
379 .It Cm recover
380 Recover corrupt partition's scheme metadata on the geom
381 .Ar geom .
382 See the section entitled
383 .Sx "RECOVERING"
384 below for the additional information.
385 .Pp
386 Additional options include:
387 .Bl -tag -width 10n
388 .It Fl f Ar flags
389 Additional operational flags.
390 See the section entitled
391 .Sx "OPERATIONAL FLAGS"
392 below for a discussion
393 about its use.
394 .El
395 .\" ==== RESIZE ====
396 .It Cm resize
397 Resize a partition from geom
398 .Ar geom
399 and further identified by the
400 .Fl i Ar index
401 option.
402 New partition size is expressed in logical block
403 numbers and can be given by the
404 .Fl s Ar size
405 option.
406 If
407 .Fl s
408 option is omitted then new size is automatically calculated
409 to maximum available from given geom
410 .Ar geom .
411 .Pp
412 Additional options include:
413 .Bl -tag -width 10n
414 .It Fl f Ar flags
415 Additional operational flags.
416 See the section entitled
417 .Sx "OPERATIONAL FLAGS"
418 below for a discussion
419 about its use.
420 .El
421 .\" ==== RESTORE ====
422 .It Cm restore
423 Restore the partition table from backup previously created by
424 .Cm backup
425 action and given from standard input.
426 Only partition table may be restored.
427 This action does not affect content of partitions.
428 This mean that you should copy your data from backup after restoring
429 partition table and write bootcode again if it is needed. 
430 .Pp
431 Additional options include:
432 .Bl -tag -width 10n
433 .It Fl F
434 Destroy partition table on the given
435 .Ar provider
436 before doing restore.
437 .It Fl l
438 Restore partition labels for partitioning schemes that support them.
439 .It Fl f Ar flags
440 Additional operational flags.
441 See the section entitled
442 .Sx "OPERATIONAL FLAGS"
443 below for a discussion
444 about its use.
445 .El
446 .\" ==== SET ====
447 .It Cm set
448 Set the named attribute on the partition entry.
449 See the section entitled
450 .Sx "ATTRIBUTES"
451 below for a list of available attributes.
452 .Pp
453 Additional options include:
454 .Bl -tag -width 10n
455 .It Fl f Ar flags
456 Additional operational flags.
457 See the section entitled
458 .Sx "OPERATIONAL FLAGS"
459 below for a discussion
460 about its use.
461 .El
462 .\" ==== SHOW ====
463 .It Cm show
464 Show the current partition information of the specified geoms
465 or all geoms if none are specified.
466 Additional options include:
467 .Bl -tag -width 10n
468 .It Fl l
469 For partition schemes that support partition labels print them
470 instead of partition type.
471 .It Fl r
472 Show raw partition type instead of symbolic name.
473 .El
474 .\" ==== UNDO ====
475 .It Cm undo
476 Revert any pending changes for geom
477 .Ar geom .
478 This action is the opposite of the
479 .Cm commit
480 action and can be used to undo any changes that have not been committed.
481 .\" ==== UNSET ====
482 .It Cm unset
483 Clear the named attribute on the partition entry.
484 See the section entitled
485 .Sx "ATTRIBUTES"
486 below for a list of available attributes.
487 .Pp
488 Additional options include:
489 .Bl -tag -width 10n
490 .It Fl f Ar flags
491 Additional operational flags.
492 See the section entitled
493 .Sx "OPERATIONAL FLAGS"
494 below for a discussion
495 about its use.
496 .El
497 .El
498 .\"
499 .Sh PARTITION TYPES
500 The
501 .Nm
502 utility uses symbolic names for common partition types to avoid that the
503 user needs to know what the partitioning scheme in question is and what
504 the actual number or identification needs to be used for a particular
505 type.
506 The
507 .Nm
508 utility also allows the user to specify scheme-specific partition types
509 for partition types that do not have symbol names.
510 The symbolic names currently understood are:
511 .Bl -tag -width ".Cm freebsd-vinum"
512 .It Cm bios-boot
513 The system partition dedicated to second stage of the boot loader program.
514 Usually it used by GRUB 2 loader when the partition table is GPT.
515 The scheme-specific type is
516 .Qq Li "!21686148-6449-6E6F-744E-656564454649" .
517 .It Cm efi
518 The system partition for computers that use the Extensible Firmware
519 Interface (EFI).
520 In such cases, the GPT partitioning scheme is being used and the
521 actual partition type for the system partition can also be specified as
522 .Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93ab" .
523 .It Cm freebsd
524 A
525 .Fx
526 partition that uses the
527 .Bx
528 disklabel to sub-divide the
529 partition into file systems.
530 This is a legacy partition type and should not be used for the APM
531 or GPT schemes.
532 The scheme-specific types are
533 .Qq Li "!165"
534 for MBR,
535 .Qq Li "!FreeBSD"
536 for APM, and
537 .Qq Li "!516e7cb4-6ecf-11d6-8ff8-00022d09712b"
538 for GPT.
539 .It Cm freebsd-boot
540 A
541 .Fx
542 partition dedicated to bootstrap code.
543 The scheme-specific type is
544 .Qq Li "!83bd6b9d-7f41-11dc-be0b-001560b84f0f"
545 for GPT.
546 .It Cm freebsd-swap
547 A
548 .Fx
549 partition dedicated to swap space.
550 The scheme-specific types are
551 .Qq Li "!FreeBSD-swap"
552 for APM,
553 .Qq Li "!516e7cb5-6ecf-11d6-8ff8-00022d09712b"
554 for GPT, and tag 0x0901 for VTOC8.
555 .It Cm freebsd-ufs
556 A
557 .Fx
558 partition that contains a UFS or UFS2 file system.
559 The scheme-specific types are
560 .Qq Li "!FreeBSD-UFS"
561 for APM,
562 .Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b"
563 for GPT, and tag 0x0902 for VTOC8.
564 .It Cm freebsd-vinum
565 A
566 .Fx
567 partition that contains a Vinum volume.
568 The scheme-specific types are
569 .Qq Li "!FreeBSD-Vinum"
570 for APM,
571 .Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b"
572 for GPT, and tag 0x0903 for VTOC8.
573 .It Cm freebsd-zfs
574 A
575 .Fx
576 partition that contains a ZFS volume.
577 The scheme-specific types are
578 .Qq Li "!FreeBSD-ZFS"
579 for APM,
580 .Qq Li "!516e7cba-6ecf-11d6-8ff8-00022d09712b"
581 for GPT, and 0x0904 for VTOC8.
582 .It Cm mbr
583 A partition that is sub-partitioned by a master boot record (MBR).
584 This type is known as
585 .Qq Li "!024dee41-33e7-11d3-9d69-0008c781f39f"
586 by GPT.
587 .El
588 .Sh ATTRIBUTES
589 The scheme-specific attributes for EBR:
590 .Bl -tag -width ".Ar active"
591 .It Ar active
592 .El
593 .Pp
594 The scheme-specific attributes for GPT:
595 .Bl -tag -width ".Ar bootfailed"
596 .It Ar bootme
597 When set, the
598 .Nm gptboot
599 stage 1 boot loader will try to boot the system from this partition.
600 Multiple partitions might be marked with the
601 .Ar bootme
602 attribute.
603 In such scenario the
604 .Nm gptboot
605 will try all
606 .Ar bootme
607 partitions one by one, until the next boot stage is successfully entered.
608 .It Ar bootonce
609 Setting this attribute automatically sets the
610 .Ar bootme
611 attribute.
612 When set, the
613 .Nm gptboot
614 stage 1 boot loader will try to boot the system from this partition only once.
615 Partitions with both
616 .Ar bootonce
617 and
618 .Ar bootme
619 attributes are tried before partitions with only the
620 .Ar bootme
621 attribute.
622 Before
623 .Ar bootonce
624 partition is tried, the
625 .Nm gptboot
626 removes the
627 .Ar bootme
628 attribute and tries to execute the next boot stage.
629 If it fails, the
630 .Ar bootonce
631 attribute that is now alone is replaced with the
632 .Ar bootfailed
633 attribute.
634 If the execution of the next boot stage succeeds, but the system is not fully
635 booted, the
636 .Nm gptboot
637 will look for
638 .Ar bootonce
639 attributes alone (without the
640 .Ar bootme
641 attribute) on the next system boot and will replace those with the
642 .Ar bootfailed
643 attribute.
644 If the system is fully booted, the
645 .Pa /etc/rc.d/gptboot
646 start-up script will look for partition with the
647 .Ar bootonce
648 attribute alone, will remove the attribute and log that the system was
649 successfully booted from this partition.
650 There should be at most one
651 .Ar bootonce
652 partition when system is successfully booted.
653 Multiple partitions might be marked with the
654 .Ar bootonce
655 and
656 .Ar bootme
657 attribute pairs.
658 .It Ar bootfailed
659 This attribute should not be manually managed.
660 It is managed by the
661 .Nm gptboot
662 stage 1 boot loader and the
663 .Pa /etc/rc.d/gptboot
664 start-up script.
665 This attribute is used to mark partitions that had the
666 .Ar bootonce
667 attribute set, but we failed to boot from them.
668 Once we successfully boot, the
669 .Pa /etc/rc.d/gptboot
670 script will log all the partitions we failed to boot from and will remove the
671 .Ar bootfailed
672 attributes.
673 .El
674 .Pp
675 The scheme-specific attributes for MBR:
676 .Bl -tag -width ".Ar active"
677 .It Ar active
678 .El
679 .Pp
680 The scheme-specific attributes for PC98:
681 .Bl -tag -width ".Ar bootable"
682 .It Ar active
683 .It Ar bootable
684 .El
685 .Sh OPERATIONAL FLAGS
686 Actions other than the
687 .Cm commit
688 and
689 .Cm undo
690 actions take an optional
691 .Fl f Ar flags
692 option.
693 This option is used to specify action-specific operational flags.
694 By default, the
695 .Nm
696 utility defines the
697 .Ql C
698 flag so that the action is immediately
699 committed.
700 The user can specify
701 .Dq Fl f Cm x
702 to have the action result in a pending change that can later, with
703 other pending changes, be committed as a single compound change with
704 the
705 .Cm commit
706 action or reverted with the
707 .Cm undo
708 action.
709 .Sh RECOVERING
710 The GEOM class PART supports recovering of partition tables only for GPT.
711 The GUID partition table has a primary and secondary (backup) copy of
712 metadata for redundance.
713 They are stored in the begining and in the end of device respectively.
714 Therefore it is acceptable to have some corruptions in the metadata that
715 are not fatal to work with GPT.
716 When kernel detects corrupt metadata it marks this table as corrupt and
717 reports about corruption.
718 Any changes in corrupt table are prohibited except
719 .Cm destroy
720 and
721 .Cm recover . 
722 .Pp
723 In case when only first sector is corrupt kernel can not detect GPT even
724 if partition table is not corrupt.
725 You can write protective MBR with
726 .Xr dd 1
727 command to restore ability of GPT detection.
728 The copy of protective MBR is usually located in the
729 .Pa /boot/pmbr
730 file.
731 .Pp
732 In case when some of metadata is corrupt you will get to know about this
733 from kernel's messages like these:
734 .Bd -literal -offset indent
735 GEOM: provider: the primary GPT table is corrupt or invalid.
736 GEOM: provider: using the secondary instead -- recovery strongly advised.
737 .Ed
738 .Pp
739 or
740 .Bd -literal -offset indent
741 GEOM: provider: the secondary GPT table is corrupt or invalid.
742 GEOM: provider: using the primary only -- recovery suggested.
743 .Ed
744 .Pp
745 Also 
746 .Cm gpart 
747 commands like 
748 .Cm show ,
749 .Cm status
750 and
751 .Cm list
752 will report about corrupt table.
753 .Pp
754 In case when the size of device has changed (e.g. volume expansion) the 
755 secondary GPT header will become located not in the last sector.
756 This is not a metadata corruption, but it is dangerous because any
757 corruption of the primary GPT will lead to lost of partition table.
758 Kernel reports about this problem with message:
759 .Bd -literal -offset indent
760 GEOM: provider: the secondary GPT header is not in the last LBA.
761 .Ed
762 .Pp
763 A corrupt table can be recovered with 
764 .Cm gpart recover 
765 command.
766 This command does reconstruction of corrupt metadata using 
767 known valid metadata.
768 Also it can relocate secondary GPT to the end of device.
769 .Pp
770 .Pa NOTE :
771 The GEOM class PART can detect the same partition table on different GEOM 
772 providers and some of them will be marked as corrupt.
773 Be careful when choosing a provider for recovering.
774 If you choose incorrectly you can destroy the metadata of another GEOM class,
775 e.g. GEOM MIRROR or GEOM LABEL.
776 .Sh EXIT STATUS
777 Exit status is 0 on success, and 1 if the command fails.
778 .Sh EXAMPLES
779 Create GPT scheme on
780 .Pa ad0 .
781 .Bd -literal -offset indent
782 /sbin/gpart create -s GPT ad0
783 .Ed
784 .Pp
785 Embed GPT bootstrap code into protective MBR.
786 .Bd -literal -offset indent
787 /sbin/gpart bootcode -b /boot/pmbr ad0
788 .Ed
789 .Pp
790 Create a dedicated
791 .Cm freebsd-boot
792 partition that can boot
793 .Fx
794 from a
795 .Cm freebsd-ufs
796 partition, and install bootstrap code into it.
797 This partition must be larger than
798 .Pa /boot/gptboot ,
799 or the GPT boot you are planning to write, but smaller than 545 KB.
800 A size of 15 blocks (7680 bytes) would be sufficient for
801 booting from UFS but let's use 128 blocks (64 KB) here in
802 this example, in order to reserve some space for potential
803 future need (e.g.\& from a ZFS partition).
804 .Bd -literal -offset indent
805 /sbin/gpart add -b 34 -s 128 -t freebsd-boot ad0
806 /sbin/gpart bootcode -p /boot/gptboot -i 1 ad0
807 .Ed
808 .Pp
809 Create a 512MB-sized
810 .Cm freebsd-ufs
811 partition that would contain UFS where the system boots from.
812 .Bd -literal -offset indent
813 /sbin/gpart add -b 162 -s 1048576 -t freebsd-ufs ad0
814 .Ed
815 .Pp
816 Create VTOC8 scheme on
817 .Pa da0 .
818 .Bd -literal -offset indent
819 /sbin/gpart create -s VTOC8 da0
820 .Ed
821 .Pp
822 Create a 512MB-sized
823 .Cm freebsd-ufs
824 partition that would contain UFS where the system boots from.
825 .Bd -literal -offset indent
826 /sbin/gpart add -s 512M -t freebsd-ufs da0
827 .Ed
828 .Pp
829 After having created all required partitions, embed bootstrap code into them.
830 .Bd -literal -offset indent
831 /sbin/gpart bootcode -p /boot/boot1 da0
832 .Ed
833 .Pp
834 Create backup of partition table from
835 .Pa da0
836 .Bd -literal -offset indent
837 /sbin/gpart backup da0 > da0.backup
838 .Ed
839 .Pp
840 Restore partition table from backup to
841 .Pa da0
842 .Bd -literal -offset indent
843 /sbin/gpart restore -l da0 < /mnt/da0.backup
844 .Ed
845 .Pp
846 Clone partition table from 
847 .Pa ada0 
848 to 
849 .Pa ada1 
850 and 
851 .Pa ada2
852 .Bd -literal -offset indent
853 /sbin/gpart backup ada0 | /sbin/gpart restore -F ada1 ada2
854 .Ed
855 .Sh SEE ALSO
856 .Xr dd 1 ,
857 .Xr geom 4 ,
858 .Xr geom 8
859 .Sh HISTORY
860 The
861 .Nm
862 utility appeared in
863 .Fx 7.0 .
864 .Sh AUTHORS
865 .An Marcel Moolenaar Aq marcel@FreeBSD.org