aboutsummaryrefslogtreecommitdiff
path: root/sbin/geom/class/part/gpart.8
blob: 7a91d3dbc07ccfc8bd943abdbc66a17536d0f97b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
.\" Copyright (c) 2007, 2008 Marcel Moolenaar
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd March 19, 2012
.Dt GPART 8
.Os
.Sh NAME
.Nm gpart
.Nd "control utility for the disk partitioning GEOM class"
.Sh SYNOPSIS
To add support for the disk partitioning GEOM class,
place one or more of the following
lines in the kernel configuration file:
.Bd -ragged -offset indent
.Cd "options GEOM_PART_APM"
.Cd "options GEOM_PART_BSD"
.Cd "options GEOM_PART_GPT"
.Cd "options GEOM_PART_LDM"
.Cd "options GEOM_PART_MBR"
.Cd "options GEOM_PART_EBR"
.Cd "options GEOM_PART_EBR_COMPAT"
.Cd "options GEOM_PART_PC98"
.Cd "options GEOM_PART_VTOC8"
.Ed
.Pp
These options provide support for the various types of partitioning
schemes supported by the
.Ns Nm
utility.
See
.Sx "PARTITIONING SCHEMES"
below for more details.
.Pp
Usage of the
.Ns Nm
utility:
.Pp
.\" ==== ADD ====
.Nm
.Cm add
.Fl t Ar type
.Op Fl a Ar alignment
.Op Fl b Ar start
.Op Fl s Ar size
.Op Fl i Ar index
.Op Fl l Ar label
.Op Fl f Ar flags
.Ar geom
.\" ==== BACKUP ====
.Nm
.Cm backup
.Ar geom
.\" ==== BOOTCODE ====
.Nm
.Cm bootcode
.Op Fl b Ar bootcode
.Op Fl p Ar partcode Fl i Ar index
.Op Fl f Ar flags
.Ar geom
.\" ==== COMMIT ====
.Nm
.Cm commit
.Ar geom
.\" ==== CREATE ====
.Nm
.Cm create
.Fl s Ar scheme
.Op Fl n Ar entries
.Op Fl f Ar flags
.Ar provider
.\" ==== DELETE ====
.Nm
.Cm delete
.Fl i Ar index
.Op Fl f Ar flags
.Ar geom
.\" ==== DESTROY ====
.Nm
.Cm destroy
.Op Fl F
.Op Fl f Ar flags
.Ar geom
.\" ==== MODIFY ====
.Nm
.Cm modify
.Fl i Ar index
.Op Fl l Ar label
.Op Fl t Ar type
.Op Fl f Ar flags
.Ar geom
.\" ==== RECOVER ====
.Nm
.Cm recover
.Op Fl f Ar flags
.Ar geom
.\" ==== RESIZE ====
.Nm
.Cm resize
.Fl i Ar index
.Op Fl a Ar alignment
.Op Fl s Ar size
.Op Fl f Ar flags
.Ar geom
.\" ==== RESTORE ====
.Nm
.Cm restore
.Op Fl lF
.Op Fl f Ar flags
.Ar provider
.Op Ar ...
.\" ==== SET ====
.Nm
.Cm set
.Fl a Ar attrib
.Fl i Ar index
.Op Fl f Ar flags
.Ar geom
.\" ==== SHOW ====
.Nm
.Cm show
.Op Fl l | r
.Op Fl p
.Op Ar geom ...
.\" ==== UNDO ====
.Nm
.Cm undo
.Ar geom
.\" ==== UNSET ====
.Nm
.Cm unset
.Fl a Ar attrib
.Fl i Ar index
.Op Fl f Ar flags
.Ar geom
.\"
.Sh DESCRIPTION
The
.Nm
utility is used to partition GEOM providers, normally disks.
The first argument is the action to be taken:
.Bl -tag -width ".Cm bootcode"
.\" ==== ADD ====
.It Cm add
Add a new partition to the partitioning scheme given by
.Ar geom .
The partition begins on the logical block address given by the
.Fl b Ar start
option.
Its size is given by the
.Fl s Ar size
option.
SI unit suffixes are allowed.
One or both
.Fl b
and
.Fl s
options can be omitted.
If so they are automatically calculated.
The type of the partition is given by the
.Fl t Ar type
option.
Partition types are discussed below in the section entitled
.Sx "PARTITION TYPES" .
.Pp
Additional options include:
.Bl -tag -width 12n
.It Fl a Ar alignment
If specified, then
.Nm
utility tries to align
.Ar start
offset and partition
.Ar size
to be multiple of
.Ar alignment
value.
.It Fl i Ar index
The index in the partition table at which the new partition is to be
placed.
The index determines the name of the device special file used
to represent the partition.
.It Fl l Ar label
The label attached to the partition.
This option is only valid when used on partitioning schemes that support
partition labels.
.It Fl f Ar flags
Additional operational flags.
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.\" ==== BACKUP ====
.It Cm backup
Dump a partition table to standard output in a special format used by the
.Cm restore
action.
.\" ==== BOOTCODE ====
.It Cm bootcode
Embed bootstrap code into the partitioning scheme's metadata on the
.Ar geom
(using
.Fl b Ar bootcode )
or write bootstrap code into a partition (using
.Fl p Ar partcode
and
.Fl i Ar index ) .
Not all partitioning schemes have embedded bootstrap code, so the
.Fl b Ar bootcode
option is scheme-specific in nature (see the section entitled
.Sx BOOTSTRAPPING
below).
The
.Fl b Ar bootcode
option specifies a file that contains the bootstrap code.
The contents and size of the file are determined by the partitioning
scheme.
The
.Fl p Ar partcode
option specifies a file that contains the bootstrap code intended to be
written to a partition.
The partition is specified by the
.Fl i Ar index
option.
The size of the file must be smaller than the size of the partition.
.Pp
Additional options include:
.Bl -tag -width 10n
.It Fl f Ar flags
Additional operational flags.
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.\" ==== COMMIT ====
.It Cm commit
Commit any pending changes for geom
.Ar geom .
All actions are committed by default and will not result in
pending changes.
Actions can be modified with the
.Fl f Ar flags
option so that they are not committed, but become pending.
Pending changes are reflected by the geom and the
.Nm
utility, but they are not actually written to disk.
The
.Cm commit
action will write all pending changes to disk.
.\" ==== CREATE ====
.It Cm create
Create a new partitioning scheme on a provider given by
.Ar provider .
The
.Fl s Ar scheme
option determines the scheme to use.
The kernel must have support for a particular scheme before
that scheme can be used to partition a disk.
.Pp
Additional options include:
.Bl -tag -width 10n
.It Fl n Ar entries
The number of entries in the partition table.
Every partitioning scheme has a minimum and maximum number of entries.
This option allows tables to be created with a number of entries
that is within the limits.
Some schemes have a maximum equal to the minimum and some schemes have
a maximum large enough to be considered unlimited.
By default, partition tables are created with the minimum number of
entries.
.It Fl f Ar flags
Additional operational flags.
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.\" ==== DELETE ====
.It Cm delete
Delete a partition from geom
.Ar geom
and further identified by the
.Fl i Ar index
option.
The partition cannot be actively used by the kernel.
.Pp
Additional options include:
.Bl -tag -width 10n
.It Fl f Ar flags
Additional operational flags.
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.\" ==== DESTROY ====
.It Cm destroy
Destroy the partitioning scheme as implemented by geom
.Ar geom .
.Pp
Additional options include:
.Bl -tag -width 10n
.It Fl F
Forced destroying of the partition table even if it is not empty.
.It Fl f Ar flags
Additional operational flags.
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.\" ==== MODIFY ====
.It Cm modify
Modify a partition from geom
.Ar geom
and further identified by the
.Fl i Ar index
option.
Only the type and/or label of the partition can be modified.
To change the type of a partition, specify the new type with the
.Fl t Ar type
option.
To change the label of a partition, specify the new label with the
.Fl l Ar label
option.
Not all partitioning schemes support labels and it is invalid to
try to change a partition label in such cases.
.Pp
Additional options include:
.Bl -tag -width 10n
.It Fl f Ar flags
Additional operational flags.
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.\" ==== RECOVER ====
.It Cm recover
Recover a corrupt partition's scheme metadata on the geom
.Ar geom .
See the section entitled
.Sx RECOVERING
below for the additional information.
.Pp
Additional options include:
.Bl -tag -width 10n
.It Fl f Ar flags
Additional operational flags.
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.\" ==== RESIZE ====
.It Cm resize
Resize a partition from geom
.Ar geom
and further identified by the
.Fl i Ar index
option.
New partition size is expressed in logical block
numbers and can be given by the
.Fl s Ar size
option.
If
.Fl s
option is omitted then new size is automatically calculated
to maximum available from given geom
.Ar geom .
.Pp
Additional options include:
.Bl -tag -width 12n
.It Fl a Ar alignment
If specified, then
.Nm
utility tries to align partition
.Ar size
to be multiple of
.Ar alignment
value.
.It Fl f Ar flags
Additional operational flags.
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.\" ==== RESTORE ====
.It Cm restore
Restore the partition table from a backup previously created by the
.Cm backup
action and read from standard input.
Only the partition table is restored.
This action does not affect the content of partitions.
After restoring the partition table and writing bootcode if needed,
user data must be restored from backup.
.Pp
Additional options include:
.Bl -tag -width 10n
.It Fl F
Destroy partition table on the given
.Ar provider
before doing restore.
.It Fl l
Restore partition labels for partitioning schemes that support them.
.It Fl f Ar flags
Additional operational flags.
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.\" ==== SET ====
.It Cm set
Set the named attribute on the partition entry.
See the section entitled
.Sx ATTRIBUTES
below for a list of available attributes.
.Pp
Additional options include:
.Bl -tag -width 10n
.It Fl f Ar flags
Additional operational flags.
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.\" ==== SHOW ====
.It Cm show
Show the current partition information of the specified geoms
or all geoms if none are specified.
Additional options include:
.Bl -tag -width 10n
.It Fl l
For partitioning schemes that support partition labels, print them
instead of partition type.
.It Fl p
Show provider names instead of partition indexes.
.It Fl r
Show raw partition type instead of symbolic name.
.El
.\" ==== UNDO ====
.It Cm undo
Revert any pending changes for geom
.Ar geom .
This action is the opposite of the
.Cm commit
action and can be used to undo any changes that have not been committed.
.\" ==== UNSET ====
.It Cm unset
Clear the named attribute on the partition entry.
See the section entitled
.Sx ATTRIBUTES
below for a list of available attributes.
.Pp
Additional options include:
.Bl -tag -width 10n
.It Fl f Ar flags
Additional operational flags.
See the section entitled
.Sx "OPERATIONAL FLAGS"
below for a discussion
about its use.
.El
.El
.Sh PARTITIONING SCHEMES
Several partitioning schemes are supported by the
.Nm
utility:
.Bl -tag -width ".Cm VTOC8"
.It Cm APM
Apple Partition Map, used by PowerPC(R) Macintosh(R) computers.
Requires the
.Cd GEOM_PART_APM
kernel option.
.It Cm BSD
Traditional BSD disklabel, usually used to subdivide MBR partitions.
.Po
This scheme can also be used as the sole partitioning method, without
an MBR.
Partition editing tools from other operating systems often do not
understand the bare disklabel partition layout, so this is sometimes
called
.Dq dangerously dedicated .
.Pc
Requires the
.Cm GEOM_PART_BSD
kernel option.
.It Cm LDM
The Logical Disk Manager is an implementation of volume manager for
Microsoft Windows NT.
Requires the
.Cd GEOM_PART_LDM
kernel option.
.It Cm GPT
GUID Partition Table is used on Intel-based Macintosh computers and
gradually replacing MBR on most PCs and other systems.
Requires the
.Cm GEOM_PART_GPT
kernel option.
.It Cm MBR
Master Boot Record is used on PCs and removable media.
Requires the
.Cm GEOM_PART_MBR
kernel option.
The
.Cm GEOM_PART_EBR
option adds support for the Extended Boot Record (EBR),
which is used to define a logical partition.
The
.Cm GEOM_PART_EBR_COMPAT
option enables backward compatibility for partition names
in the EBR scheme.
It also prevents any type of actions on such partitions.
.It Cm PC98
An MBR variant for NEC PC-98 and compatible computers.
Requires the
.Cm GEOM_PART_PC98
kernel option.
.It Cm VTOC8
Sun's SMI Volume Table Of Contents, used by
.Tn SPARC64
and
.Tn UltraSPARC
computers.
Requires the
.Cm GEOM_PART_VTOC8
kernel option.
.El
.Sh PARTITION TYPES
Partition types are identified on disk by particular strings or magic
values.
The
.Nm
utility uses symbolic names for common partition types so the user
does not need to know these values or other details of the partitioning
scheme in question.
The
.Nm
utility also allows the user to specify scheme-specific partition types
for partition types that do not have symbolic names.
Symbolic names currently understood are:
.Bl -tag -width ".Cm ms-ldm-metadata"
.It Cm bios-boot
The system partition dedicated to second stage of the boot loader program.
Usually it is used by the GRUB 2 loader for GPT partitioning schemes.
The scheme-specific type is
.Qq Li "!21686148-6449-6E6F-744E-656564454649" .
.It Cm efi
The system partition for computers that use the Extensible Firmware
Interface (EFI).
In such cases, the GPT partitioning scheme is used and the
actual partition type for the system partition can also be specified as
.Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93ab" .
.It Cm freebsd
A
.Fx
partition subdivided into filesystems with a
.Bx
disklabel.
This is a legacy partition type and should not be used for the APM
or GPT schemes.
The scheme-specific types are
.Qq Li "!165"
for MBR,
.Qq Li "!FreeBSD"
for APM, and
.Qq Li "!516e7cb4-6ecf-11d6-8ff8-00022d09712b"
for GPT.
.It Cm freebsd-boot
A
.Fx
partition dedicated to bootstrap code.
The scheme-specific type is
.Qq Li "!83bd6b9d-7f41-11dc-be0b-001560b84f0f"
for GPT.
.It Cm freebsd-swap
A
.Fx
partition dedicated to swap space.
The scheme-specific types are
.Qq Li "!FreeBSD-swap"
for APM,
.Qq Li "!516e7cb5-6ecf-11d6-8ff8-00022d09712b"
for GPT, and tag 0x0901 for VTOC8.
.It Cm freebsd-ufs
A
.Fx
partition that contains a UFS or UFS2 filesystem.
The scheme-specific types are
.Qq Li "!FreeBSD-UFS"
for APM,
.Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b"
for GPT, and tag 0x0902 for VTOC8.
.It Cm freebsd-vinum
A
.Fx
partition that contains a Vinum volume.
The scheme-specific types are
.Qq Li "!FreeBSD-Vinum"
for APM,
.Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b"
for GPT, and tag 0x0903 for VTOC8.
.It Cm freebsd-zfs
A
.Fx
partition that contains a ZFS volume.
The scheme-specific types are
.Qq Li "!FreeBSD-ZFS"
for APM,
.Qq Li "!516e7cba-6ecf-11d6-8ff8-00022d09712b"
for GPT, and 0x0904 for VTOC8.
.It Cm mbr
A partition that is sub-partitioned by a Master Boot Record (MBR).
This type is known as
.Qq Li "!024dee41-33e7-11d3-9d69-0008c781f39f"
by GPT.
.It Cm ms-ldm-data
A partition that contains Logical Disk Manager (LDM) volumes.
The scheme-specific types are
.Qq Li "!66"
for MBR,
.Qq Li "!af9b60a0-1431-4f62-bc68-3311714a69ad"
for GPT.
.It Cm ms-ldm-metadata
A partition that contains Logical Disk Manager (LDM) database.
The scheme-specific type is
.Qq Li "!5808c8aa-7e8f-42e0-85d2-e1e90434cfb3"
for GPT.
.El
.Sh ATTRIBUTES
The scheme-specific attributes for EBR:
.Bl -tag -width ".Cm active"
.It Cm active
.El
.Pp
The scheme-specific attributes for GPT:
.Bl -tag -width ".Cm bootfailed"
.It Cm bootme
When set, the
.Nm gptboot
stage 1 boot loader will try to boot the system from this partition.
Multiple partitions might be marked with the
.Cm bootme
attribute.
In such scenario the
.Nm gptboot
will try all
.Cm bootme
partitions one by one, until the next boot stage is successfully entered.
.It Cm bootonce
Setting this attribute automatically sets the
.Cm bootme
attribute.
When set, the
.Nm gptboot
stage 1 boot loader will try to boot the system from this partition only once.
Partitions with both
.Cm bootonce
and
.Cm bootme
attributes are tried before partitions with only the
.Cm bootme
attribute.
Before
.Cm bootonce
partition is tried, the
.Nm gptboot
removes the
.Cm bootme
attribute and tries to execute the next boot stage.
If it fails, the
.Cm bootonce
attribute that is now alone is replaced with the
.Cm bootfailed
attribute.
If the execution of the next boot stage succeeds, but the system is not fully
booted, the
.Nm gptboot
will look for
.Cm bootonce
attributes alone (without the
.Cm bootme
attribute) on the next system boot and will replace those with the
.Cm bootfailed
attribute.
If the system is fully booted, the
.Pa /etc/rc.d/gptboot
start-up script will look for partition with the
.Cm bootonce
attribute alone, will remove the attribute and log that the system was
successfully booted from this partition.
There should be at most one
.Cm bootonce
partition when system is successfully booted.
Multiple partitions might be marked with the
.Cm bootonce
and
.Cm bootme
attribute pairs.
.It Cm bootfailed
This attribute should not be manually managed.
It is managed by the
.Nm gptboot
stage 1 boot loader and the
.Pa /etc/rc.d/gptboot
start-up script.
This attribute is used to mark partitions that had the
.Cm bootonce
attribute set, but we failed to boot from them.
Once we successfully boot, the
.Pa /etc/rc.d/gptboot
script will log all the partitions we failed to boot from and will remove the
.Cm bootfailed
attributes.
.El
.Pp
The scheme-specific attributes for MBR:
.Bl -tag -width ".Cm active"
.It Cm active
.El
.Pp
The scheme-specific attributes for PC98:
.Bl -tag -width ".Cm bootable"
.It Cm active
.It Cm bootable
.El
.Sh BOOTSTRAPPING
.Fx
supports several partitioning schemes and each scheme uses different
bootstrap code.
The bootstrap code is located in a specific disk area for each partitioning
scheme, and may vary in size for different schemes.
.Pp
Bootstrap code can be separated into two types.
The first type is embedded in the partitioning scheme's metadata, while the
second type is located on a specific partition.
Embedding bootstrap code should only be done with the
.Cm gpart bootcode
command with the
.Fl b Ar bootcode
option.
The GEOM PART class knows how to safely embed bootstrap code into
specific partitioning scheme metadata without causing any damage.
.Pp
The Master Boot Record (MBR) uses a 512-byte bootstrap code image, embedded
into the partition table's metadata area.
There are two variants of this bootstrap code:
.Pa /boot/mbr
and
.Pa /boot/boot0 .
.Pa /boot/mbr
searches for a partition with the
.Cm active
attribute (see the
.Sx ATTRIBUTES
section) in the partition table.
Then it runs next bootstrap stage.
The
.Pa /boot/boot0
image contains a boot manager with some additional interactive functions
for multi-booting from a user-selected partition.
.Pp
A BSD disklabel is usually created inside an MBR partition (slice)
with type
.Cm freebsd
(see the
.Sx "PARTITION TYPES"
section).
It uses 8 KB size bootstrap code image
.Pa /boot/boot ,
embedded into the partition table's metadata area.
.Pp
Both types of bootstrap code are used to boot from the GUID Partition Table.
First, a protective MBR is embedded into the first disk sector from the
.Pa /boot/pmbr
image.
It searches the GPT
.Cm freebsd-boot
partition (see the
.Sx "PARTITION TYPES"
section) in the GPT and runs the next bootstrap stage from it.
The
.Cm freebsd-boot
partition should be smaller than 545 KB.
There are two variants of bootstrap code to write to this partition:
.Pa /boot/gptboot
and
.Pa /boot/gptzfsboot .
.Pa /boot/gptboot
is used to boot from UFS.
It searches
.Cm freebsd-ufs
GPT partitions and starts
.Pa /boot/loader
.Pq the third bootstrap stage
if found.
The
.Pa /boot/gptzfsboot
is used to boot from ZFS.
It searches
.Cm freebsd-zfs
GPT partitions and starts
.Pa /boot/zfsloader
if found.
.Pp
The VTOC8 scheme does not support embedding bootstrap code.
Instead, the 8 KBytes bootstrap code image
.Pa /boot/boot1
should be written with the
.Cm gpart bootcode
command with the
.Fl p Ar bootcode
option to all sufficiently large VTOC8 partitions.
To do this the
.Fl i Ar index
option could be omitted.
.Pp
The APM scheme also does not support embedding bootstrap code.
Instead, the 800 KBytes bootstrap code image
.Pa /boot/boot1.hfs
should be written with the
.Cm gpart bootcode
command to a partition of type
.Cm freebsd-boot ,
which should also be 800 KB in size.
.Sh OPERATIONAL FLAGS
Actions other than the
.Cm commit
and
.Cm undo
actions take an optional
.Fl f Ar flags
option.
This option is used to specify action-specific operational flags.
By default, the
.Nm
utility defines the
.Ql C
flag so that the action is immediately
committed.
The user can specify
.Dq Fl f Cm x
to have the action result in a pending change that can later, with
other pending changes, be committed as a single compound change with
the
.Cm commit
action or reverted with the
.Cm undo
action.
.Sh RECOVERING
The GEOM PART class supports recovering of partition tables only for GPT.
The GPT primary metadata is stored at the beginning of the device.
For redundancy, a secondary
.Pq backup
copy of the metadata is stored at the end of the device.
As a result of having two copies, some corruption of metadata is not
fatal to the working of GPT.
When the kernel detects corrupt metadata, it marks this table as corrupt
and reports the problem.
.Cm destroy
and
.Cm recover
are the only operations allowed on corrupt tables.
.Pp
If the first sector of a provider is corrupt, the kernel can not detect GPT
even if the partition table itself is not corrupt.
The protective MBR can be rewritten using the
.Xr dd 1
command, to restore the ability to detect the GPT.
The copy of the protective MBR is usually located in the
.Pa /boot/pmbr
file.
.Pp
If one GPT header appears to be corrupt but the other copy remains intact,
the kernel will log the following:
.Bd -literal -offset indent
GEOM: provider: the primary GPT table is corrupt or invalid.
GEOM: provider: using the secondary instead -- recovery strongly advised.
.Ed
.Pp
or
.Bd -literal -offset indent
GEOM: provider: the secondary GPT table is corrupt or invalid.
GEOM: provider: using the primary only -- recovery suggested.
.Ed
.Pp
Also
.Nm
commands such as
.Cm show , status
and
.Cm list
will report about corrupt tables.
.Pp
If the size of the device has changed (e.g.\& volume expansion) the
secondary GPT header will no longer be located in the last sector.
This is not a metadata corruption, but it is dangerous because any
corruption of the primary GPT will lead to loss of the partition table.
This problem is reported by the kernel with the message:
.Bd -literal -offset indent
GEOM: provider: the secondary GPT header is not in the last LBA.
.Ed
.Pp
This situation can be recovered with the
.Cm recover
command.
This command reconstructs the corrupt metadata using known valid
metadata and relocates the secondary GPT to the end of the device.
.Pp
.Em NOTE :
The GEOM PART class can detect the same partition table visible through
different GEOM providers, and some of them will be marked as corrupt.
Be careful when choosing a provider for recovery.
If you choose incorrectly you can destroy the metadata of another GEOM class,
e.g.\& GEOM MIRROR or GEOM LABEL.
.Sh SYSCTL VARIABLES
The following
.Xr sysctl 8
variables can be used to control the behavior of the
.Nm PART
GEOM class.
The default value is shown next to each variable.
.Bl -tag -width indent
.It Va kern.geom.part.check_integrity : No 1
This variable controls the behaviour of metadata integrity checks.
When integrity checks are enabled, the
.Nm PART
GEOM class verifies all generic partition parameters obtained from the
disk metadata.
If some inconsistency is detected, the partition table will be
rejected with a diagnostic message:
.Sy "GEOM_PART: Integrity check failed (provider, scheme)" .
.It Va kern.geom.part.ldm.debug : No 0
Debug level of the Logical Disk Manager (LDM) module.
This can be set to a number between 0 and 2 inclusive.
If set to 0 minimal debug information is printed,
and if set to 2 the maximum amount of debug information is printed.
.It Va kern.geom.part.ldm.show_mirrors : No 0
This variable controls how the Logical Disk Manager (LDM) module handles
mirrored volumes.
By default mirrored volumes are shown as partitions with type
.Cm ms-ldm-data
(see the
.Sx "PARTITION TYPES"
section).
If this variable set to 1 each component of the mirrored volume will be
present as independent partition.
.Em NOTE :
This may break a mirrored volume and lead to data damage.
.El
.Sh EXIT STATUS
Exit status is 0 on success, and 1 if the command fails.
.Sh EXAMPLES
Create a GPT scheme on
.Pa ad0 :
.Bd -literal -offset indent
/sbin/gpart create -s GPT ad0
.Ed
.Pp
Embed GPT bootstrap code into a protective MBR:
.Bd -literal -offset indent
/sbin/gpart bootcode -b /boot/pmbr ad0
.Ed
.Pp
Create a dedicated
.Cm freebsd-boot
partition that can boot
.Fx
from a
.Cm freebsd-ufs
partition, and install bootstrap code into it.
This partition must be larger than the bootstrap code
.Po
usually either
.Pa /boot/gptboot
or
.Pa /boot/gptzfsboot
.Pc ,
but smaller than 545 kB since the first-stage loader will load the
entire partition into memory during boot, regardless of how much data
it actually contains.
This example uses 88 blocks (44 kB) so the next partition will be
aligned on a 64 kB boundary without the need to specify an explicit
offset or alignment.
The boot partition itself is aligned on a 4 kB boundary.
.Bd -literal -offset indent
/sbin/gpart add -b 40 -s 88 -t freebsd-boot ad0
/sbin/gpart bootcode -p /boot/gptboot -i 1 ad0
.Ed
.Pp
Create a 512MB-sized
.Cm freebsd-ufs
partition to contain a UFS filesystem from which the system can boot.
.Bd -literal -offset indent
/sbin/gpart add -s 512M -t freebsd-ufs ad0
.Ed
.Pp
Create an MBR scheme on
.Pa ada0 ,
then create a 30GB-sized
.Fx
slice, mark it active and
install the
.Nm boot0
boot manager:
.Bd -literal -offset indent
/sbin/gpart create -s MBR ada0
/sbin/gpart add -t freebsd -s 30G ada0
/sbin/gpart set -a active -i 1 ada0
/sbin/gpart bootcode -b /boot/boot0 ada0
.Ed
.Pp
Now create a
.Bx
scheme
.Pf ( Bx
label) with space for up to 20 partitions:
.Bd -literal -offset indent
/sbin/gpart create -s BSD -n 20 ada0s1
.Ed
.Pp
Create a 1GB-sized UFS partition and a 4GB-sized swap partition:
.Bd -literal -offset indent
/sbin/gpart add -t freebsd-ufs -s 1G ada0s1
/sbin/gpart add -t freebsd-swap -s 4G ada0s1
.Ed
.Pp
Install bootstrap code for the
.Bx
label:
.Bd -literal -offset indent
/sbin/gpart bootcode -b /boot/boot ada0s1
.Ed
.Pp
Create a VTOC8 scheme on
.Pa da0 :
.Bd -literal -offset indent
/sbin/gpart create -s VTOC8 da0
.Ed
.Pp
Create a 512MB-sized
.Cm freebsd-ufs
partition to contain a UFS filesystem from which the system can boot.
.Bd -literal -offset indent
/sbin/gpart add -s 512M -t freebsd-ufs da0
.Ed
.Pp
Create a 15GB-sized
.Cm freebsd-ufs
partition to contain a UFS filesystem and aligned on 4KB boundaries:
.Bd -literal -offset indent
/sbin/gpart add -s 15G -t freebsd-ufs -a 4k da0
.Ed
.Pp
After creating all required partitions, embed bootstrap code into them:
.Bd -literal -offset indent
/sbin/gpart bootcode -p /boot/boot1 da0
.Ed
.Pp
Create a backup of the partition table from
.Pa da0 :
.Bd -literal -offset indent
/sbin/gpart backup da0 > da0.backup
.Ed
.Pp
Restore the partition table from the backup to
.Pa da0 :
.Bd -literal -offset indent
/sbin/gpart restore -l da0 < /mnt/da0.backup
.Ed
.Pp
Clone the partition table from
.Pa ada0
to
.Pa ada1
and
.Pa ada2 :
.Bd -literal -offset indent
/sbin/gpart backup ada0 | /sbin/gpart restore -F ada1 ada2
.Ed
.Sh SEE ALSO
.Xr dd 1 ,
.Xr geom 4 ,
.Xr boot0cfg 8 ,
.Xr geom 8
.Sh HISTORY
The
.Nm
utility appeared in
.Fx 7.0 .
.Sh AUTHORS
.An Marcel Moolenaar Aq marcel@FreeBSD.org