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