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 begins on the logical block address given by the
153 Its size is given by the
156 SI unit suffixes are allowed.
161 options can be omitted.
162 If so they are automatically calculated.
163 The type of the partition is given by the
166 Partition types are discussed below in the section entitled
167 .Sx "PARTITION TYPES" .
169 Additional options include:
171 .It Fl a Ar alignment
174 utility tries to align
182 The index in the partition table at which the new partition is to be
184 The index determines the name of the device special file used
185 to represent the partition.
187 The label attached to the partition.
188 This option is only valid when used on partitioning schemes that support
191 Additional operational flags.
192 See the section entitled
193 .Sx "OPERATIONAL FLAGS"
194 below for a discussion
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
212 Not all partitioning schemes have embedded bootstrap code, so the
214 option is scheme-specific in nature (see the section entitled
219 option specifies a file that contains the bootstrap code.
220 The contents and size of the file are determined by the partitioning
224 option specifies a file that contains the bootstrap code intended to be
225 written to a partition.
226 The partition is specified by the
229 The size of the file must be smaller than the size of the partition.
231 Additional options include:
234 Additional operational flags.
235 See the section entitled
236 .Sx "OPERATIONAL FLAGS"
237 below for a discussion
242 Commit any pending changes for geom
244 All actions are committed by default and will not result in
246 Actions can be modified with the
248 option so that they are not committed, but become pending.
249 Pending changes are reflected by the geom and the
251 utility, but they are not actually written to disk.
254 action will write all pending changes to disk.
257 Create a new partitioning scheme on a provider given by
261 option determines the scheme to use.
262 The kernel must have support for a particular scheme before
263 that scheme can be used to partition a disk.
265 Additional options include:
268 The number of entries in the partition table.
269 Every partitioning scheme has a minimum and maximum number of entries.
270 This option allows tables to be created with a number of entries
271 that is within the limits.
272 Some schemes have a maximum equal to the minimum and some schemes have
273 a maximum large enough to be considered unlimited.
274 By default, partition tables are created with the minimum number of
277 Additional operational flags.
278 See the section entitled
279 .Sx "OPERATIONAL FLAGS"
280 below for a discussion
285 Delete a partition from geom
287 and further identified by the
290 The partition cannot be actively used by the kernel.
292 Additional options include:
295 Additional operational flags.
296 See the section entitled
297 .Sx "OPERATIONAL FLAGS"
298 below for a discussion
301 .\" ==== DESTROY ====
303 Destroy the partitioning scheme as implemented by geom
306 Additional options include:
309 Forced destroying of the partition table even if it is not empty.
311 Additional operational flags.
312 See the section entitled
313 .Sx "OPERATIONAL FLAGS"
314 below for a discussion
319 Modify a partition from geom
321 and further identified by the
324 Only the type and/or label of the partition can be modified.
325 To change the type of a partition, specify the new type with the
328 To change the label of a partition, specify the new label with the
331 Not all partitioning schemes support labels and it is invalid to
332 try to change a partition label in such cases.
334 Additional options include:
337 Additional operational flags.
338 See the section entitled
339 .Sx "OPERATIONAL FLAGS"
340 below for a discussion
343 .\" ==== RECOVER ====
345 Recover a corrupt partition's scheme metadata on the geom
347 See the section entitled
349 below for the additional information.
351 Additional options include:
354 Additional operational flags.
355 See the section entitled
356 .Sx "OPERATIONAL FLAGS"
357 below for a discussion
362 Resize a partition from geom
364 and further identified by the
367 New partition size is expressed in logical block
368 numbers and can be given by the
373 option is omitted then new size is automatically calculated
374 to maximum available from given geom
377 Additional options include:
379 .It Fl a Ar alignment
382 utility tries to align partition
388 Additional operational flags.
389 See the section entitled
390 .Sx "OPERATIONAL FLAGS"
391 below for a discussion
394 .\" ==== RESTORE ====
396 Restore the partition table from a backup previously created by the
398 action and read from standard input.
399 Only the partition table is restored.
400 This action does not affect the content of partitions.
401 After restoring the partition table and writing bootcode if needed,
402 user data must be restored from backup.
404 Additional options include:
407 Destroy partition table on the given
409 before doing restore.
411 Restore partition labels for partitioning schemes that support them.
413 Additional operational flags.
414 See the section entitled
415 .Sx "OPERATIONAL FLAGS"
416 below for a discussion
421 Set the named attribute on the partition entry.
422 See the section entitled
424 below for a list of available attributes.
426 Additional options include:
429 Additional operational flags.
430 See the section entitled
431 .Sx "OPERATIONAL FLAGS"
432 below for a discussion
437 Show current partition information for the specified geoms, or all
438 geoms if none are specified.
439 The default output includes the logical starting block of each
440 partition, the partition size in blocks, the partition index number,
441 the partition type, and a human readable partition size.
442 Block sizes and locations are based on the device's Sectorsize
445 Additional options include:
448 For partitioning schemes that support partition labels, print them
449 instead of partition type.
451 Show provider names instead of partition indexes.
453 Show raw partition type instead of symbolic name.
457 Revert any pending changes for geom
459 This action is the opposite of the
461 action and can be used to undo any changes that have not been committed.
464 Clear the named attribute on the partition entry.
465 See the section entitled
467 below for a list of available attributes.
469 Additional options include:
472 Additional operational flags.
473 See the section entitled
474 .Sx "OPERATIONAL FLAGS"
475 below for a discussion
491 .Sh PARTITIONING SCHEMES
492 Several partitioning schemes are supported by the
495 .Bl -tag -width ".Cm VTOC8"
497 Apple Partition Map, used by PowerPC(R) Macintosh(R) computers.
502 Traditional BSD disklabel, usually used to subdivide MBR partitions.
504 This scheme can also be used as the sole partitioning method, without
506 Partition editing tools from other operating systems often do not
507 understand the bare disklabel partition layout, so this is sometimes
509 .Dq dangerously dedicated .
515 64-bit implementation of BSD disklabel used in DragonFlyBSD to subdivide MBR
521 The Logical Disk Manager is an implementation of volume manager for
522 Microsoft Windows NT.
527 GUID Partition Table is used on Intel-based Macintosh computers and
528 gradually replacing MBR on most PCs and other systems.
533 Master Boot Record is used on PCs and removable media.
539 option adds support for the Extended Boot Record (EBR),
540 which is used to define a logical partition.
542 .Cm GEOM_PART_EBR_COMPAT
543 option enables backward compatibility for partition names
545 It also prevents any type of actions on such partitions.
547 An MBR variant for NEC PC-98 and compatible computers.
552 Sun's SMI Volume Table Of Contents, used by
562 Partition types are identified on disk by particular strings or magic
566 utility uses symbolic names for common partition types so the user
567 does not need to know these values or other details of the partitioning
571 utility also allows the user to specify scheme-specific partition types
572 for partition types that do not have symbolic names.
573 Symbolic names currently understood and used by
576 .Bl -tag -width ".Cm dragonfly-disklabel64"
578 The system partition dedicated to storing boot loaders on some Apple
580 The scheme-specific types are
583 .Qq Li "!Apple_Bootstrap"
585 .Qq Li "!426f6f74-0000-11aa-aa11-00306543ecac"
588 The system partition dedicated to second stage of the boot loader program.
589 Usually it is used by the GRUB 2 loader for GPT partitioning schemes.
590 The scheme-specific type is
591 .Qq Li "!21686148-6449-6E6F-744E-656564454649" .
593 The system partition for computers that use the Extensible Firmware
595 In such cases, the GPT partitioning scheme is used and the
596 actual partition type for the system partition can also be specified as
597 .Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93b" .
601 partition subdivided into filesystems with a
604 This is a legacy partition type and should not be used for the APM
606 The scheme-specific types are
611 .Qq Li "!516e7cb4-6ecf-11d6-8ff8-00022d09712b"
616 partition dedicated to bootstrap code.
617 The scheme-specific type is
618 .Qq Li "!83bd6b9d-7f41-11dc-be0b-001560b84f0f"
623 partition dedicated to swap space.
624 The scheme-specific types are
625 .Qq Li "!FreeBSD-swap"
627 .Qq Li "!516e7cb5-6ecf-11d6-8ff8-00022d09712b"
628 for GPT, and tag 0x0901 for VTOC8.
632 partition that contains a UFS or UFS2 filesystem.
633 The scheme-specific types are
634 .Qq Li "!FreeBSD-UFS"
636 .Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b"
637 for GPT, and tag 0x0902 for VTOC8.
641 partition that contains a Vinum volume.
642 The scheme-specific types are
643 .Qq Li "!FreeBSD-Vinum"
645 .Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b"
646 for GPT, and tag 0x0903 for VTOC8.
650 partition that contains a ZFS volume.
651 The scheme-specific types are
652 .Qq Li "!FreeBSD-ZFS"
654 .Qq Li "!516e7cba-6ecf-11d6-8ff8-00022d09712b"
655 for GPT, and 0x0904 for VTOC8.
658 Another symbolic names that can be used with
661 .Bl -tag -width ".Cm dragonfly-disklabel64"
662 .It Cm apple-core-storage
663 An Apple Mac OS X partition used by logical volume manager known as
665 The scheme-specific type is
666 .Qq Li "!53746f72-6167-11aa-aa11-00306543ecac"
669 An Apple Mac OS X partition that contains a HFS or HFS+ filesystem.
670 The scheme-specific types are
675 .Qq Li "!48465300-0000-11aa-aa11-00306543ecac"
678 An Apple Mac OS X partition dedicated to partition metadata that descibes
680 The scheme-specific type is
681 .Qq Li "!4c616265-6c00-11aa-aa11-00306543ecac"
684 An Apple Mac OS X partition used in a software RAID configuration.
685 The scheme-specific type is
686 .Qq Li "!52414944-0000-11aa-aa11-00306543ecac"
688 .It Cm apple-raid-offline
689 An Apple Mac OS X partition used in a software RAID configuration.
690 The scheme-specific type is
691 .Qq Li "!52414944-5f4f-11aa-aa11-00306543ecac"
693 .It Cm apple-tv-recovery
694 An Apple Mac OS X partition used by Apple TV.
695 The scheme-specific type is
696 .Qq Li "!5265636f-7665-11aa-aa11-00306543ecac"
699 An Apple Mac OS X partition that contains a UFS filesystem.
700 The scheme-specific types are
703 .Qq Li "!Apple_UNIX_SVR2"
705 .Qq Li "!55465300-0000-11aa-aa11-00306543ecac"
707 .It Cm dragonfly-label32
708 A DragonFlyBSD partition subdivided into filesystems with a
711 The scheme-specific type is
712 .Qq Li "!9d087404-1ca5-11dc-8817-01301bb8a9f5"
714 .It Cm dragonfly-label64
715 A DragonFlyBSD partition subdivided into filesystems with a
717 The scheme-specific type is
718 .Qq Li "!3d48ce54-1d16-11dc-8696-01301bb8a9f5"
720 .It Cm dragonfly-legacy
721 A legacy partition type used in DragonFlyBSD.
722 The scheme-specific type is
723 .Qq Li "!bd215ab2-1d16-11dc-8696-01301bb8a9f5"
726 A DragonFlyBSD partition used with Concatenated Disk driver.
727 The scheme-specific type is
728 .Qq Li "!dbd5211b-1ca5-11dc-8817-01301bb8a9f5"
730 .It Cm dragonfly-hammer
731 A DragonFlyBSD partition that contains a Hammer filesystem.
732 The scheme-specific type is
733 .Qq Li "!61dc63ac-6e38-11dc-8513-01301bb8a9f5"
735 .It Cm dragonfly-hammer2
736 A DragonFlyBSD partition that contains a Hammer2 filesystem.
737 The scheme-specific type is
738 .Qq Li "!5cbb9ad1-862d-11dc-a94d-01301bb8a9f5"
740 .It Cm dragonfly-swap
741 A DragonFlyBSD partition dedicated to swap space.
742 The scheme-specific type is
743 .Qq Li "!9d58fdbd-1ca5-11dc-8817-01301bb8a9f5"
746 A DragonFlyBSD partition that contains an UFS1 filesystem.
747 The scheme-specific type is
748 .Qq Li "!9d94ce7c-1ca5-11dc-8817-01301bb8a9f5"
750 .It Cm dragonfly-vinum
751 A DragonFlyBSD partition used with Logical Volume Manager.
752 The scheme-specific type is
753 .Qq Li "!9dd4478f-1ca5-11dc-8817-01301bb8a9f5"
756 A partition subdivided into filesystems with a EBR.
757 The scheme-specific type is
761 A partition that contains a FAT16 filesystem.
762 The scheme-specific type is
766 A partition that contains a FAT32 filesystem.
767 The scheme-specific type is
771 A Linux partition that contains some filesystem with data.
772 The scheme-specific types are
775 .Qq Li "!0fc63daf-8483-4772-8e79-3d69d8477de4"
778 A Linux partition dedicated to Logical Volume Manager.
779 The scheme-specific types are
782 .Qq Li "!e6d6d379-f507-44c2-a23c-238f2a3df928"
785 A Linux partition used in a software RAID configuration.
786 The scheme-specific types are
789 .Qq Li "!a19d880f-05fc-4d3b-a006-743f0f84911e"
792 A Linux partition dedicated to swap space.
793 The scheme-specific types are
796 .Qq Li "!0657fd6d-a4ab-43c4-84e5-0933c84b4f4f"
799 A partition that is sub-partitioned by a Master Boot Record (MBR).
800 This type is known as
801 .Qq Li "!024dee41-33e7-11d3-9d69-0008c781f39f"
804 A basic data partition (BDP) for Microsoft operating systems.
805 In the GPT this type is the equivalent to partition types
810 The scheme-specific type is
811 .Qq Li "!ebd0a0a2-b9e5-4433-87c0-68b6b72699c7"
814 A partition that contains Logical Disk Manager (LDM) volumes.
815 The scheme-specific types are
818 .Qq Li "!af9b60a0-1431-4f62-bc68-3311714a69ad"
820 .It Cm ms-ldm-metadata
821 A partition that contains Logical Disk Manager (LDM) database.
822 The scheme-specific type is
823 .Qq Li "!5808c8aa-7e8f-42e0-85d2-e1e90434cfb3"
826 A NetBSD partition used with Concatenated Disk driver.
827 The scheme-specific type is
828 .Qq Li "!2db519c4-b10f-11dc-b99b-0019d1879648"
831 An encrypted NetBSD partition.
832 The scheme-specific type is
833 .Qq Li "!2db519ec-b10f-11dc-b99b-0019d1879648"
836 A NetBSD partition that contains an UFS filesystem.
837 The scheme-specific type is
838 .Qq Li "!49f48d5a-b10e-11dc-b99b-0019d1879648"
841 A NetBSD partition that contains an LFS filesystem.
842 The scheme-specific type is
843 .Qq Li "!49f48d82-b10e-11dc-b99b-0019d1879648"
846 A NetBSD partition used in a software RAID configuration.
847 The scheme-specific type is
848 .Qq Li "!49f48daa-b10e-11dc-b99b-0019d1879648"
851 A NetBSD partition dedicated to swap space.
852 The scheme-specific type is
853 .Qq Li "!49f48d32-b10e-11dc-b99b-0019d1879648"
856 A partition that contains a NTFS or exFAT filesystem.
857 The scheme-specific type is
861 The system partition dedicated to storing boot loaders on some PowerPC systems,
862 notably those made by IBM.
863 The scheme-specific types are
866 .Qq Li "!0x9e1a2d38-c612-4316-aa26-8b49521e5a8b"
869 A partition that contains a VMware File System (VMFS).
870 The scheme-specific types are
873 .Qq Li "!aa31e02a-400f-11db-9590-000c2911d1b8"
875 .It Cm vmware-vmkdiag
876 A partition that contains a VMware diagostic filesystem.
877 The scheme-specific types are
880 .Qq Li "!9d275380-40ad-11db-bf97-000c2911d1b8"
882 .It Cm vmware-reserved
883 A VMware reserved partition.
884 The scheme-specific type is
885 .Qq Li "!9198effc-31c0-11db-8f-78-000c2911d1b8"
887 .It Cm vmware-vsanhdr
888 A partition claimed by VMware VSAN.
889 The scheme-specific type is
890 .Qq Li "!381cfccc-7288-11e0-92ee-000c2911d0b2"
894 The scheme-specific attributes for EBR:
895 .Bl -tag -width ".Cm active"
899 The scheme-specific attributes for GPT:
900 .Bl -tag -width ".Cm bootfailed"
904 stage 1 boot loader will try to boot the system from this partition.
905 Multiple partitions can be marked with the
912 Setting this attribute automatically sets the
917 stage 1 boot loader will try to boot the system from this partition only once.
918 Multiple partitions can be marked with the
927 This attribute should not be manually managed.
930 stage 1 boot loader and the
931 .Pa /etc/rc.d/gptboot
937 Setting this attribute overwrites the Protective MBR with a new one where
938 the 0xee partition is the second, rather than the first record.
939 This resolves a BIOS compatibility issue with some Lenovo models including the
940 X220, T420, and T520, allowing them to boot from GPT partitioned disks
944 The scheme-specific attributes for MBR:
945 .Bl -tag -width ".Cm active"
949 The scheme-specific attributes for PC98:
950 .Bl -tag -width ".Cm bootable"
956 supports several partitioning schemes and each scheme uses different
958 The bootstrap code is located in a specific disk area for each partitioning
959 scheme, and may vary in size for different schemes.
961 Bootstrap code can be separated into two types.
962 The first type is embedded in the partitioning scheme's metadata, while the
963 second type is located on a specific partition.
964 Embedding bootstrap code should only be done with the
969 The GEOM PART class knows how to safely embed bootstrap code into
970 specific partitioning scheme metadata without causing any damage.
972 The Master Boot Record (MBR) uses a 512-byte bootstrap code image, embedded
973 into the partition table's metadata area.
974 There are two variants of this bootstrap code:
979 searches for a partition with the
983 section) in the partition table.
984 Then it runs next bootstrap stage.
987 image contains a boot manager with some additional interactive functions
988 for multi-booting from a user-selected partition.
990 A BSD disklabel is usually created inside an MBR partition (slice)
994 .Sx "PARTITION TYPES"
996 It uses 8 KB size bootstrap code image
998 embedded into the partition table's metadata area.
1000 Both types of bootstrap code are used to boot from the GUID Partition Table.
1001 First, a protective MBR is embedded into the first disk sector from the
1004 It searches through the GPT for a
1007 .Sx "PARTITION TYPES"
1008 section) and runs the next bootstrap stage from it.
1011 partition should be smaller than 545 KB.
1012 It can be located either before or after other
1014 partitions on the disk.
1015 There are two variants of bootstrap code to write to this partition:
1018 .Pa /boot/gptzfsboot .
1021 is used to boot from UFS partitions.
1025 partitions in the GPT and selects one to boot based on the
1030 If neither attribute is found,
1032 boots from the first
1036 .Pq the third bootstrap stage
1037 is loaded from the first partition that matches these conditions.
1040 for more information.
1042 .Pa /boot/gptzfsboot
1043 is used to boot from ZFS.
1044 It searches through the GPT for
1046 partitions, trying to detect ZFS pools.
1047 After all pools are detected,
1049 is started from the first one found.
1051 The VTOC8 scheme does not support embedding bootstrap code.
1052 Instead, the 8 KBytes bootstrap code image
1054 should be written with the
1058 option to all sufficiently large VTOC8 partitions.
1061 option could be omitted.
1063 The APM scheme also does not support embedding bootstrap code.
1064 Instead, the 800 KBytes bootstrap code image
1066 should be written with the
1068 command to a partition of type
1070 which should also be 800 KB in size.
1071 .Sh OPERATIONAL FLAGS
1072 Actions other than the
1076 actions take an optional
1079 This option is used to specify action-specific operational flags.
1084 flag so that the action is immediately
1086 The user can specify
1088 to have the action result in a pending change that can later, with
1089 other pending changes, be committed as a single compound change with
1092 action or reverted with the
1096 The GEOM PART class supports recovering of partition tables only for GPT.
1097 The GPT primary metadata is stored at the beginning of the device.
1098 For redundancy, a secondary
1100 copy of the metadata is stored at the end of the device.
1101 As a result of having two copies, some corruption of metadata is not
1102 fatal to the working of GPT.
1103 When the kernel detects corrupt metadata, it marks this table as corrupt
1104 and reports the problem.
1108 are the only operations allowed on corrupt tables.
1110 If one GPT header appears to be corrupt but the other copy remains intact,
1111 the kernel will log the following:
1112 .Bd -literal -offset indent
1113 GEOM: provider: the primary GPT table is corrupt or invalid.
1114 GEOM: provider: using the secondary instead -- recovery strongly advised.
1118 .Bd -literal -offset indent
1119 GEOM: provider: the secondary GPT table is corrupt or invalid.
1120 GEOM: provider: using the primary only -- recovery suggested.
1129 will report about corrupt tables.
1131 If the size of the device has changed (e.g.,\& volume expansion) the
1132 secondary GPT header will no longer be located in the last sector.
1133 This is not a metadata corruption, but it is dangerous because any
1134 corruption of the primary GPT will lead to loss of the partition table.
1135 This problem is reported by the kernel with the message:
1136 .Bd -literal -offset indent
1137 GEOM: provider: the secondary GPT header is not in the last LBA.
1140 This situation can be recovered with the
1143 This command reconstructs the corrupt metadata using known valid
1144 metadata and relocates the secondary GPT to the end of the device.
1147 The GEOM PART class can detect the same partition table visible through
1148 different GEOM providers, and some of them will be marked as corrupt.
1149 Be careful when choosing a provider for recovery.
1150 If you choose incorrectly you can destroy the metadata of another GEOM class,
1151 e.g.,\& GEOM MIRROR or GEOM LABEL.
1152 .Sh SYSCTL VARIABLES
1155 variables can be used to control the behavior of the
1158 The default value is shown next to each variable.
1159 .Bl -tag -width indent
1160 .It Va kern.geom.part.check_integrity : No 1
1161 This variable controls the behaviour of metadata integrity checks.
1162 When integrity checks are enabled, the
1164 GEOM class verifies all generic partition parameters obtained from the
1166 If some inconsistency is detected, the partition table will be
1167 rejected with a diagnostic message:
1168 .Sy "GEOM_PART: Integrity check failed (provider, scheme)" .
1169 .It Va kern.geom.part.ldm.debug : No 0
1170 Debug level of the Logical Disk Manager (LDM) module.
1171 This can be set to a number between 0 and 2 inclusive.
1172 If set to 0 minimal debug information is printed,
1173 and if set to 2 the maximum amount of debug information is printed.
1174 .It Va kern.geom.part.ldm.show_mirrors : No 0
1175 This variable controls how the Logical Disk Manager (LDM) module handles
1177 By default mirrored volumes are shown as partitions with type
1180 .Sx "PARTITION TYPES"
1182 If this variable set to 1 each component of the mirrored volume will be
1183 present as independent partition.
1185 This may break a mirrored volume and lead to data damage.
1186 .It Va kern.geom.part.mbr.enforce_chs : No 1
1187 Specify how the Master Boot Record (MBR) module does alignment.
1188 If this variable is set to a non-zero value, the module will automatically
1189 recalculate the user-specified offset and size for alignment with the CHS
1191 Otherwise the values will be left unchanged.
1194 Exit status is 0 on success, and 1 if the command fails.
1196 The examples below assume that the disk's logical block size is 512
1197 bytes, regardless of its physical block size.
1199 In this example, we will format
1201 with the GPT scheme and create boot, swap and root partitions.
1202 First, we need to create the partition table:
1203 .Bd -literal -offset indent
1204 /sbin/gpart create -s GPT ada0
1207 Next, we install a protective MBR with the first-stage bootstrap code.
1208 The protective MBR lists a single, bootable partition spanning the
1209 entire disk, thus allowing non-GPT-aware BIOSes to boot from the disk
1210 and preventing tools which do not understand the GPT scheme from
1211 considering the disk to be unformatted.
1212 .Bd -literal -offset indent
1213 /sbin/gpart bootcode -b /boot/pmbr ada0
1216 We then create a dedicated
1218 partition to hold the second-stage boot loader, which will load the
1220 kernel and modules from a UFS or ZFS filesystem.
1221 This partition must be larger than the bootstrap code
1226 .Pa /boot/gptzfsboot
1229 but smaller than 545 kB since the first-stage loader will load the
1230 entire partition into memory during boot, regardless of how much data
1231 it actually contains.
1232 We create a 472-block (236 kB) boot partition at offset 40, which is
1233 the size of the partition table (34 blocks or 17 kB) rounded up to the
1234 nearest 4 kB boundary.
1235 .Bd -literal -offset indent
1236 /sbin/gpart add -b 40 -s 472 -t freebsd-boot ada0
1237 /sbin/gpart bootcode -p /boot/gptboot -i 1 ada0
1240 We now create a 4 GB swap partition at the first available offset,
1241 which is 40 + 472 = 512 blocks (256 kB).
1242 .Bd -literal -offset indent
1243 /sbin/gpart add -s 4G -t freebsd-swap ada0
1246 Aligning the swap partition and all subsequent partitions on a 256 kB
1247 boundary ensures optimal performance on a wide range of media, from
1248 plain old disks with 512-byte blocks, through modern
1250 disks with 4096-byte physical blocks, to RAID volumes with stripe
1251 sizes of up to 256 kB.
1253 Finally, we create and format an 8 GB
1255 partition for the root filesystem, leaving the rest of the slice free
1256 for additional filesystems:
1257 .Bd -literal -offset indent
1258 /sbin/gpart add -s 8G -t freebsd-ufs ada0
1259 /sbin/newfs -Uj /dev/ada0p3
1262 In this example, we will format
1264 with the MBR scheme and create a single partition which we subdivide
1269 First, we create the partition table and a single 64 GB partition,
1270 then we mark that partition active (bootable) and install the
1271 first-stage boot loader:
1272 .Bd -literal -offset indent
1273 /sbin/gpart create -s MBR ada0
1274 /sbin/gpart add -t freebsd -s 64G ada0
1275 /sbin/gpart set -a active -i 1 ada0
1276 /sbin/gpart bootcode -b /boot/boot0 ada0
1279 Next, we create a disklabel in that partition
1282 in disklabel terminology
1284 with room for up to 20 partitions:
1285 .Bd -literal -offset indent
1286 /sbin/gpart create -s BSD -n 20 ada0s1
1289 We then create an 8 GB root partition and a 4 GB swap partition:
1290 .Bd -literal -offset indent
1291 /sbin/gpart add -t freebsd-ufs -s 8G ada0s1
1292 /sbin/gpart add -t freebsd-swap -s 4G ada0s1
1295 Finally, we install the appropriate boot loader for the
1298 .Bd -literal -offset indent
1299 /sbin/gpart bootcode -b /boot/boot ada0s1
1303 Create a VTOC8 scheme on
1305 .Bd -literal -offset indent
1306 /sbin/gpart create -s VTOC8 da0
1309 Create a 512MB-sized
1311 partition to contain a UFS filesystem from which the system can boot.
1312 .Bd -literal -offset indent
1313 /sbin/gpart add -s 512M -t freebsd-ufs da0
1318 partition to contain a UFS filesystem and aligned on 4KB boundaries:
1319 .Bd -literal -offset indent
1320 /sbin/gpart add -s 15G -t freebsd-ufs -a 4k da0
1323 After creating all required partitions, embed bootstrap code into them:
1324 .Bd -literal -offset indent
1325 /sbin/gpart bootcode -p /boot/boot1 da0
1327 .Ss Backup and Restore
1329 Create a backup of the partition table from
1331 .Bd -literal -offset indent
1332 /sbin/gpart backup da0 > da0.backup
1335 Restore the partition table from the backup to
1337 .Bd -literal -offset indent
1338 /sbin/gpart restore -l da0 < /mnt/da0.backup
1341 Clone the partition table from
1347 .Bd -literal -offset indent
1348 /sbin/gpart backup ada0 | /sbin/gpart restore -F ada1 ada2
1361 .An Marcel Moolenaar Aq Mt marcel@FreeBSD.org