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
104 .\" ==== BOOTCODE ====
108 .Op Fl p Ar partcode Fl i Ar index
128 .\" ==== DESTROY ====
142 .\" ==== RECOVER ====
154 .\" ==== RESTORE ====
188 utility is used to partition GEOM providers, normally disks.
189 The first argument of which is the action to be taken:
190 .Bl -tag -width ".Cm bootcode"
193 Add a new partition to the partitioning scheme given by
195 The partition begins on the logical block address given by the
198 Its size is given by the
200 option. SI unit suffixes are allowed. One or both
204 options can be ommitted. If so they are automatically calculated.
205 The type of the partition is given by the
208 Partition types are discussed below in the section entitled
209 .Sx "PARTITION TYPES" .
211 Additional options include:
214 The index in the partition table at which the new partition is to be
216 The index determines the name of the device special file used
217 to represent the partition.
219 The label attached to the partition.
220 This option is only valid when used on partitioning schemes that support
223 Additional operational flags.
224 See the section entitled
225 .Sx "OPERATIONAL FLAGS"
226 below for a discussion
231 Dump a partition table to standard output in special format used by
234 .\" ==== BOOTCODE ====
236 Embed bootstrap code into the partitioning scheme's metadata on the
240 or write bootstrap code into a partition (using
244 Not all partitioning schemes have embedded bootstrap code, so the
246 option is scheme-specific in nature.
247 For the GPT scheme, embedded bootstrap code is supported.
248 The bootstrap code is embedded in the protective MBR rather than the GPT.
251 option specifies a file that contains the bootstrap code.
252 The contents and size of the file are determined by the partitioning
254 For the MBR scheme, it is a 512 byte file of which the first 446 bytes
255 are installed as bootstrap code.
258 option specifies a file that contains the bootstrap code intended to be
259 written to a partition.
260 For the VTOC8 scheme, it is a 8192 byte file of which the last 7680 bytes
261 are installed as bootstrap code.
262 The partition is specified by the
265 For the VTOC8 scheme, if the
267 option is omitted, the bootstrap code is written to all sufficiently large
269 The size of the file must be smaller than the size of the partition.
271 Additional options include:
274 Additional operational flags.
275 See the section entitled
276 .Sx "OPERATIONAL FLAGS"
277 below for a discussion
282 Commit any pending changes for geom
284 All actions are being committed by default and will not result in
286 Actions can be modified with the
288 option so that they are not being committed by default.
289 As such, they become pending.
290 Pending changes are reflected by the geom and the
292 utility, but they are not actually written to disk.
295 action will write any and all pending changes to disk.
298 Create a new partitioning scheme on a provider given by
302 option determines the scheme to use.
303 The kernel needs to have support for a particular scheme before
304 that scheme can be used to partition a disk.
306 Additional options include:
309 The number of entries in the partition table.
310 Every partitioning scheme has a minimum and a maximum number of entries
311 and this option allows tables to be created with the number of entries
312 that lies anywhere between the minimum and the maximum.
313 Some schemes have a maximum equal to the minimum and some schemes have
314 a maximum large enough to be considered unlimited.
315 By default, partition tables are created with the minimum number of
318 Additional operational flags.
319 See the section entitled
320 .Sx "OPERATIONAL FLAGS"
321 below for a discussion
326 Delete a partition from geom
328 and further identified by the
331 The partition cannot be actively used by the kernel.
333 Additional options include:
336 Additional operational flags.
337 See the section entitled
338 .Sx "OPERATIONAL FLAGS"
339 below for a discussion
342 .\" ==== DESTROY ====
344 Destroy the partitioning scheme as implemented by geom
347 Additional options include:
350 Forced destroying of the partition table even if it is not empty.
\r
352 Additional operational flags.
353 See the section entitled
354 .Sx "OPERATIONAL FLAGS"
355 below for a discussion
360 Modify a partition from geom
362 and further identified by the
365 Only the the type and/or label of the partition can be modified.
366 To change the type of a partition, specify the new type with the
369 To change the label of a partition, specify the new label with the
372 Not all partitioning schemes support labels and it is invalid to
373 try to change a partition label in such cases.
375 Additional options include:
378 Additional operational flags.
379 See the section entitled
380 .Sx "OPERATIONAL FLAGS"
381 below for a discussion
384 .\" ==== RECOVER ====
386 Recover corrupt partition's scheme metadata on the geom
388 See the section entitled
390 below for the additional information.
392 Additional options include:
395 Additional operational flags.
396 See the section entitled
397 .Sx "OPERATIONAL FLAGS"
398 below for a discussion
403 Resize a partition from geom
405 and further identified by the
408 New partition size is expressed in logical block
409 numbers and can be given by the
414 option is omitted then new size is automatically calculated
415 to maximum available from given geom
418 Additional options include:
421 Additional operational flags.
422 See the section entitled
423 .Sx "OPERATIONAL FLAGS"
424 below for a discussion
427 .\" ==== RESTORE ====
429 Restore the partition table from backup previously created by
431 action and given from standard input.
432 Only partition table may be restored.
433 This action does not affect content of partitions.
434 This mean that you should copy your data from backup after restoring
435 partition table and write bootcode again if it is needed.
437 Additional options include:
440 Destroy partition table on the given
442 before doing restore.
444 Restore partition labels for partitioning schemes that support them.
446 Additional operational flags.
447 See the section entitled
448 .Sx "OPERATIONAL FLAGS"
449 below for a discussion
454 Set the named attribute on the partition entry.
455 See the section entitled
457 below for a list of available attributes.
459 Additional options include:
462 Additional operational flags.
463 See the section entitled
464 .Sx "OPERATIONAL FLAGS"
465 below for a discussion
470 Show the current partition information of the specified geoms
471 or all geoms if none are specified.
472 Additional options include:
475 For partition schemes that support partition labels print them
476 instead of partition type.
478 Show provider names instead of partition indexes.
480 Show raw partition type instead of symbolic name.
484 Revert any pending changes for geom
486 This action is the opposite of the
488 action and can be used to undo any changes that have not been committed.
491 Clear the named attribute on the partition entry.
492 See the section entitled
494 below for a list of available attributes.
496 Additional options include:
499 Additional operational flags.
500 See the section entitled
501 .Sx "OPERATIONAL FLAGS"
502 below for a discussion
510 utility uses symbolic names for common partition types to avoid that the
511 user needs to know what the partitioning scheme in question is and what
512 the actual number or identification needs to be used for a particular
516 utility also allows the user to specify scheme-specific partition types
517 for partition types that do not have symbol names.
518 The symbolic names currently understood are:
519 .Bl -tag -width ".Cm freebsd-vinum"
521 The system partition dedicated to second stage of the boot loader program.
522 Usually it used by GRUB 2 loader when the partition table is GPT.
523 The scheme-specific type is
524 .Qq Li "!21686148-6449-6E6F-744E-656564454649" .
526 The system partition for computers that use the Extensible Firmware
528 In such cases, the GPT partitioning scheme is being used and the
529 actual partition type for the system partition can also be specified as
530 .Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93ab" .
534 partition that uses the
536 disklabel to sub-divide the
537 partition into file systems.
538 This is a legacy partition type and should not be used for the APM
540 The scheme-specific types are
545 .Qq Li "!516e7cb4-6ecf-11d6-8ff8-00022d09712b"
550 partition dedicated to bootstrap code.
551 The scheme-specific type is
552 .Qq Li "!83bd6b9d-7f41-11dc-be0b-001560b84f0f"
557 partition dedicated to swap space.
558 The scheme-specific types are
559 .Qq Li "!FreeBSD-swap"
561 .Qq Li "!516e7cb5-6ecf-11d6-8ff8-00022d09712b"
562 for GPT, and tag 0x0901 for VTOC8.
566 partition that contains a UFS or UFS2 file system.
567 The scheme-specific types are
568 .Qq Li "!FreeBSD-UFS"
570 .Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b"
571 for GPT, and tag 0x0902 for VTOC8.
575 partition that contains a Vinum volume.
576 The scheme-specific types are
577 .Qq Li "!FreeBSD-Vinum"
579 .Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b"
580 for GPT, and tag 0x0903 for VTOC8.
584 partition that contains a ZFS volume.
585 The scheme-specific types are
586 .Qq Li "!FreeBSD-ZFS"
588 .Qq Li "!516e7cba-6ecf-11d6-8ff8-00022d09712b"
589 for GPT, and 0x0904 for VTOC8.
591 A partition that is sub-partitioned by a master boot record (MBR).
592 This type is known as
593 .Qq Li "!024dee41-33e7-11d3-9d69-0008c781f39f"
597 The scheme-specific attributes for EBR:
598 .Bl -tag -width ".Ar active"
602 The scheme-specific attributes for GPT:
603 .Bl -tag -width ".Ar bootfailed"
607 stage 1 boot loader will try to boot the system from this partition.
608 Multiple partitions might be marked with the
615 partitions one by one, until the next boot stage is successfully entered.
617 Setting this attribute automatically sets the
622 stage 1 boot loader will try to boot the system from this partition only once.
627 attributes are tried before partitions with only the
632 partition is tried, the
636 attribute and tries to execute the next boot stage.
639 attribute that is now alone is replaced with the
642 If the execution of the next boot stage succeeds, but the system is not fully
647 attributes alone (without the
649 attribute) on the next system boot and will replace those with the
652 If the system is fully booted, the
653 .Pa /etc/rc.d/gptboot
654 start-up script will look for partition with the
656 attribute alone, will remove the attribute and log that the system was
657 successfully booted from this partition.
658 There should be at most one
660 partition when system is successfully booted.
661 Multiple partitions might be marked with the
667 This attribute should not be manually managed.
670 stage 1 boot loader and the
671 .Pa /etc/rc.d/gptboot
673 This attribute is used to mark partitions that had the
675 attribute set, but we failed to boot from them.
676 Once we successfully boot, the
677 .Pa /etc/rc.d/gptboot
678 script will log all the partitions we failed to boot from and will remove the
683 The scheme-specific attributes for MBR:
684 .Bl -tag -width ".Ar active"
688 The scheme-specific attributes for PC98:
689 .Bl -tag -width ".Ar bootable"
693 .Sh OPERATIONAL FLAGS
694 Actions other than the
698 actions take an optional
701 This option is used to specify action-specific operational flags.
706 flag so that the action is immediately
710 to have the action result in a pending change that can later, with
711 other pending changes, be committed as a single compound change with
714 action or reverted with the
718 The GEOM class PART supports recovering of partition tables only for GPT.
719 The GUID partition table has a primary and secondary (backup) copy of
720 metadata for redundance.
721 They are stored in the begining and in the end of device respectively.
722 Therefore it is acceptable to have some corruptions in the metadata that
723 are not fatal to work with GPT.
724 When kernel detects corrupt metadata it marks this table as corrupt and
725 reports about corruption.
726 Any changes in corrupt table are prohibited except
731 In case when only first sector is corrupt kernel can not detect GPT even
732 if partition table is not corrupt.
733 You can write protective MBR with
735 command to restore ability of GPT detection.
736 The copy of protective MBR is usually located in the
740 In case when some of metadata is corrupt you will get to know about this
741 from kernel's messages like these:
742 .Bd -literal -offset indent
743 GEOM: provider: the primary GPT table is corrupt or invalid.
744 GEOM: provider: using the secondary instead -- recovery strongly advised.
748 .Bd -literal -offset indent
749 GEOM: provider: the secondary GPT table is corrupt or invalid.
750 GEOM: provider: using the primary only -- recovery suggested.
760 will report about corrupt table.
762 In case when the size of device has changed (e.g. volume expansion) the
763 secondary GPT header will become located not in the last sector.
764 This is not a metadata corruption, but it is dangerous because any
765 corruption of the primary GPT will lead to lost of partition table.
766 Kernel reports about this problem with message:
767 .Bd -literal -offset indent
768 GEOM: provider: the secondary GPT header is not in the last LBA.
771 A corrupt table can be recovered with
774 This command does reconstruction of corrupt metadata using
775 known valid metadata.
776 Also it can relocate secondary GPT to the end of device.
779 The GEOM class PART can detect the same partition table on different GEOM
780 providers and some of them will be marked as corrupt.
781 Be careful when choosing a provider for recovering.
782 If you choose incorrectly you can destroy the metadata of another GEOM class,
783 e.g. GEOM MIRROR or GEOM LABEL.
785 Exit status is 0 on success, and 1 if the command fails.
789 .Bd -literal -offset indent
790 /sbin/gpart create -s GPT ad0
793 Embed GPT bootstrap code into protective MBR.
794 .Bd -literal -offset indent
795 /sbin/gpart bootcode -b /boot/pmbr ad0
800 partition that can boot
804 partition, and install bootstrap code into it.
805 This partition must be larger than
807 or the GPT boot you are planning to write, but smaller than 545 KB.
808 A size of 15 blocks (7680 bytes) would be sufficient for
809 booting from UFS but let's use 128 blocks (64 KB) here in
810 this example, in order to reserve some space for potential
811 future need (e.g.\& from a ZFS partition).
812 .Bd -literal -offset indent
813 /sbin/gpart add -b 34 -s 128 -t freebsd-boot ad0
814 /sbin/gpart bootcode -p /boot/gptboot -i 1 ad0
819 partition that would contain UFS where the system boots from.
820 .Bd -literal -offset indent
821 /sbin/gpart add -b 162 -s 1048576 -t freebsd-ufs ad0
824 Create VTOC8 scheme on
826 .Bd -literal -offset indent
827 /sbin/gpart create -s VTOC8 da0
832 partition that would contain UFS where the system boots from.
833 .Bd -literal -offset indent
834 /sbin/gpart add -s 512M -t freebsd-ufs da0
837 After having created all required partitions, embed bootstrap code into them.
838 .Bd -literal -offset indent
839 /sbin/gpart bootcode -p /boot/boot1 da0
842 Create backup of partition table from
844 .Bd -literal -offset indent
845 /sbin/gpart backup da0 > da0.backup
848 Restore partition table from backup to
850 .Bd -literal -offset indent
851 /sbin/gpart restore -l da0 < /mnt/da0.backup
854 Clone partition table from
860 .Bd -literal -offset indent
861 /sbin/gpart backup ada0 | /sbin/gpart restore -F ada1 ada2
873 .An Marcel Moolenaar Aq marcel@FreeBSD.org