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 ====
54 .Op Fl p Ar partcode Fl i Ar index
101 .\" ==== RESTORE ====
144 utility is used to partition GEOM providers, normally disks.
145 The first argument is the action to be taken:
146 .Bl -tag -width ".Cm bootcode"
149 Add a new partition to the partitioning scheme given by
151 The partition type must be specified with
153 The partition's location, size, and other attributes will be calculated
154 automatically if the corresponding options are not specified.
158 command accepts these options:
160 .It Fl a Ar alignment
161 If specified, then the
163 utility tries to align
171 The logical block address where the partition will begin.
172 An SI unit suffix is allowed.
174 Additional operational flags.
175 See the section entitled
176 .Sx "OPERATIONAL FLAGS"
177 below for a discussion
180 The index in the partition table at which the new partition is to be
182 The index determines the name of the device special file used
183 to represent the partition.
185 The label attached to the partition.
186 This option is only valid when used on partitioning schemes that support
189 Create a partition of size
191 An SI unit suffix is allowed.
193 Create a partition of type
195 Partition types are discussed below in the section entitled
196 .Sx "PARTITION TYPES" .
200 Dump a partition table to standard output in a special format used by the
203 .\" ==== BOOTCODE ====
205 Embed bootstrap code into the partitioning scheme's metadata on the
209 or write bootstrap code into a partition (using
216 command accepts these options:
219 Do not preserve the Volume Serial Number for MBR.
220 MBR bootcode contains Volume Serial Number by default, and
222 tries to preserve it when installing new bootstrap code.
223 This option skips preservation to help with some versions of
225 that do not support Volume Serial Number.
227 Embed bootstrap code from the file
229 into the partitioning scheme's metadata for
231 Not all partitioning schemes have embedded bootstrap code, so the
233 option is scheme-specific in nature (see the section entitled
238 file must match the partitioning scheme's requirements for file content
241 Additional operational flags.
242 See the section entitled
243 .Sx "OPERATIONAL FLAGS"
244 below for a discussion
247 Specify the target partition for
250 Write the bootstrap code from the file
254 partition specified by
256 The size of the file must be smaller than the size of the partition.
260 Commit any pending changes for geom
262 All actions are committed by default and will not result in
264 Actions can be modified with the
266 option so that they are not committed, but become pending.
267 Pending changes are reflected by the geom and the
269 utility, but they are not actually written to disk.
272 action will write all pending changes to disk.
275 Create a new partitioning scheme on a provider given by
277 The scheme to use must be specified with the
283 command accepts these options:
286 Additional operational flags.
287 See the section entitled
288 .Sx "OPERATIONAL FLAGS"
289 below for a discussion
292 The number of entries in the partition table.
293 Every partitioning scheme has a minimum and maximum number of entries.
294 This option allows tables to be created with a number of entries
295 that is within the limits.
296 Some schemes have a maximum equal to the minimum and some schemes have
297 a maximum large enough to be considered unlimited.
298 By default, partition tables are created with the minimum number of
301 Specify the partitioning scheme to use.
302 The kernel must have support for a particular scheme before
303 that scheme can be used to partition a disk.
307 Delete a partition from geom
309 and further identified by the
312 The partition cannot be actively used by the kernel.
316 command accepts these options:
319 Additional operational flags.
320 See the section entitled
321 .Sx "OPERATIONAL FLAGS"
322 below for a discussion
325 Specifies the index of the partition to be deleted.
327 .\" ==== DESTROY ====
329 Destroy the partitioning scheme as implemented by geom
334 command accepts these options:
337 Forced destroying of the partition table even if it is not empty.
339 Additional operational flags.
340 See the section entitled
341 .Sx "OPERATIONAL FLAGS"
342 below for a discussion
347 Modify a partition from geom
349 and further identified by the
352 Only the type and/or label of the partition can be modified.
353 Not all partitioning schemes support labels and it is invalid to
354 try to change a partition label in such cases.
358 command accepts these options:
361 Additional operational flags.
362 See the section entitled
363 .Sx "OPERATIONAL FLAGS"
364 below for a discussion
367 Specifies the index of the partition to be modified.
369 Change the partition label to
372 Change the partition type to
375 .\" ==== RECOVER ====
377 Recover a corrupt partition's scheme metadata on the geom
379 See the section entitled
381 below for the additional information.
385 command accepts these options:
388 Additional operational flags.
389 See the section entitled
390 .Sx "OPERATIONAL FLAGS"
391 below for a discussion
396 Resize a partition from geom
398 and further identified by the
401 If the new size is not specified it is automatically calculated
402 to be the maximum available from
407 command accepts these options:
409 .It Fl a Ar alignment
410 If specified, then the
412 utility tries to align partition
414 to be a multiple of the
418 Additional operational flags.
419 See the section entitled
420 .Sx "OPERATIONAL FLAGS"
421 below for a discussion
424 Specifies the index of the partition to be resized.
426 Specifies the new size of the partition, in logical blocks.
427 An SI unit suffix is allowed.
429 .\" ==== RESTORE ====
431 Restore the partition table from a backup previously created by the
433 action and read from standard input.
434 Only the partition table is restored.
435 This action does not affect the content of partitions.
436 After restoring the partition table and writing bootcode if needed,
437 user data must be restored from backup.
441 command accepts these options:
444 Destroy partition table on the given
446 before doing restore.
448 Additional operational flags.
449 See the section entitled
450 .Sx "OPERATIONAL FLAGS"
451 below for a discussion
454 Restore partition labels for partitioning schemes that support them.
458 Set the named attribute on the partition entry.
459 See the section entitled
461 below for a list of available attributes.
465 command accepts these options:
468 Specifies the attribute to set.
470 Additional operational flags.
471 See the section entitled
472 .Sx "OPERATIONAL FLAGS"
473 below for a discussion
476 Specifies the index of the partition on which the attribute will be set.
480 Show current partition information for the specified geoms, or all
481 geoms if none are specified.
482 The default output includes the logical starting block of each
483 partition, the partition size in blocks, the partition index number,
484 the partition type, and a human readable partition size.
485 Block sizes and locations are based on the device's Sectorsize
491 command accepts these options:
494 For partitioning schemes that support partition labels, print them
495 instead of partition type.
497 Show provider names instead of partition indexes.
499 Show raw partition type instead of symbolic name.
503 Revert any pending changes for geom
505 This action is the opposite of the
507 action and can be used to undo any changes that have not been committed.
510 Clear the named attribute on the partition entry.
511 See the section entitled
513 below for a list of available attributes.
517 command accepts these options:
520 Specifies the attribute to clear.
522 Additional operational flags.
523 See the section entitled
524 .Sx "OPERATIONAL FLAGS"
525 below for a discussion
528 Specifies the index of the partition on which the attribute will be cleared.
543 .Sh PARTITIONING SCHEMES
544 Several partitioning schemes are supported by the
547 .Bl -tag -width ".Cm VTOC8"
549 Apple Partition Map, used by PowerPC(R) Macintosh(R) computers.
554 Traditional BSD disklabel, usually used to subdivide MBR partitions.
556 This scheme can also be used as the sole partitioning method, without
558 Partition editing tools from other operating systems often do not
559 understand the bare disklabel partition layout, so this is sometimes
561 .Dq dangerously dedicated .
567 64-bit implementation of BSD disklabel used in DragonFlyBSD to subdivide MBR
573 The Logical Disk Manager is an implementation of volume manager for
574 Microsoft Windows NT.
579 GUID Partition Table is used on Intel-based Macintosh computers and
580 gradually replacing MBR on most PCs and other systems.
585 Master Boot Record is used on PCs and removable media.
591 option adds support for the Extended Boot Record (EBR),
592 which is used to define a logical partition.
594 .Cm GEOM_PART_EBR_COMPAT
595 option enables backward compatibility for partition names
597 It also prevents any type of actions on such partitions.
599 Sun's SMI Volume Table Of Contents, used by
611 for additional information on labelization of devices and partitions.
613 Partition types are identified on disk by particular strings or magic
617 utility uses symbolic names for common partition types so the user
618 does not need to know these values or other details of the partitioning
622 utility also allows the user to specify scheme-specific partition types
623 for partition types that do not have symbolic names.
624 Symbolic names currently understood and used by
627 .Bl -tag -width ".Cm dragonfly-disklabel64"
629 The system partition dedicated to storing boot loaders on some Apple
631 The scheme-specific types are
634 .Qq Li "!Apple_Bootstrap"
636 .Qq Li "!426f6f74-0000-11aa-aa11-00306543ecac"
639 The system partition dedicated to second stage of the boot loader program.
640 Usually it is used by the GRUB 2 loader for GPT partitioning schemes.
641 The scheme-specific type is
642 .Qq Li "!21686148-6449-6E6F-744E-656564454649" .
644 The system partition for computers that use the Extensible Firmware
646 The scheme-specific types are
649 .Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93b"
654 partition subdivided into filesystems with a
657 This is a legacy partition type and should not be used for the APM
659 The scheme-specific types are
664 .Qq Li "!516e7cb4-6ecf-11d6-8ff8-00022d09712b"
669 partition dedicated to bootstrap code.
670 The scheme-specific type is
671 .Qq Li "!83bd6b9d-7f41-11dc-be0b-001560b84f0f"
676 partition dedicated to swap space.
677 The scheme-specific types are
678 .Qq Li "!FreeBSD-swap"
680 .Qq Li "!516e7cb5-6ecf-11d6-8ff8-00022d09712b"
681 for GPT, and tag 0x0901 for VTOC8.
685 partition that contains a UFS or UFS2 filesystem.
686 The scheme-specific types are
687 .Qq Li "!FreeBSD-UFS"
689 .Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b"
690 for GPT, and tag 0x0902 for VTOC8.
694 partition that contains a Vinum volume.
695 The scheme-specific types are
696 .Qq Li "!FreeBSD-Vinum"
698 .Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b"
699 for GPT, and tag 0x0903 for VTOC8.
703 partition that contains a ZFS volume.
704 The scheme-specific types are
705 .Qq Li "!FreeBSD-ZFS"
707 .Qq Li "!516e7cba-6ecf-11d6-8ff8-00022d09712b"
708 for GPT, and 0x0904 for VTOC8.
711 Other symbolic names that can be used with the
714 .Bl -tag -width ".Cm dragonfly-disklabel64"
716 An Apple macOS partition used for the Apple file system, APFS.
717 .It Cm apple-core-storage
718 An Apple Mac OS X partition used by logical volume manager known as
720 The scheme-specific type is
721 .Qq Li "!53746f72-6167-11aa-aa11-00306543ecac"
724 An Apple Mac OS X partition that contains a HFS or HFS+ filesystem.
725 The scheme-specific types are
730 .Qq Li "!48465300-0000-11aa-aa11-00306543ecac"
733 An Apple Mac OS X partition dedicated to partition metadata that descibes
735 The scheme-specific type is
736 .Qq Li "!4c616265-6c00-11aa-aa11-00306543ecac"
739 An Apple Mac OS X partition used in a software RAID configuration.
740 The scheme-specific type is
741 .Qq Li "!52414944-0000-11aa-aa11-00306543ecac"
743 .It Cm apple-raid-offline
744 An Apple Mac OS X partition used in a software RAID configuration.
745 The scheme-specific type is
746 .Qq Li "!52414944-5f4f-11aa-aa11-00306543ecac"
748 .It Cm apple-tv-recovery
749 An Apple Mac OS X partition used by Apple TV.
750 The scheme-specific type is
751 .Qq Li "!5265636f-7665-11aa-aa11-00306543ecac"
754 An Apple Mac OS X partition that contains a UFS filesystem.
755 The scheme-specific types are
758 .Qq Li "!Apple_UNIX_SVR2"
760 .Qq Li "!55465300-0000-11aa-aa11-00306543ecac"
763 An Apple Mac OS X partition that contains a ZFS volume.
764 The scheme-specific type is
765 .Qq Li "!6a898cc3-1dd2-11b2-99a6-080020736631"
767 The same GUID is being used also for
768 .Sy illumos/Solaris /usr partition .
772 .It Cm dragonfly-label32
773 A DragonFlyBSD partition subdivided into filesystems with a
776 The scheme-specific type is
777 .Qq Li "!9d087404-1ca5-11dc-8817-01301bb8a9f5"
779 .It Cm dragonfly-label64
780 A DragonFlyBSD partition subdivided into filesystems with a
782 The scheme-specific type is
783 .Qq Li "!3d48ce54-1d16-11dc-8696-01301bb8a9f5"
785 .It Cm dragonfly-legacy
786 A legacy partition type used in DragonFlyBSD.
787 The scheme-specific type is
788 .Qq Li "!bd215ab2-1d16-11dc-8696-01301bb8a9f5"
791 A DragonFlyBSD partition used with Concatenated Disk driver.
792 The scheme-specific type is
793 .Qq Li "!dbd5211b-1ca5-11dc-8817-01301bb8a9f5"
795 .It Cm dragonfly-hammer
796 A DragonFlyBSD partition that contains a Hammer filesystem.
797 The scheme-specific type is
798 .Qq Li "!61dc63ac-6e38-11dc-8513-01301bb8a9f5"
800 .It Cm dragonfly-hammer2
801 A DragonFlyBSD partition that contains a Hammer2 filesystem.
802 The scheme-specific type is
803 .Qq Li "!5cbb9ad1-862d-11dc-a94d-01301bb8a9f5"
805 .It Cm dragonfly-swap
806 A DragonFlyBSD partition dedicated to swap space.
807 The scheme-specific type is
808 .Qq Li "!9d58fdbd-1ca5-11dc-8817-01301bb8a9f5"
811 A DragonFlyBSD partition that contains an UFS1 filesystem.
812 The scheme-specific type is
813 .Qq Li "!9d94ce7c-1ca5-11dc-8817-01301bb8a9f5"
815 .It Cm dragonfly-vinum
816 A DragonFlyBSD partition used with Logical Volume Manager.
817 The scheme-specific type is
818 .Qq Li "!9dd4478f-1ca5-11dc-8817-01301bb8a9f5"
821 A partition subdivided into filesystems with a EBR.
822 The scheme-specific type is
826 A partition that contains a FAT16 filesystem.
827 The scheme-specific type is
831 A partition that contains a FAT32 filesystem.
832 The scheme-specific type is
836 A partition that contains a FAT32 (LBA) filesystem.
837 The scheme-specific type is
841 A raw partition containing a HiFive first stage bootloader.
842 The scheme-specific type is
843 .Qq Li "!5b193300-fc78-40cd-8002-e86c45580b47"
846 A raw partition containing a HiFive second stage bootloader.
847 The scheme-specific type is
848 .Qq Li "!2e54b353-1271-4842-806f-e436d6af6985"
851 A Linux partition that contains some filesystem with data.
852 The scheme-specific types are
855 .Qq Li "!0fc63daf-8483-4772-8e79-3d69d8477de4"
858 A Linux partition dedicated to Logical Volume Manager.
859 The scheme-specific types are
862 .Qq Li "!e6d6d379-f507-44c2-a23c-238f2a3df928"
865 A Linux partition used in a software RAID configuration.
866 The scheme-specific types are
869 .Qq Li "!a19d880f-05fc-4d3b-a006-743f0f84911e"
872 A Linux partition dedicated to swap space.
873 The scheme-specific types are
876 .Qq Li "!0657fd6d-a4ab-43c4-84e5-0933c84b4f4f"
879 A partition that is sub-partitioned by a Master Boot Record (MBR).
880 This type is known as
881 .Qq Li "!024dee41-33e7-11d3-9d69-0008c781f39f"
884 A basic data partition (BDP) for Microsoft operating systems.
885 In the GPT this type is the equivalent to partition types
890 This type is used for GPT exFAT partitions.
891 The scheme-specific type is
892 .Qq Li "!ebd0a0a2-b9e5-4433-87c0-68b6b72699c7"
895 A partition that contains Logical Disk Manager (LDM) volumes.
896 The scheme-specific types are
899 .Qq Li "!af9b60a0-1431-4f62-bc68-3311714a69ad"
901 .It Cm ms-ldm-metadata
902 A partition that contains Logical Disk Manager (LDM) database.
903 The scheme-specific type is
904 .Qq Li "!5808c8aa-7e8f-42e0-85d2-e1e90434cfb3"
907 A NetBSD partition used with Concatenated Disk driver.
908 The scheme-specific type is
909 .Qq Li "!2db519c4-b10f-11dc-b99b-0019d1879648"
912 An encrypted NetBSD partition.
913 The scheme-specific type is
914 .Qq Li "!2db519ec-b10f-11dc-b99b-0019d1879648"
917 A NetBSD partition that contains an UFS filesystem.
918 The scheme-specific type is
919 .Qq Li "!49f48d5a-b10e-11dc-b99b-0019d1879648"
922 A NetBSD partition that contains an LFS filesystem.
923 The scheme-specific type is
924 .Qq Li "!49f48d82-b10e-11dc-b99b-0019d1879648"
927 A NetBSD partition used in a software RAID configuration.
928 The scheme-specific type is
929 .Qq Li "!49f48daa-b10e-11dc-b99b-0019d1879648"
932 A NetBSD partition dedicated to swap space.
933 The scheme-specific type is
934 .Qq Li "!49f48d32-b10e-11dc-b99b-0019d1879648"
937 A partition that contains a NTFS or exFAT filesystem.
938 The scheme-specific type is
942 The system partition dedicated to storing boot loaders on some PowerPC systems,
943 notably those made by IBM.
944 The scheme-specific types are
947 .Qq Li "!9e1a2d38-c612-4316-aa26-8b49521e5a8b"
950 A illumos/Solaris partition dedicated to boot loader.
951 The scheme-specific type is
952 .Qq Li "!6a82cb45-1dd2-11b2-99a6-080020736631"
955 A illumos/Solaris partition dedicated to root filesystem.
956 The scheme-specific type is
957 .Qq Li "!6a85cf4d-1dd2-11b2-99a6-080020736631"
960 A illumos/Solaris partition dedicated to swap.
961 The scheme-specific type is
962 .Qq Li "!6a87c46f-1dd2-11b2-99a6-080020736631"
964 .It Cm solaris-backup
965 A illumos/Solaris partition dedicated to backup.
966 The scheme-specific type is
967 .Qq Li "!6a8b642b-1dd2-11b2-99a6-080020736631"
970 A illumos/Solaris partition dedicated to /var filesystem.
971 The scheme-specific type is
972 .Qq Li "!6a8ef2e9-1dd2-11b2-99a6-080020736631"
975 A illumos/Solaris partition dedicated to /home filesystem.
976 The scheme-specific type is
977 .Qq Li "!6a90ba39-1dd2-11b2-99a6-080020736631"
979 .It Cm solaris-altsec
980 A illumos/Solaris partition dedicated to alternate sector.
981 The scheme-specific type is
982 .Qq Li "!6a9283a5-1dd2-11b2-99a6-080020736631"
984 .It Cm solaris-reserved
985 A illumos/Solaris partition dedicated to reserved space.
986 The scheme-specific type is
987 .Qq Li "!6a945a3b-1dd2-11b2-99a6-080020736631"
990 A partition that contains a VMware File System (VMFS).
991 The scheme-specific types are
994 .Qq Li "!aa31e02a-400f-11db-9590-000c2911d1b8"
996 .It Cm vmware-vmkdiag
997 A partition that contains a VMware diagostic filesystem.
998 The scheme-specific types are
1001 .Qq Li "!9d275380-40ad-11db-bf97-000c2911d1b8"
1003 .It Cm vmware-reserved
1004 A VMware reserved partition.
1005 The scheme-specific type is
1006 .Qq Li "!9198effc-31c0-11db-8f-78-000c2911d1b8"
1008 .It Cm vmware-vsanhdr
1009 A partition claimed by VMware VSAN.
1010 The scheme-specific type is
1011 .Qq Li "!381cfccc-7288-11e0-92ee-000c2911d0b2"
1015 The scheme-specific attributes for EBR:
1016 .Bl -tag -width ".Cm active"
1020 The scheme-specific attributes for GPT:
1021 .Bl -tag -width ".Cm bootfailed"
1025 stage 1 boot loader will try to boot the system from this partition.
1026 Multiple partitions can be marked with the
1033 Setting this attribute automatically sets the
1038 stage 1 boot loader will try to boot the system from this partition only once.
1039 Multiple partitions can be marked with the
1048 This attribute should not be manually managed.
1049 It is managed by the
1051 stage 1 boot loader and the
1052 .Pa /etc/rc.d/gptboot
1058 Setting this attribute overwrites the Protective MBR with a new one where
1059 the 0xee partition is the second, rather than the first record.
1060 This resolves a BIOS compatibility issue with some Lenovo models including the
1061 X220, T420, and T520, allowing them to boot from GPT partitioned disks
1065 The scheme-specific attributes for MBR:
1066 .Bl -tag -width ".Cm active"
1071 supports several partitioning schemes and each scheme uses different
1073 The bootstrap code is located in a specific disk area for each partitioning
1074 scheme, and may vary in size for different schemes.
1076 Bootstrap code can be separated into two types.
1077 The first type is embedded in the partitioning scheme's metadata, while the
1078 second type is located on a specific partition.
1079 Embedding bootstrap code should only be done with the
1084 The GEOM PART class knows how to safely embed bootstrap code into
1085 specific partitioning scheme metadata without causing any damage.
1087 The Master Boot Record (MBR) uses a 512-byte bootstrap code image, embedded
1088 into the partition table's metadata area.
1089 There are two variants of this bootstrap code:
1094 searches for a partition with the
1098 section) in the partition table.
1099 Then it runs next bootstrap stage.
1102 image contains a boot manager with some additional interactive functions
1103 for multi-booting from a user-selected partition.
1105 A BSD disklabel is usually created inside an MBR partition (slice)
1109 .Sx "PARTITION TYPES"
1111 It uses 8 KB size bootstrap code image
1113 embedded into the partition table's metadata area.
1115 Both types of bootstrap code are used to boot from the GUID Partition Table.
1116 First, a protective MBR is embedded into the first disk sector from the
1119 It searches through the GPT for a
1122 .Sx "PARTITION TYPES"
1123 section) and runs the next bootstrap stage from it.
1126 partition should be smaller than 545 KB.
1127 It can be located either before or after other
1129 partitions on the disk.
1130 There are two variants of bootstrap code to write to this partition:
1133 .Pa /boot/gptzfsboot .
1136 is used to boot from UFS partitions.
1140 partitions in the GPT and selects one to boot based on the
1145 If neither attribute is found,
1147 boots from the first
1151 .Pq the third bootstrap stage
1152 is loaded from the first partition that matches these conditions.
1155 for more information.
1157 .Pa /boot/gptzfsboot
1158 is used to boot from ZFS.
1159 It searches through the GPT for
1161 partitions, trying to detect ZFS pools.
1162 After all pools are detected,
1164 is started from the first one found set as bootable.
1166 The VTOC8 scheme does not support embedding bootstrap code.
1167 Instead, the 8 KBytes bootstrap code image
1169 should be written with the
1173 option to all sufficiently large VTOC8 partitions.
1176 option could be omitted.
1178 The APM scheme also does not support embedding bootstrap code.
1179 Instead, the 800 KBytes bootstrap code image
1181 should be written with the
1183 command to a partition of type
1185 which should also be 800 KB in size.
1186 .Sh OPERATIONAL FLAGS
1187 Actions other than the
1191 actions take an optional
1194 This option is used to specify action-specific operational flags.
1199 flag so that the action is immediately
1201 The user can specify
1203 to have the action result in a pending change that can later, with
1204 other pending changes, be committed as a single compound change with
1207 action or reverted with the
1211 The GEOM PART class supports recovering of partition tables only for GPT.
1212 The GPT primary metadata is stored at the beginning of the device.
1213 For redundancy, a secondary
1215 copy of the metadata is stored at the end of the device.
1216 As a result of having two copies, some corruption of metadata is not
1217 fatal to the working of GPT.
1218 When the kernel detects corrupt metadata, it marks this table as corrupt
1219 and reports the problem.
1223 are the only operations allowed on corrupt tables.
1225 If one GPT header appears to be corrupt but the other copy remains intact,
1226 the kernel will log the following:
1227 .Bd -literal -offset indent
1228 GEOM: provider: the primary GPT table is corrupt or invalid.
1229 GEOM: provider: using the secondary instead -- recovery strongly advised.
1233 .Bd -literal -offset indent
1234 GEOM: provider: the secondary GPT table is corrupt or invalid.
1235 GEOM: provider: using the primary only -- recovery suggested.
1244 will report about corrupt tables.
1246 If the size of the device has changed (e.g.,\& volume expansion) the
1247 secondary GPT header will no longer be located in the last sector.
1248 This is not a metadata corruption, but it is dangerous because any
1249 corruption of the primary GPT will lead to loss of the partition table.
1250 This problem is reported by the kernel with the message:
1251 .Bd -literal -offset indent
1252 GEOM: provider: the secondary GPT header is not in the last LBA.
1255 This situation can be recovered with the
1258 This command reconstructs the corrupt metadata using known valid
1259 metadata and relocates the secondary GPT to the end of the device.
1262 The GEOM PART class can detect the same partition table visible through
1263 different GEOM providers, and some of them will be marked as corrupt.
1264 Be careful when choosing a provider for recovery.
1265 If you choose incorrectly you can destroy the metadata of another GEOM class,
1266 e.g.,\& GEOM MIRROR or GEOM LABEL.
1267 .Sh SYSCTL VARIABLES
1270 variables can be used to control the behavior of the
1273 The default value is shown next to each variable.
1274 .Bl -tag -width indent
1275 .It Va kern.geom.part.allow_nesting : No 0
1276 By default, some schemes (currently BSD, BSD64 and VTOC8) do not permit
1277 further nested partitioning.
1278 This variable overrides this restriction and allows arbitrary nesting (except
1279 within partitions created at offset 0).
1280 Some schemes have their own separate checks, for which see below.
1281 .It Va kern.geom.part.auto_resize : No 1
1282 This variable controls automatic resize behavior of the
1285 When this variable is enable and new size of provider is detected, the schema
1286 metadata is resized but all changes are not saved to disk, until
1288 is run to confirm changes.
1289 This behavior is also reported with diagnostic message:
1290 .Sy "GEOM_PART: (provider) was automatically resized."
1291 .Sy "Use `gpart commit (provider)` to save changes or `gpart undo (provider)`"
1292 .Sy "to revert them."
1293 .It Va kern.geom.part.check_integrity : No 1
1294 This variable controls the behaviour of metadata integrity checks.
1295 When integrity checks are enabled, the
1297 GEOM class verifies all generic partition parameters obtained from the
1299 If some inconsistency is detected, the partition table will be
1300 rejected with a diagnostic message:
1301 .Sy "GEOM_PART: Integrity check failed (provider, scheme)" .
1302 .It Va kern.geom.part.gpt.allow_nesting : No 0
1303 By default the GPT scheme is allowed only at the outermost nesting level.
1304 This variable allows this restriction to be removed.
1305 .It Va kern.geom.part.ldm.debug : No 0
1306 Debug level of the Logical Disk Manager (LDM) module.
1307 This can be set to a number between 0 and 2 inclusive.
1308 If set to 0 minimal debug information is printed,
1309 and if set to 2 the maximum amount of debug information is printed.
1310 .It Va kern.geom.part.ldm.show_mirrors : No 0
1311 This variable controls how the Logical Disk Manager (LDM) module handles
1313 By default mirrored volumes are shown as partitions with type
1316 .Sx "PARTITION TYPES"
1318 If this variable set to 1 each component of the mirrored volume will be
1319 present as independent partition.
1321 This may break a mirrored volume and lead to data damage.
1322 .It Va kern.geom.part.mbr.enforce_chs : No 0
1323 Specify how the Master Boot Record (MBR) module does alignment.
1324 If this variable is set to a non-zero value, the module will automatically
1325 recalculate the user-specified offset and size for alignment with the CHS
1327 Otherwise the values will be left unchanged.
1328 .It Va kern.geom.part.separator : No ""
1329 Specify an optional separator that will be inserted between the GEOM name
1334 Note that setting this variable may break software which assumes a particular
1338 Exit status is 0 on success, and 1 if the command fails.
1340 The examples below assume that the disk's logical block size is 512
1341 bytes, regardless of its physical block size.
1343 In this example, we will format
1345 with the GPT scheme and create boot, swap and root partitions.
1346 First, we need to create the partition table:
1347 .Bd -literal -offset indent
1348 /sbin/gpart create -s GPT ada0
1351 Next, we install a protective MBR with the first-stage bootstrap code.
1352 The protective MBR lists a single, bootable partition spanning the
1353 entire disk, thus allowing non-GPT-aware BIOSes to boot from the disk
1354 and preventing tools which do not understand the GPT scheme from
1355 considering the disk to be unformatted.
1356 .Bd -literal -offset indent
1357 /sbin/gpart bootcode -b /boot/pmbr ada0
1360 We then create a dedicated
1362 partition to hold the second-stage boot loader, which will load the
1364 kernel and modules from a UFS or ZFS filesystem.
1365 This partition must be larger than the bootstrap code
1370 .Pa /boot/gptzfsboot
1373 but smaller than 545 kB since the first-stage loader will load the
1374 entire partition into memory during boot, regardless of how much data
1375 it actually contains.
1376 We create a 472-block (236 kB) boot partition at offset 40, which is
1377 the size of the partition table (34 blocks or 17 kB) rounded up to the
1378 nearest 4 kB boundary.
1379 .Bd -literal -offset indent
1380 /sbin/gpart add -b 40 -s 472 -t freebsd-boot ada0
1381 /sbin/gpart bootcode -p /boot/gptboot -i 1 ada0
1384 We now create a 4 GB swap partition at the first available offset,
1385 which is 40 + 472 = 512 blocks (256 kB).
1386 .Bd -literal -offset indent
1387 /sbin/gpart add -s 4G -t freebsd-swap ada0
1390 Aligning the swap partition and all subsequent partitions on a 256 kB
1391 boundary ensures optimal performance on a wide range of media, from
1392 plain old disks with 512-byte blocks, through modern
1394 disks with 4096-byte physical blocks, to RAID volumes with stripe
1395 sizes of up to 256 kB.
1397 Finally, we create and format an 8 GB
1399 partition for the root filesystem, leaving the rest of the slice free
1400 for additional filesystems:
1401 .Bd -literal -offset indent
1402 /sbin/gpart add -s 8G -t freebsd-ufs ada0
1403 /sbin/newfs -Uj /dev/ada0p3
1406 In this example, we will format
1408 with the MBR scheme and create a single partition which we subdivide
1413 First, we create the partition table and a single 64 GB partition,
1414 then we mark that partition active (bootable) and install the
1415 first-stage boot loader:
1416 .Bd -literal -offset indent
1417 /sbin/gpart create -s MBR ada0
1418 /sbin/gpart add -t freebsd -s 64G ada0
1419 /sbin/gpart set -a active -i 1 ada0
1420 /sbin/gpart bootcode -b /boot/boot0 ada0
1423 Next, we create a disklabel in that partition
1426 in disklabel terminology
1428 with room for up to 20 partitions:
1429 .Bd -literal -offset indent
1430 /sbin/gpart create -s BSD -n 20 ada0s1
1433 We then create an 8 GB root partition and a 4 GB swap partition:
1434 .Bd -literal -offset indent
1435 /sbin/gpart add -t freebsd-ufs -s 8G ada0s1
1436 /sbin/gpart add -t freebsd-swap -s 4G ada0s1
1439 Finally, we install the appropriate boot loader for the
1442 .Bd -literal -offset indent
1443 /sbin/gpart bootcode -b /boot/boot ada0s1
1447 Create a VTOC8 scheme on
1449 .Bd -literal -offset indent
1450 /sbin/gpart create -s VTOC8 da0
1453 Create a 512MB-sized
1455 partition to contain a UFS filesystem from which the system can boot.
1456 .Bd -literal -offset indent
1457 /sbin/gpart add -s 512M -t freebsd-ufs da0
1462 partition to contain a UFS filesystem and aligned on 4KB boundaries:
1463 .Bd -literal -offset indent
1464 /sbin/gpart add -s 15G -t freebsd-ufs -a 4k da0
1467 After creating all required partitions, embed bootstrap code into them:
1468 .Bd -literal -offset indent
1469 /sbin/gpart bootcode -p /boot/boot1 da0
1471 .Ss Deleting Partitions and Destroying the Partitioning Scheme
1474 error is shown when trying to destroy a partition table, remember that
1475 all of the partitions must be deleted first with the
1480 has three partitions:
1481 .Bd -literal -offset indent
1482 /sbin/gpart delete -i 3 da0
1483 /sbin/gpart delete -i 2 da0
1484 /sbin/gpart delete -i 1 da0
1485 /sbin/gpart destroy da0
1488 Rather than deleting each partition and then destroying the partitioning
1491 option can be given with
1493 to delete all of the partitions before destroying the partitioning scheme.
1494 This is equivalent to the previous example:
1495 .Bd -literal -offset indent
1496 /sbin/gpart destroy -F da0
1498 .Ss Backup and Restore
1500 Create a backup of the partition table from
1502 .Bd -literal -offset indent
1503 /sbin/gpart backup da0 > da0.backup
1506 Restore the partition table from the backup to
1508 .Bd -literal -offset indent
1509 /sbin/gpart restore -l da0 < /mnt/da0.backup
1512 Clone the partition table from
1518 .Bd -literal -offset indent
1519 /sbin/gpart backup ada0 | /sbin/gpart restore -F ada1 ada2
1533 .An Marcel Moolenaar Aq Mt marcel@FreeBSD.org
1537 (6a898cc3-1dd2-11b2-99a6-080020736631) is also being used
1538 on illumos/Solaris platforms for ZFS volumes.