]> CyberLeo.Net >> Repos - FreeBSD/releng/8.2.git/blob - sbin/geom/class/part/gpart.8
Copy stable/8 to releng/8.2 in preparation for FreeBSD-8.2 release.
[FreeBSD/releng/8.2.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 November 22, 2010
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\r
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 ommitted. 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\r
344 Forced destroying of the partition table even if it is not empty.\r
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. Only partition table
426 may be restored. This action does not affect content of partitions.
427 This mean that you should copy your data from backup after restoring
428 partition table and write bootcode again if it is needed. 
429 .Pp
430 Additional options include:
431 .Bl -tag -width 10n
432 .It Fl F
433 Destroy partition table on the given
434 .Ar provider
435 before doing restore.
436 .It Fl l
437 Restore partition labels for partitioning schemes that support them.
438 .It Fl f Ar flags
439 Additional operational flags.
440 See the section entitled
441 .Sx "OPERATIONAL FLAGS"
442 below for a discussion
443 about its use.
444 .El
445 .\" ==== SET ====
446 .It Cm set
447 Set the named attribute on the partition entry.
448 See the section entitled
449 .Sx "ATTRIBUTES"
450 below for a list of available attributes.
451 .Pp
452 Additional options include:
453 .Bl -tag -width 10n
454 .It Fl f Ar flags
455 Additional operational flags.
456 See the section entitled
457 .Sx "OPERATIONAL FLAGS"
458 below for a discussion
459 about its use.
460 .El
461 .\" ==== SHOW ====
462 .It Cm show
463 Show the current partition information of the specified geoms
464 or all geoms if none are specified.
465 Additional options include:
466 .Bl -tag -width 10n
467 .It Fl l
468 For partition schemes that support partition labels print them
469 instead of partition type.
470 .It Fl r
471 Show raw partition type instead of symbolic name.
472 .El
473 .\" ==== UNDO ====
474 .It Cm undo
475 Revert any pending changes for geom
476 .Ar geom .
477 This action is the opposite of the
478 .Cm commit
479 action and can be used to undo any changes that have not been committed.
480 .\" ==== UNSET ====
481 .It Cm unset
482 Clear the named attribute on the partition entry.
483 See the section entitled
484 .Sx "ATTRIBUTES"
485 below for a list of available attributes.
486 .Pp
487 Additional options include:
488 .Bl -tag -width 10n
489 .It Fl f Ar flags
490 Additional operational flags.
491 See the section entitled
492 .Sx "OPERATIONAL FLAGS"
493 below for a discussion
494 about its use.
495 .El
496 .El
497 .\"
498 .Sh PARTITION TYPES
499 The
500 .Nm
501 utility uses symbolic names for common partition types to avoid that the
502 user needs to know what the partitioning scheme in question is and what
503 the actual number or identification needs to be used for a particular
504 type.
505 The
506 .Nm
507 utility also allows the user to specify scheme-specific partition types
508 for partition types that do not have symbol names.
509 The symbolic names currently understood are:
510 .Bl -tag -width ".Cm freebsd-vinum"
511 .It Cm efi
512 The system partition for computers that use the Extensible Firmware
513 Interface (EFI).
514 In such cases, the GPT partitioning scheme is being used and the
515 actual partition type for the system partition can also be specified as
516 .Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93ab" .
517 .It Cm freebsd
518 A
519 .Fx
520 partition that uses the
521 .Bx
522 disklabel to sub-divide the
523 partition into file systems.
524 This is a legacy partition type and should not be used for the APM
525 or GPT schemes.
526 The scheme-specific types are
527 .Qq Li "!165"
528 for MBR,
529 .Qq Li "!FreeBSD"
530 for APM, and
531 .Qq Li "!516e7cb4-6ecf-11d6-8ff8-00022d09712b"
532 for GPT.
533 .It Cm freebsd-boot
534 A
535 .Fx
536 partition dedicated to bootstrap code.
537 The scheme-specific type is
538 .Qq Li "!83bd6b9d-7f41-11dc-be0b-001560b84f0f"
539 for GPT.
540 .It Cm freebsd-swap
541 A
542 .Fx
543 partition dedicated to swap space.
544 The scheme-specific types are
545 .Qq Li "!FreeBSD-swap"
546 for APM,
547 .Qq Li "!516e7cb5-6ecf-11d6-8ff8-00022d09712b"
548 for GPT, and tag 0x0901 for VTOC8.
549 .It Cm freebsd-ufs
550 A
551 .Fx
552 partition that contains a UFS or UFS2 file system.
553 The scheme-specific types are
554 .Qq Li "!FreeBSD-UFS"
555 for APM,
556 .Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b"
557 for GPT, and tag 0x0902 for VTOC8.
558 .It Cm freebsd-vinum
559 A
560 .Fx
561 partition that contains a Vinum volume.
562 The scheme-specific types are
563 .Qq Li "!FreeBSD-Vinum"
564 for APM,
565 .Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b"
566 for GPT, and tag 0x0903 for VTOC8.
567 .It Cm freebsd-zfs
568 A
569 .Fx
570 partition that contains a ZFS volume.
571 The scheme-specific types are
572 .Qq Li "!FreeBSD-ZFS"
573 for APM,
574 .Qq Li "!516e7cba-6ecf-11d6-8ff8-00022d09712b"
575 for GPT, and 0x0904 for VTOC8.
576 .It Cm mbr
577 A partition that is sub-partitioned by a master boot record (MBR).
578 This type is known as
579 .Qq Li "!024dee41-33e7-11d3-9d69-0008c781f39f"
580 by GPT.
581 .El
582 .Sh ATTRIBUTES
583 The scheme-specific attributes for EBR:
584 .Bl -tag -width ".Ar active"
585 .It Ar active
586 .El
587 .Pp
588 The scheme-specific attributes for GPT:
589 .Bl -tag -width ".Ar bootfailed"
590 .It Ar bootme
591 When set, the
592 .Nm gptboot
593 stage 1 boot loader will try to boot the system from this partition.
594 Multiple partitions might be marked with the
595 .Ar bootme
596 attribute.
597 In such scenario the
598 .Nm gptboot
599 will try all
600 .Ar bootme
601 partitions one by one, until the next boot stage is successfully entered.
602 .It Ar bootonce
603 Setting this attribute automatically sets the
604 .Ar bootme
605 attribute.
606 When set, the
607 .Nm gptboot
608 stage 1 boot loader will try to boot the system from this partition only once.
609 Partitions with both
610 .Ar bootonce
611 and
612 .Ar bootme
613 attributes are tried before partitions with only the
614 .Ar bootme
615 attribute.
616 Before
617 .Ar bootonce
618 partition is tried, the
619 .Nm gptboot
620 removes the
621 .Ar bootme
622 attribute and tries to execute the next boot stage.
623 If it fails, the
624 .Ar bootonce
625 attribute that is now alone is replaced with the
626 .Ar bootfailed
627 attribute.
628 If the execution of the next boot stage succeeds, but the system is not fully
629 booted, the
630 .Nm gptboot
631 will look for
632 .Ar bootonce
633 attributes alone (without the
634 .Ar bootme
635 attribute) on the next system boot and will replace those with the
636 .Ar bootfailed
637 attribute.
638 If the system is fully booted, the
639 .Pa /etc/rc.d/gptboot
640 start-up script will look for partition with the
641 .Ar bootonce
642 attribute alone, will remove the attribute and log that the system was
643 successfully booted from this partition.
644 There should be at most one
645 .Ar bootonce
646 partition when system is successfully booted.
647 Multiple partitions might be marked with the
648 .Ar bootonce
649 and
650 .Ar bootme
651 attribute pairs.
652 .It Ar bootfailed
653 This attribute should not be manually managed.
654 It is managed by the
655 .Nm gptboot
656 stage 1 boot loader and the
657 .Pa /etc/rc.d/gptboot
658 start-up script.
659 This attribute is used to mark partitions that had the
660 .Ar bootonce
661 attribute set, but we failed to boot from them.
662 Once we successfully boot, the
663 .Pa /etc/rc.d/gptboot
664 script will log all the partitions we failed to boot from and will remove the
665 .Ar bootfailed
666 attributes.
667 .El
668 .Pp
669 The scheme-specific attributes for MBR:
670 .Bl -tag -width ".Ar active"
671 .It Ar active
672 .El
673 .Pp
674 The scheme-specific attributes for PC98:
675 .Bl -tag -width ".Ar bootable"
676 .It Ar active
677 .It Ar bootable
678 .El
679 .Sh OPERATIONAL FLAGS
680 Actions other than the
681 .Cm commit
682 and
683 .Cm undo
684 actions take an optional
685 .Fl f Ar flags
686 option.
687 This option is used to specify action-specific operational flags.
688 By default, the
689 .Nm
690 utility defines the
691 .Ql C
692 flag so that the action is immediately
693 committed.
694 The user can specify
695 .Dq Fl f Cm x
696 to have the action result in a pending change that can later, with
697 other pending changes, be committed as a single compound change with
698 the
699 .Cm commit
700 action or reverted with the
701 .Cm undo
702 action.
703 .Sh RECOVERING
704 The GEOM class PART supports recovering of partition tables only for GPT.
705 The GUID partition table has a primary and secondary (backup) copy of
706 metadata for redundance. They are stored in the begining and in the end
707 of device respectively. Therefore it is acceptable to have some corruptions
708 in the metadata that are not fatal to work with GPT. When kernel detects
709 corrupt metadata it marks this table as corrupt and reports about corruption.
710 Any changes in corrupt table are prohibited except
711 .Cm destroy
712 and
713 .Cm recover . 
714 .Pp
715 In case when only first sector is corrupt kernel can not detect GPT even
716 if partition table is not corrupt. You can write protective MBR with
717 .Xr dd 1
718 command to restore ability of GPT detection. The copy of protective MBR is
719 usually located in the
720 .Pa /boot/pmbr
721 file.
722 .Pp
723 In case when some of metadata is corrupt you will get to know about this
724 from kernel's messages like these:
725 .Bd -literal -offset indent
726 GEOM: provider: the primary GPT table is corrupt or invalid.
727 GEOM: provider: using the secondary instead -- recovery strongly advised.
728 .Ed
729 .Pp
730 or
731 .Bd -literal -offset indent
732 GEOM: provider: the secondary GPT table is corrupt or invalid.
733 GEOM: provider: using the primary only -- recovery suggested.
734 .Ed
735 .Pp
736 Also 
737 .Cm gpart 
738 commands like 
739 .Cm show ,
740 .Cm status
741 and
742 .Cm list
743 will report about corrupt table.
744 .Pp
745 In case when the size of device has changed (e.g. volume expansion) the 
746 secondary GPT header will become located not in the last sector. This is 
747 not a metadata corruption, but it is dangerous because any corruption of 
748 the primary GPT will lead to lost of partition table. Kernel reports about 
749 this problem with message:
750 .Bd -literal -offset indent
751 GEOM: provider: the secondary GPT header is not in the last LBA.
752 .Ed
753 .Pp
754 A corrupt table can be recovered with 
755 .Cm gpart recover 
756 command. This command does reconstruction of corrupt metadata using 
757 known valid metadata. Also it can relocate secondary GPT to the end of 
758 device.
759 .Pp
760 .Pa NOTE :
761 The GEOM class PART can detect the same partition table on different GEOM 
762 providers and some of them will marked as corrupt. Be careful when choising 
763 a provider for recovering. If you did incorrect choise you can destroy 
764 metadata of another GEOM class, e.g. GEOM MIRROR or GEOM LABEL.
765 .Sh EXIT STATUS
766 Exit status is 0 on success, and 1 if the command fails.
767 .Sh EXAMPLES
768 Create GPT scheme on
769 .Pa ad0 .
770 .Bd -literal -offset indent
771 /sbin/gpart create -s GPT ad0
772 .Ed
773 .Pp
774 Embed GPT bootstrap code into protective MBR.
775 .Bd -literal -offset indent
776 /sbin/gpart bootcode -b /boot/pmbr ad0
777 .Ed
778 .Pp
779 Create a dedicated
780 .Cm freebsd-boot
781 partition that can boot
782 .Fx
783 from a
784 .Cm freebsd-ufs
785 partition, and install bootstrap code into it.
786 This partition must be larger than
787 .Pa /boot/gptboot ,
788 or the GPT boot you are planning to write, but smaller than 545 KB.
789 A size of 15 blocks (7680 bytes) would be sufficient for
790 booting from UFS but let's use 128 blocks (64 KB) here in
791 this example, in order to reserve some space for potential
792 future need (e.g.\& from a ZFS partition).
793 .Bd -literal -offset indent
794 /sbin/gpart add -b 34 -s 128 -t freebsd-boot ad0
795 /sbin/gpart bootcode -p /boot/gptboot -i 1 ad0
796 .Ed
797 .Pp
798 Create a 512MB-sized
799 .Cm freebsd-ufs
800 partition that would contain UFS where the system boots from.
801 .Bd -literal -offset indent
802 /sbin/gpart add -b 162 -s 1048576 -t freebsd-ufs ad0
803 .Ed
804 .Pp
805 Create VTOC8 scheme on
806 .Pa da0 .
807 .Bd -literal -offset indent
808 /sbin/gpart create -s VTOC8 da0
809 .Ed
810 .Pp
811 Create a 512MB-sized
812 .Cm freebsd-ufs
813 partition that would contain UFS where the system boots from.
814 .Bd -literal -offset indent
815 /sbin/gpart add -s 512M -t freebsd-ufs da0
816 .Ed
817 .Pp
818 After having created all required partitions, embed bootstrap code into them.
819 .Bd -literal -offset indent
820 /sbin/gpart bootcode -p /boot/boot1 da0
821 .Ed
822 .Pp
823 Create backup of partition table from
824 .Pa da0
825 .Bd -literal -offset indent
826 /sbin/gpart backup da0 > da0.backup
827 .Ed
828 .Pp
829 Restore partition table from backup to
830 .Pa da0
831 .Bd -literal -offset indent
832 /sbin/gpart restore -l da0 < /mnt/da0.backup
833 .Ed
834 .Pp
835 Clone partition table from 
836 .Pa ada0 
837 to 
838 .Pa ada1 
839 and 
840 .Pa ada2
841 .Bd -literal -offset indent
842 /sbin/gpart backup ada0 | /sbin/gpart restore -F ada1 ada2
843 .Ed
844 .Sh SEE ALSO
845 .Xr dd 1 ,
846 .Xr geom 4 ,
847 .Xr geom 8
848 .Sh HISTORY
849 The
850 .Nm
851 utility appeared in
852 .Fx 7.0 .
853 .Sh AUTHORS
854 .An Marcel Moolenaar Aq marcel@FreeBSD.org