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"
34 To add support for the disk partitioning GEOM class,
35 place one or more of the following
36 lines in your kernel configuration file:
37 .Bd -ragged -offset indent
38 .Cd "options GEOM_PART_APM"
39 .Cd "options GEOM_PART_BSD"
40 .Cd "options GEOM_PART_EBR"
41 .Cd "options GEOM_PART_EBR_COMPAT"
42 .Cd "options GEOM_PART_GPT"
43 .Cd "options GEOM_PART_MBR"
44 .Cd "options GEOM_PART_PC98"
45 .Cd "options GEOM_PART_VTOC8"
50 option adds support for the Apple Partition Map (APM)
51 found on Apple Macintosh computers.
54 option adds support for the traditional
59 option adds support for the Extended Boot Record (EBR),
60 which is used to define a logical partition.
62 .Dv GEOM_PART_EBR_COMPAT
63 option enables backward compatibility for partition names
64 in the EBR scheme. Also it makes impossible any types of actions
68 option adds support for the GUID Partition Table (GPT)
69 found on Intel Itanium computers and Intel-based Macintosh computers.
72 option adds support for the Master Boot Record (MBR)
73 found on PCs and used on many removable media.
76 option adds support for the MBR variant as used on
80 option adds support for Sun's SMI VTOC8 label as
81 found on computers based on
105 .\" ==== BOOTCODE ====
109 .Op Fl p Ar partcode Fl i Ar index
129 .\" ==== DESTROY ====
143 .\" ==== RECOVER ====
152 .Op Fl a Ar alignment
156 .\" ==== RESTORE ====
190 utility is used to partition GEOM providers, normally disks.
191 The first argument of which is the action to be taken:
192 .Bl -tag -width ".Cm bootcode"
195 Add a new partition to the partitioning scheme given by
197 The partition begins on the logical block address given by the
200 Its size is given by the
202 option. SI unit suffixes are allowed. One or both
206 options can be ommitted. If so they are automatically calculated.
207 The type of the partition is given by the
210 Partition types are discussed below in the section entitled
211 .Sx "PARTITION TYPES" .
213 Additional options include:
215 .It Fl a Ar alignment
218 utility tries to align
226 The index in the partition table at which the new partition is to be
228 The index determines the name of the device special file used
229 to represent the partition.
231 The label attached to the partition.
232 This option is only valid when used on partitioning schemes that support
235 Additional operational flags.
236 See the section entitled
237 .Sx "OPERATIONAL FLAGS"
238 below for a discussion
243 Dump a partition table to standard output in special format used by
246 .\" ==== BOOTCODE ====
248 Embed bootstrap code into the partitioning scheme's metadata on the
252 or write bootstrap code into a partition (using
256 Not all partitioning schemes have embedded bootstrap code, so the
258 option is scheme-specific in nature (see the section entitled
263 option specifies a file that contains the bootstrap code.
264 The contents and size of the file are determined by the partitioning
268 option specifies a file that contains the bootstrap code intended to be
269 written to a partition.
270 The partition is specified by the
273 The size of the file must be smaller than the size of the partition.
275 Additional options include:
278 Additional operational flags.
279 See the section entitled
280 .Sx "OPERATIONAL FLAGS"
281 below for a discussion
286 Commit any pending changes for geom
288 All actions are being committed by default and will not result in
290 Actions can be modified with the
292 option so that they are not being committed by default.
293 As such, they become pending.
294 Pending changes are reflected by the geom and the
296 utility, but they are not actually written to disk.
299 action will write any and all pending changes to disk.
302 Create a new partitioning scheme on a provider given by
306 option determines the scheme to use.
307 The kernel needs to have support for a particular scheme before
308 that scheme can be used to partition a disk.
310 Additional options include:
313 The number of entries in the partition table.
314 Every partitioning scheme has a minimum and a maximum number of entries
315 and this option allows tables to be created with the number of entries
316 that lies anywhere between the minimum and the maximum.
317 Some schemes have a maximum equal to the minimum and some schemes have
318 a maximum large enough to be considered unlimited.
319 By default, partition tables are created with the minimum number of
322 Additional operational flags.
323 See the section entitled
324 .Sx "OPERATIONAL FLAGS"
325 below for a discussion
330 Delete a partition from geom
332 and further identified by the
335 The partition cannot be actively used by the kernel.
337 Additional options include:
340 Additional operational flags.
341 See the section entitled
342 .Sx "OPERATIONAL FLAGS"
343 below for a discussion
346 .\" ==== DESTROY ====
348 Destroy the partitioning scheme as implemented by geom
351 Additional options include:
354 Forced destroying of the partition table even if it is not empty.
\r
356 Additional operational flags.
357 See the section entitled
358 .Sx "OPERATIONAL FLAGS"
359 below for a discussion
364 Modify a partition from geom
366 and further identified by the
369 Only the type and/or label of the partition can be modified.
370 To change the type of a partition, specify the new type with the
373 To change the label of a partition, specify the new label with the
376 Not all partitioning schemes support labels and it is invalid to
377 try to change a partition label in such cases.
379 Additional options include:
382 Additional operational flags.
383 See the section entitled
384 .Sx "OPERATIONAL FLAGS"
385 below for a discussion
388 .\" ==== RECOVER ====
390 Recover corrupt partition's scheme metadata on the geom
392 See the section entitled
394 below for the additional information.
396 Additional options include:
399 Additional operational flags.
400 See the section entitled
401 .Sx "OPERATIONAL FLAGS"
402 below for a discussion
407 Resize a partition from geom
409 and further identified by the
412 New partition size is expressed in logical block
413 numbers and can be given by the
418 option is omitted then new size is automatically calculated
419 to maximum available from given geom
422 Additional options include:
424 .It Fl a Ar alignment
427 utility tries to align partition
433 Additional operational flags.
434 See the section entitled
435 .Sx "OPERATIONAL FLAGS"
436 below for a discussion
439 .\" ==== RESTORE ====
441 Restore the partition table from backup previously created by
443 action and given from standard input.
444 Only partition table may be restored.
445 This action does not affect content of partitions.
446 This mean that you should copy your data from backup after restoring
447 partition table and write bootcode again if it is needed.
449 Additional options include:
452 Destroy partition table on the given
454 before doing restore.
456 Restore partition labels for partitioning schemes that support them.
458 Additional operational flags.
459 See the section entitled
460 .Sx "OPERATIONAL FLAGS"
461 below for a discussion
466 Set the named attribute on the partition entry.
467 See the section entitled
469 below for a list of available attributes.
471 Additional options include:
474 Additional operational flags.
475 See the section entitled
476 .Sx "OPERATIONAL FLAGS"
477 below for a discussion
482 Show the current partition information of the specified geoms
483 or all geoms if none are specified.
484 Additional options include:
487 For partition schemes that support partition labels print them
488 instead of partition type.
490 Show provider names instead of partition indexes.
492 Show raw partition type instead of symbolic name.
496 Revert any pending changes for geom
498 This action is the opposite of the
500 action and can be used to undo any changes that have not been committed.
503 Clear the named attribute on the partition entry.
504 See the section entitled
506 below for a list of available attributes.
508 Additional options include:
511 Additional operational flags.
512 See the section entitled
513 .Sx "OPERATIONAL FLAGS"
514 below for a discussion
520 Partition types are identified on disk by particular strings or magic
524 utility uses symbolic names for common partition types to avoid the
525 user needing to know these values or other details of the partitioning
529 utility also allows the user to specify scheme-specific partition types
530 for partition types that do not have symbolic names.
531 The symbolic names currently understood are:
532 .Bl -tag -width ".Cm freebsd-vinum"
534 The system partition dedicated to second stage of the boot loader program.
535 Usually it used by GRUB 2 loader when the partition table is GPT.
536 The scheme-specific type is
537 .Qq Li "!21686148-6449-6E6F-744E-656564454649" .
539 The system partition for computers that use the Extensible Firmware
541 In such cases, the GPT partitioning scheme is being used and the
542 actual partition type for the system partition can also be specified as
543 .Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93ab" .
547 partition that uses the
549 disklabel to sub-divide the
550 partition into file systems.
551 This is a legacy partition type and should not be used for the APM
553 The scheme-specific types are
558 .Qq Li "!516e7cb4-6ecf-11d6-8ff8-00022d09712b"
563 partition dedicated to bootstrap code.
564 The scheme-specific type is
565 .Qq Li "!83bd6b9d-7f41-11dc-be0b-001560b84f0f"
570 partition dedicated to swap space.
571 The scheme-specific types are
572 .Qq Li "!FreeBSD-swap"
574 .Qq Li "!516e7cb5-6ecf-11d6-8ff8-00022d09712b"
575 for GPT, and tag 0x0901 for VTOC8.
579 partition that contains a UFS or UFS2 file system.
580 The scheme-specific types are
581 .Qq Li "!FreeBSD-UFS"
583 .Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b"
584 for GPT, and tag 0x0902 for VTOC8.
588 partition that contains a Vinum volume.
589 The scheme-specific types are
590 .Qq Li "!FreeBSD-Vinum"
592 .Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b"
593 for GPT, and tag 0x0903 for VTOC8.
597 partition that contains a ZFS volume.
598 The scheme-specific types are
599 .Qq Li "!FreeBSD-ZFS"
601 .Qq Li "!516e7cba-6ecf-11d6-8ff8-00022d09712b"
602 for GPT, and 0x0904 for VTOC8.
604 A partition that is sub-partitioned by a master boot record (MBR).
605 This type is known as
606 .Qq Li "!024dee41-33e7-11d3-9d69-0008c781f39f"
610 The scheme-specific attributes for EBR:
611 .Bl -tag -width ".Ar active"
615 The scheme-specific attributes for GPT:
616 .Bl -tag -width ".Ar bootfailed"
620 stage 1 boot loader will try to boot the system from this partition.
621 Multiple partitions might be marked with the
628 partitions one by one, until the next boot stage is successfully entered.
630 Setting this attribute automatically sets the
635 stage 1 boot loader will try to boot the system from this partition only once.
640 attributes are tried before partitions with only the
645 partition is tried, the
649 attribute and tries to execute the next boot stage.
652 attribute that is now alone is replaced with the
655 If the execution of the next boot stage succeeds, but the system is not fully
660 attributes alone (without the
662 attribute) on the next system boot and will replace those with the
665 If the system is fully booted, the
666 .Pa /etc/rc.d/gptboot
667 start-up script will look for partition with the
669 attribute alone, will remove the attribute and log that the system was
670 successfully booted from this partition.
671 There should be at most one
673 partition when system is successfully booted.
674 Multiple partitions might be marked with the
680 This attribute should not be manually managed.
683 stage 1 boot loader and the
684 .Pa /etc/rc.d/gptboot
686 This attribute is used to mark partitions that had the
688 attribute set, but we failed to boot from them.
689 Once we successfully boot, the
690 .Pa /etc/rc.d/gptboot
691 script will log all the partitions we failed to boot from and will remove the
696 The scheme-specific attributes for MBR:
697 .Bl -tag -width ".Ar active"
701 The scheme-specific attributes for PC98:
702 .Bl -tag -width ".Ar bootable"
708 supports several partitioning schemes and each scheme uses different
710 The bootstrap code is located in the specific disk area for each partitioning
711 scheme and also it might have different size.
713 The bootstrap code could be separated into two types.
714 The first one is embedded in the partitioning scheme's metadata, the second
715 type is located on the specific partition.
716 The embedding bootstrap code should be done only with the
721 The GEOM PART class has knowlege on how to embed bootstrap code into specific
722 partitioning scheme metadata without damage.
724 The Master Boot Record (MBR) uses 512-bytes bootstrap code image, embedded into
725 partition table's metadata area.
726 There are two variants of this bootstrap code:
730 The first one searches partition with
734 section) in the partition table.
735 Then it runs next bootstrap stage.
738 image contains a boot manager with some additional interactive functions.
740 The BSD disklabel is usually created on top of the MBR partition (slice)
744 .Sx "PARTITION TYPES"
746 It uses 8 KB size bootstrap code image
748 embedded into partition table's metadata area.
750 Both types of bootstrap code are used to boot from the GUID Partition Table.
751 First of all, a protective MBR is embedded into first disk sector from the
757 .Sx "PARTITION TYPES"
758 section) in the GPT and runs next bootstrap stage from it.
761 partition should be smaller than 545 KB.
762 There are two variants of bootstrap code to write to this partition:
765 .Pa /boot/gptzfsboot .
766 The first one is used to boot from UFS.
767 It searches in the GPT partition with type
769 and it runs the third bootstrap stage (
774 is used to boot from ZFS.
775 It searches partition with type
781 The VTOC8 scheme does not support embedding bootstrap code.
782 Instead, the 8 KBytes bootstrap code image
784 should be written with
788 option to all sufficiently large VTOC8 partitions.
791 option could be ommited.
793 The APM scheme also does not support embedding bootstrap code.
794 Instead, the 800 KBytes bootstrap code image
796 should be written with
798 command to a partition of type
800 which should also be 800 KB in size.
801 .Sh OPERATIONAL FLAGS
802 Actions other than the
806 actions take an optional
809 This option is used to specify action-specific operational flags.
814 flag so that the action is immediately
818 to have the action result in a pending change that can later, with
819 other pending changes, be committed as a single compound change with
822 action or reverted with the
826 The GEOM PART class supports recovering of partition tables only for GPT.
827 The GUID partition table has a primary and secondary (backup) copy of
828 metadata for redundance, these are stored at the begining and the end
829 of the device respectively.
830 As a result of having two copies, it is acceptable to have some corruption
831 within the metadata that is not fatal to the working of GPT.
832 When the kernel detects corrupt metadata it marks this table as corrupt and
833 reports the corruption.
834 Any operations on corrupt tables are prohibited except for
839 If the first sector of a provider is corrupt, the kernel can not detect GPT
840 even if partition table itself is not corrupt.
841 You can rewrite the protective MBR using the
843 command, to restore the ability to detect the GPT.
844 The copy of the protective MBR is usually located in the
848 If one GPT header appears to be corrupt but the other copy remains intact,
849 the kernel will log the following:
850 .Bd -literal -offset indent
851 GEOM: provider: the primary GPT table is corrupt or invalid.
852 GEOM: provider: using the secondary instead -- recovery strongly advised.
856 .Bd -literal -offset indent
857 GEOM: provider: the secondary GPT table is corrupt or invalid.
858 GEOM: provider: using the primary only -- recovery suggested.
867 will report about corrupt tables.
869 If the size of the device has changed (e.g.\& volume expansion) the
870 secondary GPT header will no longer be located in the last sector.
871 This is not a metadata corruption, but it is dangerous because any
872 corruption of the primary GPT will lead to loss of partition table.
873 This problem is reported by the kernel with the message:
874 .Bd -literal -offset indent
875 GEOM: provider: the secondary GPT header is not in the last LBA.
878 This situation can be recovered with the
881 This command reconstructs the corrupt metadata using known valid
882 metadata and relocates the secondary GPT to the end of the device.
885 The GEOM PART class can detect the same partition table visible through
886 different GEOM providers, and some of them will be marked as corrupt.
887 Be careful when choosing a provider for recovery.
888 If you choose incorrectly you can destroy the metadata of another GEOM class,
889 e.g.\& GEOM MIRROR or GEOM LABEL.
891 Exit status is 0 on success, and 1 if the command fails.
895 .Bd -literal -offset indent
896 /sbin/gpart create -s GPT ad0
899 Embed GPT bootstrap code into protective MBR.
900 .Bd -literal -offset indent
901 /sbin/gpart bootcode -b /boot/pmbr ad0
906 partition that can boot
910 partition, and install bootstrap code into it.
911 This partition must be larger than
913 or the GPT boot you are planning to write, but smaller than 545 KB.
914 A size of 15 blocks (7680 bytes) would be sufficient for
915 booting from UFS but let's use 128 blocks (64 KB) here in
916 this example, in order to reserve some space for potential
917 future need (e.g.\& from a ZFS partition).
918 .Bd -literal -offset indent
919 /sbin/gpart add -b 34 -s 128 -t freebsd-boot ad0
920 /sbin/gpart bootcode -p /boot/gptboot -i 1 ad0
925 partition that would contain UFS where the system boots from.
926 .Bd -literal -offset indent
927 /sbin/gpart add -b 162 -s 1048576 -t freebsd-ufs ad0
930 Create VTOC8 scheme on
932 .Bd -literal -offset indent
933 /sbin/gpart create -s VTOC8 da0
938 partition that would contain UFS where the system boots from.
939 .Bd -literal -offset indent
940 /sbin/gpart add -s 512M -t freebsd-ufs da0
945 partition that would contain UFS and aligned on 4KB boundaries:
946 .Bd -literal -offset indent
947 /sbin/gpart add -s 15G -t freebsd-ufs -a 4k da0
950 After having created all required partitions, embed bootstrap code into them.
951 .Bd -literal -offset indent
952 /sbin/gpart bootcode -p /boot/boot1 da0
955 Create backup of partition table from
957 .Bd -literal -offset indent
958 /sbin/gpart backup da0 > da0.backup
961 Restore partition table from backup to
963 .Bd -literal -offset indent
964 /sbin/gpart restore -l da0 < /mnt/da0.backup
967 Clone partition table from
973 .Bd -literal -offset indent
974 /sbin/gpart backup ada0 | /sbin/gpart restore -F ada1 ada2
987 .An Marcel Moolenaar Aq marcel@FreeBSD.org