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_GPT"
42 .Cd "options GEOM_PART_MBR"
43 .Cd "options GEOM_PART_PC98"
44 .Cd "options GEOM_PART_VTOC8"
49 option adds support for the Apple Partition Map (APM)
50 found on Apple Macintosh computers.
53 option adds support for the traditional
58 option adds support for the Extended Boot Record (EBR),
59 which is used to define a logical partition.
62 option adds support for the GUID Partition Table (GPT)
63 found on Intel Itanium computers and Intel-based Macintosh computers.
66 option adds support for the Master Boot Record (MBR)
67 found on PCs and used on many removable media.
70 option adds support for the MBR variant as used on
74 option adds support for Sun's SMI VTOC8 label as
75 found on computers based on
98 .\" ==== BOOTCODE ====
102 .Op Fl p Ar partcode Fl i Ar index
122 .\" ==== DESTROY ====
136 .\" ==== RECOVER ====
148 .\" ==== RESTORE ====
182 utility is used to partition GEOM providers, normally disks.
183 The first argument of which is the action to be taken:
184 .Bl -tag -width ".Cm bootcode"
187 Add a new partition to the partitioning scheme given by
189 The partition begins on the logical block address given by the
192 Its size is given by the
194 option. SI unit suffixes are allowed. One or both
198 options can be ommitted. If so they are automatically calculated.
199 The type of the partition is given by the
202 Partition types are discussed below in the section entitled
203 .Sx "PARTITION TYPES" .
205 Additional options include:
208 The index in the partition table at which the new partition is to be
210 The index determines the name of the device special file used
211 to represent the partition.
213 The label attached to the partition.
214 This option is only valid when used on partitioning schemes that support
217 Additional operational flags.
218 See the section entitled
219 .Sx "OPERATIONAL FLAGS"
220 below for a discussion
225 Dump a partition table to standard output in special format used by
228 .\" ==== BOOTCODE ====
230 Embed bootstrap code into the partitioning scheme's metadata on the
234 or write bootstrap code into a partition (using
238 Not all partitioning schemes have embedded bootstrap code, so the
240 option is scheme-specific in nature.
241 For the GPT scheme, embedded bootstrap code is supported.
242 The bootstrap code is embedded in the protective MBR rather than the GPT.
245 option specifies a file that contains the bootstrap code.
246 The contents and size of the file are determined by the partitioning
248 For the MBR scheme, it is a 512 byte file of which the first 446 bytes
249 are installed as bootstrap code.
252 option specifies a file that contains the bootstrap code intended to be
253 written to a partition.
254 For the VTOC8 scheme, it is a 8192 byte file of which the last 7680 bytes
255 are installed as bootstrap code.
256 The partition is specified by the
259 For the VTOC8 scheme, if the
261 option is omitted, the bootstrap code is written to all sufficiently large
263 The size of the file must be smaller than the size of the partition.
265 Additional options include:
268 Additional operational flags.
269 See the section entitled
270 .Sx "OPERATIONAL FLAGS"
271 below for a discussion
276 Commit any pending changes for geom
278 All actions are being committed by default and will not result in
280 Actions can be modified with the
282 option so that they are not being committed by default.
283 As such, they become pending.
284 Pending changes are reflected by the geom and the
286 utility, but they are not actually written to disk.
289 action will write any and all pending changes to disk.
292 Create a new partitioning scheme on a provider given by
296 option determines the scheme to use.
297 The kernel needs to have support for a particular scheme before
298 that scheme can be used to partition a disk.
300 Additional options include:
303 The number of entries in the partition table.
304 Every partitioning scheme has a minimum and a maximum number of entries
305 and this option allows tables to be created with the number of entries
306 that lies anywhere between the minimum and the maximum.
307 Some schemes have a maximum equal to the minimum and some schemes have
308 a maximum large enough to be considered unlimited.
309 By default, partition tables are created with the minimum number of
312 Additional operational flags.
313 See the section entitled
314 .Sx "OPERATIONAL FLAGS"
315 below for a discussion
320 Delete a partition from geom
322 and further identified by the
325 The partition cannot be actively used by the kernel.
327 Additional options include:
330 Additional operational flags.
331 See the section entitled
332 .Sx "OPERATIONAL FLAGS"
333 below for a discussion
336 .\" ==== DESTROY ====
338 Destroy the partitioning scheme as implemented by geom
341 Additional options include:
344 Forced destroying of the partition table even if it is not empty.
\r
346 Additional operational flags.
347 See the section entitled
348 .Sx "OPERATIONAL FLAGS"
349 below for a discussion
354 Modify a partition from geom
356 and further identified by the
359 Only the the type and/or label of the partition can be modified.
360 To change the type of a partition, specify the new type with the
363 To change the label of a partition, specify the new label with the
366 Not all partitioning schemes support labels and it is invalid to
367 try to change a partition label in such cases.
369 Additional options include:
372 Additional operational flags.
373 See the section entitled
374 .Sx "OPERATIONAL FLAGS"
375 below for a discussion
378 .\" ==== RECOVER ====
380 Recover corrupt partition's scheme metadata on the geom
382 See the section entitled
384 below for the additional information.
386 Additional options include:
389 Additional operational flags.
390 See the section entitled
391 .Sx "OPERATIONAL FLAGS"
392 below for a discussion
397 Resize a partition from geom
399 and further identified by the
402 New partition size is expressed in logical block
403 numbers and can be given by the
408 option is omitted then new size is automatically calculated
409 to maximum available from given geom
412 Additional options include:
415 Additional operational flags.
416 See the section entitled
417 .Sx "OPERATIONAL FLAGS"
418 below for a discussion
421 .\" ==== RESTORE ====
423 Restore the partition table from backup previously created by
425 action and given from standard input. Only partition table
426 may be restored. This action does not affect content of partitions.
427 This mean that you should copy your data from backup after restoring
428 partition table and write bootcode again if it is needed.
430 Additional options include:
433 Destroy partition table on the given
435 before doing restore.
437 Restore partition labels for partitioning schemes that support them.
439 Additional operational flags.
440 See the section entitled
441 .Sx "OPERATIONAL FLAGS"
442 below for a discussion
447 Set the named attribute on the partition entry.
448 See the section entitled
450 below for a list of available attributes.
452 Additional options include:
455 Additional operational flags.
456 See the section entitled
457 .Sx "OPERATIONAL FLAGS"
458 below for a discussion
463 Show the current partition information of the specified geoms
464 or all geoms if none are specified.
465 Additional options include:
468 For partition schemes that support partition labels print them
469 instead of partition type.
471 Show raw partition type instead of symbolic name.
475 Revert any pending changes for geom
477 This action is the opposite of the
479 action and can be used to undo any changes that have not been committed.
482 Clear the named attribute on the partition entry.
483 See the section entitled
485 below for a list of available attributes.
487 Additional options include:
490 Additional operational flags.
491 See the section entitled
492 .Sx "OPERATIONAL FLAGS"
493 below for a discussion
501 utility uses symbolic names for common partition types to avoid that the
502 user needs to know what the partitioning scheme in question is and what
503 the actual number or identification needs to be used for a particular
507 utility also allows the user to specify scheme-specific partition types
508 for partition types that do not have symbol names.
509 The symbolic names currently understood are:
510 .Bl -tag -width ".Cm freebsd-vinum"
512 The system partition for computers that use the Extensible Firmware
514 In such cases, the GPT partitioning scheme is being used and the
515 actual partition type for the system partition can also be specified as
516 .Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93ab" .
520 partition that uses the
522 disklabel to sub-divide the
523 partition into file systems.
524 This is a legacy partition type and should not be used for the APM
526 The scheme-specific types are
531 .Qq Li "!516e7cb4-6ecf-11d6-8ff8-00022d09712b"
536 partition dedicated to bootstrap code.
537 The scheme-specific type is
538 .Qq Li "!83bd6b9d-7f41-11dc-be0b-001560b84f0f"
543 partition dedicated to swap space.
544 The scheme-specific types are
545 .Qq Li "!FreeBSD-swap"
547 .Qq Li "!516e7cb5-6ecf-11d6-8ff8-00022d09712b"
548 for GPT, and tag 0x0901 for VTOC8.
552 partition that contains a UFS or UFS2 file system.
553 The scheme-specific types are
554 .Qq Li "!FreeBSD-UFS"
556 .Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b"
557 for GPT, and tag 0x0902 for VTOC8.
561 partition that contains a Vinum volume.
562 The scheme-specific types are
563 .Qq Li "!FreeBSD-Vinum"
565 .Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b"
566 for GPT, and tag 0x0903 for VTOC8.
570 partition that contains a ZFS volume.
571 The scheme-specific types are
572 .Qq Li "!FreeBSD-ZFS"
574 .Qq Li "!516e7cba-6ecf-11d6-8ff8-00022d09712b"
575 for GPT, and 0x0904 for VTOC8.
577 A partition that is sub-partitioned by a master boot record (MBR).
578 This type is known as
579 .Qq Li "!024dee41-33e7-11d3-9d69-0008c781f39f"
583 The scheme-specific attributes for EBR:
584 .Bl -tag -width ".Ar active"
588 The scheme-specific attributes for GPT:
589 .Bl -tag -width ".Ar bootfailed"
593 stage 1 boot loader will try to boot the system from this partition.
594 Multiple partitions might be marked with the
601 partitions one by one, until the next boot stage is successfully entered.
603 Setting this attribute automatically sets the
608 stage 1 boot loader will try to boot the system from this partition only once.
613 attributes are tried before partitions with only the
618 partition is tried, the
622 attribute and tries to execute the next boot stage.
625 attribute that is now alone is replaced with the
628 If the execution of the next boot stage succeeds, but the system is not fully
633 attributes alone (without the
635 attribute) on the next system boot and will replace those with the
638 If the system is fully booted, the
639 .Pa /etc/rc.d/gptboot
640 start-up script will look for partition with the
642 attribute alone, will remove the attribute and log that the system was
643 successfully booted from this partition.
644 There should be at most one
646 partition when system is successfully booted.
647 Multiple partitions might be marked with the
653 This attribute should not be manually managed.
656 stage 1 boot loader and the
657 .Pa /etc/rc.d/gptboot
659 This attribute is used to mark partitions that had the
661 attribute set, but we failed to boot from them.
662 Once we successfully boot, the
663 .Pa /etc/rc.d/gptboot
664 script will log all the partitions we failed to boot from and will remove the
669 The scheme-specific attributes for MBR:
670 .Bl -tag -width ".Ar active"
674 The scheme-specific attributes for PC98:
675 .Bl -tag -width ".Ar bootable"
679 .Sh OPERATIONAL FLAGS
680 Actions other than the
684 actions take an optional
687 This option is used to specify action-specific operational flags.
692 flag so that the action is immediately
696 to have the action result in a pending change that can later, with
697 other pending changes, be committed as a single compound change with
700 action or reverted with the
704 The GEOM class PART supports recovering of partition tables only for GPT.
705 The GUID partition table has a primary and secondary (backup) copy of
706 metadata for redundance. They are stored in the begining and in the end
707 of device respectively. Therefore it is acceptable to have some corruptions
708 in the metadata that are not fatal to work with GPT. When kernel detects
709 corrupt metadata it marks this table as corrupt and reports about corruption.
710 Any changes in corrupt table are prohibited except
715 In case when only first sector is corrupt kernel can not detect GPT even
716 if partition table is not corrupt. You can write protective MBR with
718 command to restore ability of GPT detection. The copy of protective MBR is
719 usually located in the
723 In case when some of metadata is corrupt you will get to know about this
724 from kernel's messages like these:
725 .Bd -literal -offset indent
726 GEOM: provider: the primary GPT table is corrupt or invalid.
727 GEOM: provider: using the secondary instead -- recovery strongly advised.
731 .Bd -literal -offset indent
732 GEOM: provider: the secondary GPT table is corrupt or invalid.
733 GEOM: provider: using the primary only -- recovery suggested.
743 will report about corrupt table.
745 In case when the size of device has changed (e.g. volume expansion) the
746 secondary GPT header will become located not in the last sector. This is
747 not a metadata corruption, but it is dangerous because any corruption of
748 the primary GPT will lead to lost of partition table. Kernel reports about
749 this problem with message:
750 .Bd -literal -offset indent
751 GEOM: provider: the secondary GPT header is not in the last LBA.
754 A corrupt table can be recovered with
756 command. This command does reconstruction of corrupt metadata using
757 known valid metadata. Also it can relocate secondary GPT to the end of
761 The GEOM class PART can detect the same partition table on different GEOM
762 providers and some of them will marked as corrupt. Be careful when choising
763 a provider for recovering. If you did incorrect choise you can destroy
764 metadata of another GEOM class, e.g. GEOM MIRROR or GEOM LABEL.
766 Exit status is 0 on success, and 1 if the command fails.
770 .Bd -literal -offset indent
771 /sbin/gpart create -s GPT ad0
774 Embed GPT bootstrap code into protective MBR.
775 .Bd -literal -offset indent
776 /sbin/gpart bootcode -b /boot/pmbr ad0
781 partition that can boot
785 partition, and install bootstrap code into it.
786 This partition must be larger than
788 or the GPT boot you are planning to write, but smaller than 545 KB.
789 A size of 15 blocks (7680 bytes) would be sufficient for
790 booting from UFS but let's use 128 blocks (64 KB) here in
791 this example, in order to reserve some space for potential
792 future need (e.g.\& from a ZFS partition).
793 .Bd -literal -offset indent
794 /sbin/gpart add -b 34 -s 128 -t freebsd-boot ad0
795 /sbin/gpart bootcode -p /boot/gptboot -i 1 ad0
800 partition that would contain UFS where the system boots from.
801 .Bd -literal -offset indent
802 /sbin/gpart add -b 162 -s 1048576 -t freebsd-ufs ad0
805 Create VTOC8 scheme on
807 .Bd -literal -offset indent
808 /sbin/gpart create -s VTOC8 da0
813 partition that would contain UFS where the system boots from.
814 .Bd -literal -offset indent
815 /sbin/gpart add -s 512M -t freebsd-ufs da0
818 After having created all required partitions, embed bootstrap code into them.
819 .Bd -literal -offset indent
820 /sbin/gpart bootcode -p /boot/boot1 da0
823 Create backup of partition table from
825 .Bd -literal -offset indent
826 /sbin/gpart backup da0 > da0.backup
829 Restore partition table from backup to
831 .Bd -literal -offset indent
832 /sbin/gpart restore -l da0 < /mnt/da0.backup
835 Clone partition table from
841 .Bd -literal -offset indent
842 /sbin/gpart backup ada0 | /sbin/gpart restore -F ada1 ada2
854 .An Marcel Moolenaar Aq marcel@FreeBSD.org