1 .\" Copyright (c) 2007, 2008 Marcel Moolenaar
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
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
32 .Nd "control utility for the disk partitioning GEOM class"
49 .\" ==== BOOTCODE ====
53 .Op Fl p Ar partcode Fl i Ar index
100 .\" ==== RESTORE ====
143 utility is used to partition GEOM providers, normally disks.
144 The first argument is the action to be taken:
145 .Bl -tag -width ".Cm bootcode"
148 Add a new partition to the partitioning scheme given by
150 The partition type must be specified with
152 The partition's location, size, and other attributes will be calculated
153 automatically if the corresponding options are not specified.
157 command accepts these options:
159 .It Fl a Ar alignment
162 utility tries to align
170 The logical block address where the partition will begin.
171 A SI unit suffix is allowed.
173 Additional operational flags.
174 See the section entitled
175 .Sx "OPERATIONAL FLAGS"
176 below for a discussion
179 The index in the partition table at which the new partition is to be
181 The index determines the name of the device special file used
182 to represent the partition.
184 The label attached to the partition.
185 This option is only valid when used on partitioning schemes that support
188 Create a partition of size
190 A SI unit suffix is allowed.
192 Create a partition of type
194 Partition types are discussed below in the section entitled
195 .Sx "PARTITION TYPES" .
199 Dump a partition table to standard output in a special format used by the
202 .\" ==== BOOTCODE ====
204 Embed bootstrap code into the partitioning scheme's metadata on the
208 or write bootstrap code into a partition (using
215 command accepts these options:
218 Embed bootstrap code from the file
220 into the partitioning scheme's metadata for
222 Not all partitioning schemes have embedded bootstrap code, so the
224 option is scheme-specific in nature (see the section entitled
229 file must match the partitioning scheme's requirements for file content
232 Additional operational flags.
233 See the section entitled
234 .Sx "OPERATIONAL FLAGS"
235 below for a discussion
238 Specify the target partition for
241 Write the bootstrap code from the file
245 partition specified by
247 The size of the file must be smaller than the size of the partition.
251 Commit any pending changes for geom
253 All actions are committed by default and will not result in
255 Actions can be modified with the
257 option so that they are not committed, but become pending.
258 Pending changes are reflected by the geom and the
260 utility, but they are not actually written to disk.
263 action will write all pending changes to disk.
266 Create a new partitioning scheme on a provider given by
268 The scheme to use must be specified with the
274 command accepts these options:
277 Additional operational flags.
278 See the section entitled
279 .Sx "OPERATIONAL FLAGS"
280 below for a discussion
283 The number of entries in the partition table.
284 Every partitioning scheme has a minimum and maximum number of entries.
285 This option allows tables to be created with a number of entries
286 that is within the limits.
287 Some schemes have a maximum equal to the minimum and some schemes have
288 a maximum large enough to be considered unlimited.
289 By default, partition tables are created with the minimum number of
292 Specify the partitioning scheme to use.
293 The kernel must have support for a particular scheme before
294 that scheme can be used to partition a disk.
298 Delete a partition from geom
300 and further identified by the
303 The partition cannot be actively used by the kernel.
307 command accepts these options:
310 Additional operational flags.
311 See the section entitled
312 .Sx "OPERATIONAL FLAGS"
313 below for a discussion
316 Specifies the index of the partition to be deleted.
318 .\" ==== DESTROY ====
320 Destroy the partitioning scheme as implemented by geom
325 command accepts these options:
328 Forced destroying of the partition table even if it is not empty.
330 Additional operational flags.
331 See the section entitled
332 .Sx "OPERATIONAL FLAGS"
333 below for a discussion
338 Modify a partition from geom
340 and further identified by the
343 Only the type and/or label of the partition can be modified.
344 Not all partitioning schemes support labels and it is invalid to
345 try to change a partition label in such cases.
349 command accepts these options:
352 Additional operational flags.
353 See the section entitled
354 .Sx "OPERATIONAL FLAGS"
355 below for a discussion
358 Specifies the index of the partition to be modified.
360 Change the partition label to
363 Change the partition type to
366 .\" ==== RECOVER ====
368 Recover a corrupt partition's scheme metadata on the geom
370 See the section entitled
372 below for the additional information.
376 command accepts these options:
379 Additional operational flags.
380 See the section entitled
381 .Sx "OPERATIONAL FLAGS"
382 below for a discussion
387 Resize a partition from geom
389 and further identified by the
392 If the new size is not specified it is automatically calculated
393 to be the maximum available from
398 command accepts these options:
400 .It Fl a Ar alignment
403 utility tries to align partition
405 to be a multiple of the
409 Additional operational flags.
410 See the section entitled
411 .Sx "OPERATIONAL FLAGS"
412 below for a discussion
415 Specifies the index of the partition to be resized.
417 Specifies the new size of the partition, in logical blocks.
418 A SI unit suffix is allowed.
420 .\" ==== RESTORE ====
422 Restore the partition table from a backup previously created by the
424 action and read from standard input.
425 Only the partition table is restored.
426 This action does not affect the content of partitions.
427 After restoring the partition table and writing bootcode if needed,
428 user data must be restored from backup.
432 command accepts these options:
435 Destroy partition table on the given
437 before doing restore.
439 Additional operational flags.
440 See the section entitled
441 .Sx "OPERATIONAL FLAGS"
442 below for a discussion
445 Restore partition labels for partitioning schemes that support them.
449 Set the named attribute on the partition entry.
450 See the section entitled
452 below for a list of available attributes.
456 command accepts these options:
459 Specifies the attribute to set.
461 Additional operational flags.
462 See the section entitled
463 .Sx "OPERATIONAL FLAGS"
464 below for a discussion
467 Specifies the index of the partition on which the attribute will be set.
471 Show current partition information for the specified geoms, or all
472 geoms if none are specified.
473 The default output includes the logical starting block of each
474 partition, the partition size in blocks, the partition index number,
475 the partition type, and a human readable partition size.
476 Block sizes and locations are based on the device's Sectorsize
482 command accepts these options:
485 For partitioning schemes that support partition labels, print them
486 instead of partition type.
488 Show provider names instead of partition indexes.
490 Show raw partition type instead of symbolic name.
494 Revert any pending changes for geom
496 This action is the opposite of the
498 action and can be used to undo any changes that have not been committed.
501 Clear the named attribute on the partition entry.
502 See the section entitled
504 below for a list of available attributes.
508 command accepts these options:
511 Specifies the attribute to clear.
513 Additional operational flags.
514 See the section entitled
515 .Sx "OPERATIONAL FLAGS"
516 below for a discussion
519 Specifies the index of the partition on which the attribute will be cleared.
534 .Sh PARTITIONING SCHEMES
535 Several partitioning schemes are supported by the
538 .Bl -tag -width ".Cm VTOC8"
540 Apple Partition Map, used by PowerPC(R) Macintosh(R) computers.
545 Traditional BSD disklabel, usually used to subdivide MBR partitions.
547 This scheme can also be used as the sole partitioning method, without
549 Partition editing tools from other operating systems often do not
550 understand the bare disklabel partition layout, so this is sometimes
552 .Dq dangerously dedicated .
558 64-bit implementation of BSD disklabel used in DragonFlyBSD to subdivide MBR
564 The Logical Disk Manager is an implementation of volume manager for
565 Microsoft Windows NT.
570 GUID Partition Table is used on Intel-based Macintosh computers and
571 gradually replacing MBR on most PCs and other systems.
576 Master Boot Record is used on PCs and removable media.
582 option adds support for the Extended Boot Record (EBR),
583 which is used to define a logical partition.
585 .Cm GEOM_PART_EBR_COMPAT
586 option enables backward compatibility for partition names
588 It also prevents any type of actions on such partitions.
590 Sun's SMI Volume Table Of Contents, used by
600 Partition types are identified on disk by particular strings or magic
604 utility uses symbolic names for common partition types so the user
605 does not need to know these values or other details of the partitioning
609 utility also allows the user to specify scheme-specific partition types
610 for partition types that do not have symbolic names.
611 Symbolic names currently understood and used by
614 .Bl -tag -width ".Cm dragonfly-disklabel64"
616 The system partition dedicated to storing boot loaders on some Apple
618 The scheme-specific types are
621 .Qq Li "!Apple_Bootstrap"
623 .Qq Li "!426f6f74-0000-11aa-aa11-00306543ecac"
626 The system partition dedicated to second stage of the boot loader program.
627 Usually it is used by the GRUB 2 loader for GPT partitioning schemes.
628 The scheme-specific type is
629 .Qq Li "!21686148-6449-6E6F-744E-656564454649" .
631 The system partition for computers that use the Extensible Firmware
633 The scheme-specific types are
636 .Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93b"
641 partition subdivided into filesystems with a
644 This is a legacy partition type and should not be used for the APM
646 The scheme-specific types are
651 .Qq Li "!516e7cb4-6ecf-11d6-8ff8-00022d09712b"
656 partition dedicated to bootstrap code.
657 The scheme-specific type is
658 .Qq Li "!83bd6b9d-7f41-11dc-be0b-001560b84f0f"
663 partition dedicated to swap space.
664 The scheme-specific types are
665 .Qq Li "!FreeBSD-swap"
667 .Qq Li "!516e7cb5-6ecf-11d6-8ff8-00022d09712b"
668 for GPT, and tag 0x0901 for VTOC8.
672 partition that contains a UFS or UFS2 filesystem.
673 The scheme-specific types are
674 .Qq Li "!FreeBSD-UFS"
676 .Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b"
677 for GPT, and tag 0x0902 for VTOC8.
681 partition that contains a Vinum volume.
682 The scheme-specific types are
683 .Qq Li "!FreeBSD-Vinum"
685 .Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b"
686 for GPT, and tag 0x0903 for VTOC8.
690 partition that contains a ZFS volume.
691 The scheme-specific types are
692 .Qq Li "!FreeBSD-ZFS"
694 .Qq Li "!516e7cba-6ecf-11d6-8ff8-00022d09712b"
695 for GPT, and 0x0904 for VTOC8.
698 Another symbolic names that can be used with
701 .Bl -tag -width ".Cm dragonfly-disklabel64"
703 An Apple macOS partition used for the Apple file system, APFS.
704 .It Cm apple-core-storage
705 An Apple Mac OS X partition used by logical volume manager known as
707 The scheme-specific type is
708 .Qq Li "!53746f72-6167-11aa-aa11-00306543ecac"
711 An Apple Mac OS X partition that contains a HFS or HFS+ filesystem.
712 The scheme-specific types are
717 .Qq Li "!48465300-0000-11aa-aa11-00306543ecac"
720 An Apple Mac OS X partition dedicated to partition metadata that descibes
722 The scheme-specific type is
723 .Qq Li "!4c616265-6c00-11aa-aa11-00306543ecac"
726 An Apple Mac OS X partition used in a software RAID configuration.
727 The scheme-specific type is
728 .Qq Li "!52414944-0000-11aa-aa11-00306543ecac"
730 .It Cm apple-raid-offline
731 An Apple Mac OS X partition used in a software RAID configuration.
732 The scheme-specific type is
733 .Qq Li "!52414944-5f4f-11aa-aa11-00306543ecac"
735 .It Cm apple-tv-recovery
736 An Apple Mac OS X partition used by Apple TV.
737 The scheme-specific type is
738 .Qq Li "!5265636f-7665-11aa-aa11-00306543ecac"
741 An Apple Mac OS X partition that contains a UFS filesystem.
742 The scheme-specific types are
745 .Qq Li "!Apple_UNIX_SVR2"
747 .Qq Li "!55465300-0000-11aa-aa11-00306543ecac"
749 .It Cm dragonfly-label32
750 A DragonFlyBSD partition subdivided into filesystems with a
753 The scheme-specific type is
754 .Qq Li "!9d087404-1ca5-11dc-8817-01301bb8a9f5"
756 .It Cm dragonfly-label64
757 A DragonFlyBSD partition subdivided into filesystems with a
759 The scheme-specific type is
760 .Qq Li "!3d48ce54-1d16-11dc-8696-01301bb8a9f5"
762 .It Cm dragonfly-legacy
763 A legacy partition type used in DragonFlyBSD.
764 The scheme-specific type is
765 .Qq Li "!bd215ab2-1d16-11dc-8696-01301bb8a9f5"
768 A DragonFlyBSD partition used with Concatenated Disk driver.
769 The scheme-specific type is
770 .Qq Li "!dbd5211b-1ca5-11dc-8817-01301bb8a9f5"
772 .It Cm dragonfly-hammer
773 A DragonFlyBSD partition that contains a Hammer filesystem.
774 The scheme-specific type is
775 .Qq Li "!61dc63ac-6e38-11dc-8513-01301bb8a9f5"
777 .It Cm dragonfly-hammer2
778 A DragonFlyBSD partition that contains a Hammer2 filesystem.
779 The scheme-specific type is
780 .Qq Li "!5cbb9ad1-862d-11dc-a94d-01301bb8a9f5"
782 .It Cm dragonfly-swap
783 A DragonFlyBSD partition dedicated to swap space.
784 The scheme-specific type is
785 .Qq Li "!9d58fdbd-1ca5-11dc-8817-01301bb8a9f5"
788 A DragonFlyBSD partition that contains an UFS1 filesystem.
789 The scheme-specific type is
790 .Qq Li "!9d94ce7c-1ca5-11dc-8817-01301bb8a9f5"
792 .It Cm dragonfly-vinum
793 A DragonFlyBSD partition used with Logical Volume Manager.
794 The scheme-specific type is
795 .Qq Li "!9dd4478f-1ca5-11dc-8817-01301bb8a9f5"
798 A partition subdivided into filesystems with a EBR.
799 The scheme-specific type is
803 A partition that contains a FAT16 filesystem.
804 The scheme-specific type is
808 A partition that contains a FAT32 filesystem.
809 The scheme-specific type is
813 A partition that contains a FAT32 (LBA) filesystem.
814 The scheme-specific type is
818 A Linux partition that contains some filesystem with data.
819 The scheme-specific types are
822 .Qq Li "!0fc63daf-8483-4772-8e79-3d69d8477de4"
825 A Linux partition dedicated to Logical Volume Manager.
826 The scheme-specific types are
829 .Qq Li "!e6d6d379-f507-44c2-a23c-238f2a3df928"
832 A Linux partition used in a software RAID configuration.
833 The scheme-specific types are
836 .Qq Li "!a19d880f-05fc-4d3b-a006-743f0f84911e"
839 A Linux partition dedicated to swap space.
840 The scheme-specific types are
843 .Qq Li "!0657fd6d-a4ab-43c4-84e5-0933c84b4f4f"
846 A partition that is sub-partitioned by a Master Boot Record (MBR).
847 This type is known as
848 .Qq Li "!024dee41-33e7-11d3-9d69-0008c781f39f"
851 A basic data partition (BDP) for Microsoft operating systems.
852 In the GPT this type is the equivalent to partition types
857 The scheme-specific type is
858 .Qq Li "!ebd0a0a2-b9e5-4433-87c0-68b6b72699c7"
861 A partition that contains Logical Disk Manager (LDM) volumes.
862 The scheme-specific types are
865 .Qq Li "!af9b60a0-1431-4f62-bc68-3311714a69ad"
867 .It Cm ms-ldm-metadata
868 A partition that contains Logical Disk Manager (LDM) database.
869 The scheme-specific type is
870 .Qq Li "!5808c8aa-7e8f-42e0-85d2-e1e90434cfb3"
873 A NetBSD partition used with Concatenated Disk driver.
874 The scheme-specific type is
875 .Qq Li "!2db519c4-b10f-11dc-b99b-0019d1879648"
878 An encrypted NetBSD partition.
879 The scheme-specific type is
880 .Qq Li "!2db519ec-b10f-11dc-b99b-0019d1879648"
883 A NetBSD partition that contains an UFS filesystem.
884 The scheme-specific type is
885 .Qq Li "!49f48d5a-b10e-11dc-b99b-0019d1879648"
888 A NetBSD partition that contains an LFS filesystem.
889 The scheme-specific type is
890 .Qq Li "!49f48d82-b10e-11dc-b99b-0019d1879648"
893 A NetBSD partition used in a software RAID configuration.
894 The scheme-specific type is
895 .Qq Li "!49f48daa-b10e-11dc-b99b-0019d1879648"
898 A NetBSD partition dedicated to swap space.
899 The scheme-specific type is
900 .Qq Li "!49f48d32-b10e-11dc-b99b-0019d1879648"
903 A partition that contains a NTFS or exFAT filesystem.
904 The scheme-specific type is
908 The system partition dedicated to storing boot loaders on some PowerPC systems,
909 notably those made by IBM.
910 The scheme-specific types are
913 .Qq Li "!0x9e1a2d38-c612-4316-aa26-8b49521e5a8b"
916 A partition that contains a VMware File System (VMFS).
917 The scheme-specific types are
920 .Qq Li "!aa31e02a-400f-11db-9590-000c2911d1b8"
922 .It Cm vmware-vmkdiag
923 A partition that contains a VMware diagostic filesystem.
924 The scheme-specific types are
927 .Qq Li "!9d275380-40ad-11db-bf97-000c2911d1b8"
929 .It Cm vmware-reserved
930 A VMware reserved partition.
931 The scheme-specific type is
932 .Qq Li "!9198effc-31c0-11db-8f-78-000c2911d1b8"
934 .It Cm vmware-vsanhdr
935 A partition claimed by VMware VSAN.
936 The scheme-specific type is
937 .Qq Li "!381cfccc-7288-11e0-92ee-000c2911d0b2"
941 The scheme-specific attributes for EBR:
942 .Bl -tag -width ".Cm active"
946 The scheme-specific attributes for GPT:
947 .Bl -tag -width ".Cm bootfailed"
951 stage 1 boot loader will try to boot the system from this partition.
952 Multiple partitions can be marked with the
959 Setting this attribute automatically sets the
964 stage 1 boot loader will try to boot the system from this partition only once.
965 Multiple partitions can be marked with the
974 This attribute should not be manually managed.
977 stage 1 boot loader and the
978 .Pa /etc/rc.d/gptboot
984 Setting this attribute overwrites the Protective MBR with a new one where
985 the 0xee partition is the second, rather than the first record.
986 This resolves a BIOS compatibility issue with some Lenovo models including the
987 X220, T420, and T520, allowing them to boot from GPT partitioned disks
991 The scheme-specific attributes for MBR:
992 .Bl -tag -width ".Cm active"
997 supports several partitioning schemes and each scheme uses different
999 The bootstrap code is located in a specific disk area for each partitioning
1000 scheme, and may vary in size for different schemes.
1002 Bootstrap code can be separated into two types.
1003 The first type is embedded in the partitioning scheme's metadata, while the
1004 second type is located on a specific partition.
1005 Embedding bootstrap code should only be done with the
1010 The GEOM PART class knows how to safely embed bootstrap code into
1011 specific partitioning scheme metadata without causing any damage.
1013 The Master Boot Record (MBR) uses a 512-byte bootstrap code image, embedded
1014 into the partition table's metadata area.
1015 There are two variants of this bootstrap code:
1020 searches for a partition with the
1024 section) in the partition table.
1025 Then it runs next bootstrap stage.
1028 image contains a boot manager with some additional interactive functions
1029 for multi-booting from a user-selected partition.
1031 A BSD disklabel is usually created inside an MBR partition (slice)
1035 .Sx "PARTITION TYPES"
1037 It uses 8 KB size bootstrap code image
1039 embedded into the partition table's metadata area.
1041 Both types of bootstrap code are used to boot from the GUID Partition Table.
1042 First, a protective MBR is embedded into the first disk sector from the
1045 It searches through the GPT for a
1048 .Sx "PARTITION TYPES"
1049 section) and runs the next bootstrap stage from it.
1052 partition should be smaller than 545 KB.
1053 It can be located either before or after other
1055 partitions on the disk.
1056 There are two variants of bootstrap code to write to this partition:
1059 .Pa /boot/gptzfsboot .
1062 is used to boot from UFS partitions.
1066 partitions in the GPT and selects one to boot based on the
1071 If neither attribute is found,
1073 boots from the first
1077 .Pq the third bootstrap stage
1078 is loaded from the first partition that matches these conditions.
1081 for more information.
1083 .Pa /boot/gptzfsboot
1084 is used to boot from ZFS.
1085 It searches through the GPT for
1087 partitions, trying to detect ZFS pools.
1088 After all pools are detected,
1090 is started from the first one found.
1092 The VTOC8 scheme does not support embedding bootstrap code.
1093 Instead, the 8 KBytes bootstrap code image
1095 should be written with the
1099 option to all sufficiently large VTOC8 partitions.
1102 option could be omitted.
1104 The APM scheme also does not support embedding bootstrap code.
1105 Instead, the 800 KBytes bootstrap code image
1107 should be written with the
1109 command to a partition of type
1111 which should also be 800 KB in size.
1112 .Sh OPERATIONAL FLAGS
1113 Actions other than the
1117 actions take an optional
1120 This option is used to specify action-specific operational flags.
1125 flag so that the action is immediately
1127 The user can specify
1129 to have the action result in a pending change that can later, with
1130 other pending changes, be committed as a single compound change with
1133 action or reverted with the
1137 The GEOM PART class supports recovering of partition tables only for GPT.
1138 The GPT primary metadata is stored at the beginning of the device.
1139 For redundancy, a secondary
1141 copy of the metadata is stored at the end of the device.
1142 As a result of having two copies, some corruption of metadata is not
1143 fatal to the working of GPT.
1144 When the kernel detects corrupt metadata, it marks this table as corrupt
1145 and reports the problem.
1149 are the only operations allowed on corrupt tables.
1151 If one GPT header appears to be corrupt but the other copy remains intact,
1152 the kernel will log the following:
1153 .Bd -literal -offset indent
1154 GEOM: provider: the primary GPT table is corrupt or invalid.
1155 GEOM: provider: using the secondary instead -- recovery strongly advised.
1159 .Bd -literal -offset indent
1160 GEOM: provider: the secondary GPT table is corrupt or invalid.
1161 GEOM: provider: using the primary only -- recovery suggested.
1170 will report about corrupt tables.
1172 If the size of the device has changed (e.g.,\& volume expansion) the
1173 secondary GPT header will no longer be located in the last sector.
1174 This is not a metadata corruption, but it is dangerous because any
1175 corruption of the primary GPT will lead to loss of the partition table.
1176 This problem is reported by the kernel with the message:
1177 .Bd -literal -offset indent
1178 GEOM: provider: the secondary GPT header is not in the last LBA.
1181 This situation can be recovered with the
1184 This command reconstructs the corrupt metadata using known valid
1185 metadata and relocates the secondary GPT to the end of the device.
1188 The GEOM PART class can detect the same partition table visible through
1189 different GEOM providers, and some of them will be marked as corrupt.
1190 Be careful when choosing a provider for recovery.
1191 If you choose incorrectly you can destroy the metadata of another GEOM class,
1192 e.g.,\& GEOM MIRROR or GEOM LABEL.
1193 .Sh SYSCTL VARIABLES
1196 variables can be used to control the behavior of the
1199 The default value is shown next to each variable.
1200 .Bl -tag -width indent
1201 .It Va kern.geom.part.auto_resize: No 1
1202 This variable controls automatic resize behavior of
1205 When this variable is enable and new size of provider is detected, the schema
1206 metadata is resized but all changes are not saved to disk, until
1208 is run to confirm changes.
1209 This 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
1214 This variable controls the behaviour of metadata integrity checks.
1215 When integrity checks are enabled, the
1217 GEOM class verifies all generic partition parameters obtained from the
1219 If some inconsistency is detected, the partition table will be
1220 rejected with a diagnostic message:
1221 .Sy "GEOM_PART: Integrity check failed (provider, scheme)" .
1222 .It Va kern.geom.part.ldm.debug : No 0
1223 Debug level of the Logical Disk Manager (LDM) module.
1224 This can be set to a number between 0 and 2 inclusive.
1225 If set to 0 minimal debug information is printed,
1226 and if set to 2 the maximum amount of debug information is printed.
1227 .It Va kern.geom.part.ldm.show_mirrors : No 0
1228 This variable controls how the Logical Disk Manager (LDM) module handles
1230 By default mirrored volumes are shown as partitions with type
1233 .Sx "PARTITION TYPES"
1235 If this variable set to 1 each component of the mirrored volume will be
1236 present as independent partition.
1238 This may break a mirrored volume and lead to data damage.
1239 .It Va kern.geom.part.mbr.enforce_chs : No 0
1240 Specify how the Master Boot Record (MBR) module does alignment.
1241 If this variable is set to a non-zero value, the module will automatically
1242 recalculate the user-specified offset and size for alignment with the CHS
1244 Otherwise the values will be left unchanged.
1247 Exit status is 0 on success, and 1 if the command fails.
1249 The examples below assume that the disk's logical block size is 512
1250 bytes, regardless of its physical block size.
1252 In this example, we will format
1254 with the GPT scheme and create boot, swap and root partitions.
1255 First, we need to create the partition table:
1256 .Bd -literal -offset indent
1257 /sbin/gpart create -s GPT ada0
1260 Next, we install a protective MBR with the first-stage bootstrap code.
1261 The protective MBR lists a single, bootable partition spanning the
1262 entire disk, thus allowing non-GPT-aware BIOSes to boot from the disk
1263 and preventing tools which do not understand the GPT scheme from
1264 considering the disk to be unformatted.
1265 .Bd -literal -offset indent
1266 /sbin/gpart bootcode -b /boot/pmbr ada0
1269 We then create a dedicated
1271 partition to hold the second-stage boot loader, which will load the
1273 kernel and modules from a UFS or ZFS filesystem.
1274 This partition must be larger than the bootstrap code
1279 .Pa /boot/gptzfsboot
1282 but smaller than 545 kB since the first-stage loader will load the
1283 entire partition into memory during boot, regardless of how much data
1284 it actually contains.
1285 We create a 472-block (236 kB) boot partition at offset 40, which is
1286 the size of the partition table (34 blocks or 17 kB) rounded up to the
1287 nearest 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
1293 We now create a 4 GB swap partition at the first available offset,
1294 which is 40 + 472 = 512 blocks (256 kB).
1295 .Bd -literal -offset indent
1296 /sbin/gpart add -s 4G -t freebsd-swap ada0
1299 Aligning the swap partition and all subsequent partitions on a 256 kB
1300 boundary ensures optimal performance on a wide range of media, from
1301 plain old disks with 512-byte blocks, through modern
1303 disks with 4096-byte physical blocks, to RAID volumes with stripe
1304 sizes of up to 256 kB.
1306 Finally, we create and format an 8 GB
1308 partition for the root filesystem, leaving the rest of the slice free
1309 for additional filesystems:
1310 .Bd -literal -offset indent
1311 /sbin/gpart add -s 8G -t freebsd-ufs ada0
1312 /sbin/newfs -Uj /dev/ada0p3
1315 In this example, we will format
1317 with the MBR scheme and create a single partition which we subdivide
1322 First, we create the partition table and a single 64 GB partition,
1323 then we mark that partition active (bootable) and install the
1324 first-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
1332 Next, we create a disklabel in that partition
1335 in disklabel terminology
1337 with room for up to 20 partitions:
1338 .Bd -literal -offset indent
1339 /sbin/gpart create -s BSD -n 20 ada0s1
1342 We 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
1348 Finally, we install the appropriate boot loader for the
1351 .Bd -literal -offset indent
1352 /sbin/gpart bootcode -b /boot/boot ada0s1
1356 Create a VTOC8 scheme on
1358 .Bd -literal -offset indent
1359 /sbin/gpart create -s VTOC8 da0
1362 Create a 512MB-sized
1364 partition 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
1371 partition 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
1376 After creating all required partitions, embed bootstrap code into them:
1377 .Bd -literal -offset indent
1378 /sbin/gpart bootcode -p /boot/boot1 da0
1380 .Ss Deleting Partitions and Destroying the Partitioning Scheme
1383 error is shown when trying to destroy a partition table, remember that
1384 all of the partitions must be deleted first with the
1389 has 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
1397 Rather than deleting each partition and then destroying the partitioning
1400 option can be given with
1402 to delete all of the partitions before destroying the partitioning scheme.
1403 This is equivalent to the previous example:
1404 .Bd -literal -offset indent
1405 /sbin/gpart destroy -F da0
1407 .Ss Backup and Restore
1409 Create a backup of the partition table from
1411 .Bd -literal -offset indent
1412 /sbin/gpart backup da0 > da0.backup
1415 Restore the partition table from the backup to
1417 .Bd -literal -offset indent
1418 /sbin/gpart restore -l da0 < /mnt/da0.backup
1421 Clone the partition table from
1427 .Bd -literal -offset indent
1428 /sbin/gpart backup ada0 | /sbin/gpart restore -F ada1 ada2
1441 .An Marcel Moolenaar Aq Mt marcel@FreeBSD.org