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 omitted. 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.
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.
426 Only partition table may be restored.
427 This action does not affect content of partitions.
428 This mean that you should copy your data from backup after restoring
429 partition table and write bootcode again if it is needed.
431 Additional options include:
434 Destroy partition table on the given
436 before doing restore.
438 Restore partition labels for partitioning schemes that support them.
440 Additional operational flags.
441 See the section entitled
442 .Sx "OPERATIONAL FLAGS"
443 below for a discussion
448 Set the named attribute on the partition entry.
449 See the section entitled
451 below for a list of available attributes.
453 Additional options include:
456 Additional operational flags.
457 See the section entitled
458 .Sx "OPERATIONAL FLAGS"
459 below for a discussion
464 Show the current partition information of the specified geoms
465 or all geoms if none are specified.
466 Additional options include:
469 For partition schemes that support partition labels print them
470 instead of partition type.
472 Show raw partition type instead of symbolic name.
476 Revert any pending changes for geom
478 This action is the opposite of the
480 action and can be used to undo any changes that have not been committed.
483 Clear the named attribute on the partition entry.
484 See the section entitled
486 below for a list of available attributes.
488 Additional options include:
491 Additional operational flags.
492 See the section entitled
493 .Sx "OPERATIONAL FLAGS"
494 below for a discussion
502 utility uses symbolic names for common partition types to avoid that the
503 user needs to know what the partitioning scheme in question is and what
504 the actual number or identification needs to be used for a particular
508 utility also allows the user to specify scheme-specific partition types
509 for partition types that do not have symbol names.
510 The symbolic names currently understood are:
511 .Bl -tag -width ".Cm freebsd-vinum"
513 The system partition dedicated to second stage of the boot loader program.
514 Usually it used by GRUB 2 loader when the partition table is GPT.
515 The scheme-specific type is
516 .Qq Li "!21686148-6449-6E6F-744E-656564454649" .
518 The system partition for computers that use the Extensible Firmware
520 In such cases, the GPT partitioning scheme is being used and the
521 actual partition type for the system partition can also be specified as
522 .Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93ab" .
526 partition that uses the
528 disklabel to sub-divide the
529 partition into file systems.
530 This is a legacy partition type and should not be used for the APM
532 The scheme-specific types are
537 .Qq Li "!516e7cb4-6ecf-11d6-8ff8-00022d09712b"
542 partition dedicated to bootstrap code.
543 The scheme-specific type is
544 .Qq Li "!83bd6b9d-7f41-11dc-be0b-001560b84f0f"
549 partition dedicated to swap space.
550 The scheme-specific types are
551 .Qq Li "!FreeBSD-swap"
553 .Qq Li "!516e7cb5-6ecf-11d6-8ff8-00022d09712b"
554 for GPT, and tag 0x0901 for VTOC8.
558 partition that contains a UFS or UFS2 file system.
559 The scheme-specific types are
560 .Qq Li "!FreeBSD-UFS"
562 .Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b"
563 for GPT, and tag 0x0902 for VTOC8.
567 partition that contains a Vinum volume.
568 The scheme-specific types are
569 .Qq Li "!FreeBSD-Vinum"
571 .Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b"
572 for GPT, and tag 0x0903 for VTOC8.
576 partition that contains a ZFS volume.
577 The scheme-specific types are
578 .Qq Li "!FreeBSD-ZFS"
580 .Qq Li "!516e7cba-6ecf-11d6-8ff8-00022d09712b"
581 for GPT, and 0x0904 for VTOC8.
583 A partition that is sub-partitioned by a master boot record (MBR).
584 This type is known as
585 .Qq Li "!024dee41-33e7-11d3-9d69-0008c781f39f"
589 The scheme-specific attributes for EBR:
590 .Bl -tag -width ".Ar active"
594 The scheme-specific attributes for GPT:
595 .Bl -tag -width ".Ar bootfailed"
599 stage 1 boot loader will try to boot the system from this partition.
600 Multiple partitions might be marked with the
607 partitions one by one, until the next boot stage is successfully entered.
609 Setting this attribute automatically sets the
614 stage 1 boot loader will try to boot the system from this partition only once.
619 attributes are tried before partitions with only the
624 partition is tried, the
628 attribute and tries to execute the next boot stage.
631 attribute that is now alone is replaced with the
634 If the execution of the next boot stage succeeds, but the system is not fully
639 attributes alone (without the
641 attribute) on the next system boot and will replace those with the
644 If the system is fully booted, the
645 .Pa /etc/rc.d/gptboot
646 start-up script will look for partition with the
648 attribute alone, will remove the attribute and log that the system was
649 successfully booted from this partition.
650 There should be at most one
652 partition when system is successfully booted.
653 Multiple partitions might be marked with the
659 This attribute should not be manually managed.
662 stage 1 boot loader and the
663 .Pa /etc/rc.d/gptboot
665 This attribute is used to mark partitions that had the
667 attribute set, but we failed to boot from them.
668 Once we successfully boot, the
669 .Pa /etc/rc.d/gptboot
670 script will log all the partitions we failed to boot from and will remove the
675 The scheme-specific attributes for MBR:
676 .Bl -tag -width ".Ar active"
680 The scheme-specific attributes for PC98:
681 .Bl -tag -width ".Ar bootable"
685 .Sh OPERATIONAL FLAGS
686 Actions other than the
690 actions take an optional
693 This option is used to specify action-specific operational flags.
698 flag so that the action is immediately
702 to have the action result in a pending change that can later, with
703 other pending changes, be committed as a single compound change with
706 action or reverted with the
710 The GEOM class PART supports recovering of partition tables only for GPT.
711 The GUID partition table has a primary and secondary (backup) copy of
712 metadata for redundance.
713 They are stored in the begining and in the end of device respectively.
714 Therefore it is acceptable to have some corruptions in the metadata that
715 are not fatal to work with GPT.
716 When kernel detects corrupt metadata it marks this table as corrupt and
717 reports about corruption.
718 Any changes in corrupt table are prohibited except
723 In case when only first sector is corrupt kernel can not detect GPT even
724 if partition table is not corrupt.
725 You can write protective MBR with
727 command to restore ability of GPT detection.
728 The copy of protective MBR is usually located in the
732 In case when some of metadata is corrupt you will get to know about this
733 from kernel's messages like these:
734 .Bd -literal -offset indent
735 GEOM: provider: the primary GPT table is corrupt or invalid.
736 GEOM: provider: using the secondary instead -- recovery strongly advised.
740 .Bd -literal -offset indent
741 GEOM: provider: the secondary GPT table is corrupt or invalid.
742 GEOM: provider: using the primary only -- recovery suggested.
752 will report about corrupt table.
754 In case when the size of device has changed (e.g. volume expansion) the
755 secondary GPT header will become located not in the last sector.
756 This is not a metadata corruption, but it is dangerous because any
757 corruption of the primary GPT will lead to lost of partition table.
758 Kernel reports about this problem with message:
759 .Bd -literal -offset indent
760 GEOM: provider: the secondary GPT header is not in the last LBA.
763 A corrupt table can be recovered with
766 This command does reconstruction of corrupt metadata using
767 known valid metadata.
768 Also it can relocate secondary GPT to the end of device.
771 The GEOM class PART can detect the same partition table on different GEOM
772 providers and some of them will be marked as corrupt.
773 Be careful when choosing a provider for recovering.
774 If you choose incorrectly you can destroy the metadata of another GEOM class,
775 e.g. GEOM MIRROR or GEOM LABEL.
777 Exit status is 0 on success, and 1 if the command fails.
781 .Bd -literal -offset indent
782 /sbin/gpart create -s GPT ad0
785 Embed GPT bootstrap code into protective MBR.
786 .Bd -literal -offset indent
787 /sbin/gpart bootcode -b /boot/pmbr ad0
792 partition that can boot
796 partition, and install bootstrap code into it.
797 This partition must be larger than
799 or the GPT boot you are planning to write, but smaller than 545 KB.
800 A size of 15 blocks (7680 bytes) would be sufficient for
801 booting from UFS but let's use 128 blocks (64 KB) here in
802 this example, in order to reserve some space for potential
803 future need (e.g.\& from a ZFS partition).
804 .Bd -literal -offset indent
805 /sbin/gpart add -b 34 -s 128 -t freebsd-boot ad0
806 /sbin/gpart bootcode -p /boot/gptboot -i 1 ad0
811 partition that would contain UFS where the system boots from.
812 .Bd -literal -offset indent
813 /sbin/gpart add -b 162 -s 1048576 -t freebsd-ufs ad0
816 Create VTOC8 scheme on
818 .Bd -literal -offset indent
819 /sbin/gpart create -s VTOC8 da0
824 partition that would contain UFS where the system boots from.
825 .Bd -literal -offset indent
826 /sbin/gpart add -s 512M -t freebsd-ufs da0
829 After having created all required partitions, embed bootstrap code into them.
830 .Bd -literal -offset indent
831 /sbin/gpart bootcode -p /boot/boot1 da0
834 Create backup of partition table from
836 .Bd -literal -offset indent
837 /sbin/gpart backup da0 > da0.backup
840 Restore partition table from backup to
842 .Bd -literal -offset indent
843 /sbin/gpart restore -l da0 < /mnt/da0.backup
846 Clone partition table from
852 .Bd -literal -offset indent
853 /sbin/gpart backup ada0 | /sbin/gpart restore -F ada1 ada2
865 .An Marcel Moolenaar Aq marcel@FreeBSD.org