1.\" Copyright (c) 2007, 2008 Marcel Moolenaar 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 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. 12.\" 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 23.\" SUCH DAMAGE. 24.\" 25.\" $FreeBSD$ 26.\" 27.Dd June 17, 2018 28.Dt GPART 8 29.Os 30.Sh NAME 31.Nm gpart 32.Nd "control utility for the disk partitioning GEOM class" 33.Sh SYNOPSIS 34.\" ==== ADD ==== 35.Nm 36.Cm add 37.Fl t Ar type 38.Op Fl a Ar alignment 39.Op Fl b Ar start 40.Op Fl s Ar size 41.Op Fl i Ar index 42.Op Fl l Ar label 43.Op Fl f Ar flags 44.Ar geom 45.\" ==== BACKUP ==== 46.Nm 47.Cm backup 48.Ar geom 49.\" ==== BOOTCODE ==== 50.Nm 51.Cm bootcode 52.Op Fl N 53.Op Fl b Ar bootcode 54.Op Fl p Ar partcode Fl i Ar index 55.Op Fl f Ar flags 56.Ar geom 57.\" ==== COMMIT ==== 58.Nm 59.Cm commit 60.Ar geom 61.\" ==== CREATE ==== 62.Nm 63.Cm create 64.Fl s Ar scheme 65.Op Fl n Ar entries 66.Op Fl f Ar flags 67.Ar provider 68.\" ==== DELETE ==== 69.Nm 70.Cm delete 71.Fl i Ar index 72.Op Fl f Ar flags 73.Ar geom 74.\" ==== DESTROY ==== 75.Nm 76.Cm destroy 77.Op Fl F 78.Op Fl f Ar flags 79.Ar geom 80.\" ==== MODIFY ==== 81.Nm 82.Cm modify 83.Fl i Ar index 84.Op Fl l Ar label 85.Op Fl t Ar type 86.Op Fl f Ar flags 87.Ar geom 88.\" ==== RECOVER ==== 89.Nm 90.Cm recover 91.Op Fl f Ar flags 92.Ar geom 93.\" ==== RESIZE ==== 94.Nm 95.Cm resize 96.Fl i Ar index 97.Op Fl a Ar alignment 98.Op Fl s Ar size 99.Op Fl f Ar flags 100.Ar geom 101.\" ==== RESTORE ==== 102.Nm 103.Cm restore 104.Op Fl lF 105.Op Fl f Ar flags 106.Ar provider 107.Op Ar ... 108.\" ==== SET ==== 109.Nm 110.Cm set 111.Fl a Ar attrib 112.Fl i Ar index 113.Op Fl f Ar flags 114.Ar geom 115.\" ==== SHOW ==== 116.Nm 117.Cm show 118.Op Fl l | r 119.Op Fl p 120.Op Ar geom ... 121.\" ==== UNDO ==== 122.Nm 123.Cm undo 124.Ar geom 125.\" ==== UNSET ==== 126.Nm 127.Cm unset 128.Fl a Ar attrib 129.Fl i Ar index 130.Op Fl f Ar flags 131.Ar geom 132.\" 133.Nm 134.Cm list 135.Nm 136.Cm status 137.Nm 138.Cm load 139.Nm 140.Cm unload 141.Sh DESCRIPTION 142The 143.Nm 144utility is used to partition GEOM providers, normally disks. 145The first argument is the action to be taken: 146.Bl -tag -width ".Cm bootcode" 147.\" ==== ADD ==== 148.It Cm add 149Add a new partition to the partitioning scheme given by 150.Ar geom . 151The partition type must be specified with 152.Fl t Ar type . 153The partition's location, size, and other attributes will be calculated 154automatically if the corresponding options are not specified. 155.Pp 156The 157.Cm add 158command accepts these options: 159.Bl -tag -width 12n 160.It Fl a Ar alignment 161If specified, then 162.Nm 163utility tries to align 164.Ar start 165offset and partition 166.Ar size 167to be multiple of 168.Ar alignment 169value. 170.It Fl b Ar start 171The logical block address where the partition will begin. 172A SI unit suffix is allowed. 173.It Fl f Ar flags 174Additional operational flags. 175See the section entitled 176.Sx "OPERATIONAL FLAGS" 177below for a discussion 178about its use. 179.It Fl i Ar index 180The index in the partition table at which the new partition is to be 181placed. 182The index determines the name of the device special file used 183to represent the partition. 184.It Fl l Ar label 185The label attached to the partition. 186This option is only valid when used on partitioning schemes that support 187partition labels. 188.It Fl s Ar size 189Create a partition of size 190.Ar size . 191A SI unit suffix is allowed. 192.It Fl t Ar type 193Create a partition of type 194.Ar type . 195Partition types are discussed below in the section entitled 196.Sx "PARTITION TYPES" . 197.El 198.\" ==== BACKUP ==== 199.It Cm backup 200Dump a partition table to standard output in a special format used by the 201.Cm restore 202action. 203.\" ==== BOOTCODE ==== 204.It Cm bootcode 205Embed bootstrap code into the partitioning scheme's metadata on the 206.Ar geom 207(using 208.Fl b Ar bootcode ) 209or write bootstrap code into a partition (using 210.Fl p Ar partcode 211and 212.Fl i Ar index ) . 213.Pp 214The 215.Cm bootcode 216command accepts these options: 217.Bl -tag -width 10n 218.It Fl N 219Don't preserve the Volume Serial Number for MBR. 220MBR bootcode contains Volume Serial Number by default, and 221.Nm 222tries to preserve it when installing new bootstrap code. 223This option allows to skip the preservation to help with some versions of 224.Xr boot0 8 225that don't support Volume Serial Number. 226.It Fl b Ar bootcode 227Embed bootstrap code from the file 228.Ar bootcode 229into the partitioning scheme's metadata for 230.Ar geom . 231Not all partitioning schemes have embedded bootstrap code, so the 232.Fl b Ar bootcode 233option is scheme-specific in nature (see the section entitled 234.Sx BOOTSTRAPPING 235below). 236The 237.Ar bootcode 238file must match the partitioning scheme's requirements for file content 239and size. 240.It Fl f Ar flags 241Additional operational flags. 242See the section entitled 243.Sx "OPERATIONAL FLAGS" 244below for a discussion 245about its use. 246.It Fl i Ar index 247Specify the target partition for 248.Fl p Ar partcode . 249.It Fl p Ar partcode 250Write the bootstrap code from the file 251.Ar partcode 252into the 253.Ar geom 254partition specified by 255.Fl i Ar index . 256The size of the file must be smaller than the size of the partition. 257.El 258.\" ==== COMMIT ==== 259.It Cm commit 260Commit any pending changes for geom 261.Ar geom . 262All actions are committed by default and will not result in 263pending changes. 264Actions can be modified with the 265.Fl f Ar flags 266option so that they are not committed, but become pending. 267Pending changes are reflected by the geom and the 268.Nm 269utility, but they are not actually written to disk. 270The 271.Cm commit 272action will write all pending changes to disk. 273.\" ==== CREATE ==== 274.It Cm create 275Create a new partitioning scheme on a provider given by 276.Ar provider . 277The scheme to use must be specified with the 278.Fl s Ar scheme 279option. 280.Pp 281The 282.Cm create 283command accepts these options: 284.Bl -tag -width 10n 285.It Fl f Ar flags 286Additional operational flags. 287See the section entitled 288.Sx "OPERATIONAL FLAGS" 289below for a discussion 290about its use. 291.It Fl n Ar entries 292The number of entries in the partition table. 293Every partitioning scheme has a minimum and maximum number of entries. 294This option allows tables to be created with a number of entries 295that is within the limits. 296Some schemes have a maximum equal to the minimum and some schemes have 297a maximum large enough to be considered unlimited. 298By default, partition tables are created with the minimum number of 299entries. 300.It Fl s Ar scheme 301Specify the partitioning scheme to use. 302The kernel must have support for a particular scheme before 303that scheme can be used to partition a disk. 304.El 305.\" ==== DELETE ==== 306.It Cm delete 307Delete a partition from geom 308.Ar geom 309and further identified by the 310.Fl i Ar index 311option. 312The partition cannot be actively used by the kernel. 313.Pp 314The 315.cm delete 316command accepts these options: 317.Bl -tag -width 10n 318.It Fl f Ar flags 319Additional operational flags. 320See the section entitled 321.Sx "OPERATIONAL FLAGS" 322below for a discussion 323about its use. 324.It Fl i Ar index 325Specifies the index of the partition to be deleted. 326.El 327.\" ==== DESTROY ==== 328.It Cm destroy 329Destroy the partitioning scheme as implemented by geom 330.Ar geom . 331.Pp 332The 333.Cm destroy 334command accepts these options: 335.Bl -tag -width 10n 336.It Fl F 337Forced destroying of the partition table even if it is not empty. 338.It Fl f Ar flags 339Additional operational flags. 340See the section entitled 341.Sx "OPERATIONAL FLAGS" 342below for a discussion 343about its use. 344.El 345.\" ==== MODIFY ==== 346.It Cm modify 347Modify a partition from geom 348.Ar geom 349and further identified by the 350.Fl i Ar index 351option. 352Only the type and/or label of the partition can be modified. 353Not all partitioning schemes support labels and it is invalid to 354try to change a partition label in such cases. 355.Pp 356The 357.Cm modify 358command accepts these options: 359.Bl -tag -width 10n 360.It Fl f Ar flags 361Additional operational flags. 362See the section entitled 363.Sx "OPERATIONAL FLAGS" 364below for a discussion 365about its use. 366.It Fl i Ar index 367Specifies the index of the partition to be modified. 368.It Fl l Ar label 369Change the partition label to 370.Ar label . 371.It Fl t Ar type 372Change the partition type to 373.Ar type . 374.El 375.\" ==== RECOVER ==== 376.It Cm recover 377Recover a corrupt partition's scheme metadata on the geom 378.Ar geom . 379See the section entitled 380.Sx RECOVERING 381below for the additional information. 382.Pp 383The 384.Cm recover 385command accepts these options: 386.Bl -tag -width 10n 387.It Fl f Ar flags 388Additional operational flags. 389See the section entitled 390.Sx "OPERATIONAL FLAGS" 391below for a discussion 392about its use. 393.El 394.\" ==== RESIZE ==== 395.It Cm resize 396Resize a partition from geom 397.Ar geom 398and further identified by the 399.Fl i Ar index 400option. 401If the new size is not specified it is automatically calculated 402to be the maximum available from 403.Ar geom . 404.Pp 405The 406.Cm resize 407command accepts these options: 408.Bl -tag -width 12n 409.It Fl a Ar alignment 410If specified, then 411.Nm 412utility tries to align partition 413.Ar size 414to be a multiple of the 415.Ar alignment 416value. 417.It Fl f Ar flags 418Additional operational flags. 419See the section entitled 420.Sx "OPERATIONAL FLAGS" 421below for a discussion 422about its use. 423.It Fl i Ar index 424Specifies the index of the partition to be resized. 425.It Fl s Ar size 426Specifies the new size of the partition, in logical blocks. 427A SI unit suffix is allowed. 428.El 429.\" ==== RESTORE ==== 430.It Cm restore 431Restore the partition table from a backup previously created by the 432.Cm backup 433action and read from standard input. 434Only the partition table is restored. 435This action does not affect the content of partitions. 436After restoring the partition table and writing bootcode if needed, 437user data must be restored from backup. 438.Pp 439The 440.Cm restore 441command accepts these options: 442.Bl -tag -width 10n 443.It Fl F 444Destroy partition table on the given 445.Ar provider 446before doing restore. 447.It Fl f Ar flags 448Additional operational flags. 449See the section entitled 450.Sx "OPERATIONAL FLAGS" 451below for a discussion 452about its use. 453.It Fl l 454Restore partition labels for partitioning schemes that support them. 455.El 456.\" ==== SET ==== 457.It Cm set 458Set the named attribute on the partition entry. 459See the section entitled 460.Sx ATTRIBUTES 461below for a list of available attributes. 462.Pp 463The 464.Cm set 465command accepts these options: 466.Bl -tag -width 10n 467.It Fl a Ar attrib 468Specifies the attribute to set. 469.It Fl f Ar flags 470Additional operational flags. 471See the section entitled 472.Sx "OPERATIONAL FLAGS" 473below for a discussion 474about its use. 475.It Fl i Ar index 476Specifies the index of the partition on which the attribute will be set. 477.El 478.\" ==== SHOW ==== 479.It Cm show 480Show current partition information for the specified geoms, or all 481geoms if none are specified. 482The default output includes the logical starting block of each 483partition, the partition size in blocks, the partition index number, 484the partition type, and a human readable partition size. 485Block sizes and locations are based on the device's Sectorsize 486as shown by 487.Cm gpart list . 488.Pp 489The 490.Cm show 491command accepts these options: 492.Bl -tag -width 10n 493.It Fl l 494For partitioning schemes that support partition labels, print them 495instead of partition type. 496.It Fl p 497Show provider names instead of partition indexes. 498.It Fl r 499Show raw partition type instead of symbolic name. 500.El 501.\" ==== UNDO ==== 502.It Cm undo 503Revert any pending changes for geom 504.Ar geom . 505This action is the opposite of the 506.Cm commit 507action and can be used to undo any changes that have not been committed. 508.\" ==== UNSET ==== 509.It Cm unset 510Clear the named attribute on the partition entry. 511See the section entitled 512.Sx ATTRIBUTES 513below for a list of available attributes. 514.Pp 515The 516.Cm unset 517command accepts these options: 518.Bl -tag -width 10n 519.It Fl a Ar attrib 520Specifies the attribute to clear. 521.It Fl f Ar flags 522Additional operational flags. 523See the section entitled 524.Sx "OPERATIONAL FLAGS" 525below for a discussion 526about its use. 527.It Fl i Ar index 528Specifies the index of the partition on which the attribute will be cleared. 529.El 530.It Cm list 531See 532.Xr geom 8 . 533.It Cm status 534See 535.Xr geom 8 . 536.It Cm load 537See 538.Xr geom 8 . 539.It Cm unload 540See 541.Xr geom 8 . 542.El 543.Sh PARTITIONING SCHEMES 544Several partitioning schemes are supported by the 545.Nm 546utility: 547.Bl -tag -width ".Cm VTOC8" 548.It Cm APM 549Apple Partition Map, used by PowerPC(R) Macintosh(R) computers. 550Requires the 551.Cd GEOM_PART_APM 552kernel option. 553.It Cm BSD 554Traditional BSD disklabel, usually used to subdivide MBR partitions. 555.Po 556This scheme can also be used as the sole partitioning method, without 557an MBR. 558Partition editing tools from other operating systems often do not 559understand the bare disklabel partition layout, so this is sometimes 560called 561.Dq dangerously dedicated . 562.Pc 563Requires the 564.Cm GEOM_PART_BSD 565kernel option. 566.It Cm BSD64 56764-bit implementation of BSD disklabel used in DragonFlyBSD to subdivide MBR 568or GPT partitions. 569Requires the 570.Cm GEOM_PART_BSD64 571kernel option. 572.It Cm LDM 573The Logical Disk Manager is an implementation of volume manager for 574Microsoft Windows NT. 575Requires the 576.Cd GEOM_PART_LDM 577kernel option. 578.It Cm GPT 579GUID Partition Table is used on Intel-based Macintosh computers and 580gradually replacing MBR on most PCs and other systems. 581Requires the 582.Cm GEOM_PART_GPT 583kernel option. 584.It Cm MBR 585Master Boot Record is used on PCs and removable media. 586Requires the 587.Cm GEOM_PART_MBR 588kernel option. 589The 590.Cm GEOM_PART_EBR 591option adds support for the Extended Boot Record (EBR), 592which is used to define a logical partition. 593The 594.Cm GEOM_PART_EBR_COMPAT 595option enables backward compatibility for partition names 596in the EBR scheme. 597It also prevents any type of actions on such partitions. 598.It Cm VTOC8 599Sun's SMI Volume Table Of Contents, used by 600.Tn SPARC64 601and 602.Tn UltraSPARC 603computers. 604Requires the 605.Cm GEOM_PART_VTOC8 606kernel option. 607.El 608.Sh PARTITION TYPES 609Partition types are identified on disk by particular strings or magic 610values. 611The 612.Nm 613utility uses symbolic names for common partition types so the user 614does not need to know these values or other details of the partitioning 615scheme in question. 616The 617.Nm 618utility also allows the user to specify scheme-specific partition types 619for partition types that do not have symbolic names. 620Symbolic names currently understood and used by 621.Fx 622are: 623.Bl -tag -width ".Cm dragonfly-disklabel64" 624.It Cm apple-boot 625The system partition dedicated to storing boot loaders on some Apple 626systems. 627The scheme-specific types are 628.Qq Li "!171" 629for MBR, 630.Qq Li "!Apple_Bootstrap" 631for APM, and 632.Qq Li "!426f6f74-0000-11aa-aa11-00306543ecac" 633for GPT. 634.It Cm bios-boot 635The system partition dedicated to second stage of the boot loader program. 636Usually it is used by the GRUB 2 loader for GPT partitioning schemes. 637The scheme-specific type is 638.Qq Li "!21686148-6449-6E6F-744E-656564454649" . 639.It Cm efi 640The system partition for computers that use the Extensible Firmware 641Interface (EFI). 642The scheme-specific types are 643.Qq Li "!239" 644for MBR, and 645.Qq Li "!c12a7328-f81f-11d2-ba4b-00a0c93ec93b" 646for GPT. 647.It Cm freebsd 648A 649.Fx 650partition subdivided into filesystems with a 651.Bx 652disklabel. 653This is a legacy partition type and should not be used for the APM 654or GPT schemes. 655The scheme-specific types are 656.Qq Li "!165" 657for MBR, 658.Qq Li "!FreeBSD" 659for APM, and 660.Qq Li "!516e7cb4-6ecf-11d6-8ff8-00022d09712b" 661for GPT. 662.It Cm freebsd-boot 663A 664.Fx 665partition dedicated to bootstrap code. 666The scheme-specific type is 667.Qq Li "!83bd6b9d-7f41-11dc-be0b-001560b84f0f" 668for GPT. 669.It Cm freebsd-swap 670A 671.Fx 672partition dedicated to swap space. 673The scheme-specific types are 674.Qq Li "!FreeBSD-swap" 675for APM, 676.Qq Li "!516e7cb5-6ecf-11d6-8ff8-00022d09712b" 677for GPT, and tag 0x0901 for VTOC8. 678.It Cm freebsd-ufs 679A 680.Fx 681partition that contains a UFS or UFS2 filesystem. 682The scheme-specific types are 683.Qq Li "!FreeBSD-UFS" 684for APM, 685.Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b" 686for GPT, and tag 0x0902 for VTOC8. 687.It Cm freebsd-vinum 688A 689.Fx 690partition that contains a Vinum volume. 691The scheme-specific types are 692.Qq Li "!FreeBSD-Vinum" 693for APM, 694.Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b" 695for GPT, and tag 0x0903 for VTOC8. 696.It Cm freebsd-zfs 697A 698.Fx 699partition that contains a ZFS volume. 700The scheme-specific types are 701.Qq Li "!FreeBSD-ZFS" 702for APM, 703.Qq Li "!516e7cba-6ecf-11d6-8ff8-00022d09712b" 704for GPT, and 0x0904 for VTOC8. 705.El 706.Pp 707Another symbolic names that can be used with 708.Cm gpart 709utility are: 710.Bl -tag -width ".Cm dragonfly-disklabel64" 711.It Cm apple-apfs 712An Apple macOS partition used for the Apple file system, APFS. 713.It Cm apple-core-storage 714An Apple Mac OS X partition used by logical volume manager known as 715Core Storage. 716The scheme-specific type is 717.Qq Li "!53746f72-6167-11aa-aa11-00306543ecac" 718for GPT. 719.It Cm apple-hfs 720An Apple Mac OS X partition that contains a HFS or HFS+ filesystem. 721The scheme-specific types are 722.Qq Li "!175" 723for MBR, 724.Qq Li "!Apple_HFS" 725for APM and 726.Qq Li "!48465300-0000-11aa-aa11-00306543ecac" 727for GPT. 728.It Cm apple-label 729An Apple Mac OS X partition dedicated to partition metadata that descibes 730disk device. 731The scheme-specific type is 732.Qq Li "!4c616265-6c00-11aa-aa11-00306543ecac" 733for GPT. 734.It Cm apple-raid 735An Apple Mac OS X partition used in a software RAID configuration. 736The scheme-specific type is 737.Qq Li "!52414944-0000-11aa-aa11-00306543ecac" 738for GPT. 739.It Cm apple-raid-offline 740An Apple Mac OS X partition used in a software RAID configuration. 741The scheme-specific type is 742.Qq Li "!52414944-5f4f-11aa-aa11-00306543ecac" 743for GPT. 744.It Cm apple-tv-recovery 745An Apple Mac OS X partition used by Apple TV. 746The scheme-specific type is 747.Qq Li "!5265636f-7665-11aa-aa11-00306543ecac" 748for GPT. 749.It Cm apple-ufs 750An Apple Mac OS X partition that contains a UFS filesystem. 751The scheme-specific types are 752.Qq Li "!168" 753for MBR, 754.Qq Li "!Apple_UNIX_SVR2" 755for APM and 756.Qq Li "!55465300-0000-11aa-aa11-00306543ecac" 757for GPT. 758.It Cm dragonfly-label32 759A DragonFlyBSD partition subdivided into filesystems with a 760.Bx 761disklabel. 762The scheme-specific type is 763.Qq Li "!9d087404-1ca5-11dc-8817-01301bb8a9f5" 764for GPT. 765.It Cm dragonfly-label64 766A DragonFlyBSD partition subdivided into filesystems with a 767disklabel64. 768The scheme-specific type is 769.Qq Li "!3d48ce54-1d16-11dc-8696-01301bb8a9f5" 770for GPT. 771.It Cm dragonfly-legacy 772A legacy partition type used in DragonFlyBSD. 773The scheme-specific type is 774.Qq Li "!bd215ab2-1d16-11dc-8696-01301bb8a9f5" 775for GPT. 776.It Cm dragonfly-ccd 777A DragonFlyBSD partition used with Concatenated Disk driver. 778The scheme-specific type is 779.Qq Li "!dbd5211b-1ca5-11dc-8817-01301bb8a9f5" 780for GPT. 781.It Cm dragonfly-hammer 782A DragonFlyBSD partition that contains a Hammer filesystem. 783The scheme-specific type is 784.Qq Li "!61dc63ac-6e38-11dc-8513-01301bb8a9f5" 785for GPT. 786.It Cm dragonfly-hammer2 787A DragonFlyBSD partition that contains a Hammer2 filesystem. 788The scheme-specific type is 789.Qq Li "!5cbb9ad1-862d-11dc-a94d-01301bb8a9f5" 790for GPT. 791.It Cm dragonfly-swap 792A DragonFlyBSD partition dedicated to swap space. 793The scheme-specific type is 794.Qq Li "!9d58fdbd-1ca5-11dc-8817-01301bb8a9f5" 795for GPT. 796.It Cm dragonfly-ufs 797A DragonFlyBSD partition that contains an UFS1 filesystem. 798The scheme-specific type is 799.Qq Li "!9d94ce7c-1ca5-11dc-8817-01301bb8a9f5" 800for GPT. 801.It Cm dragonfly-vinum 802A DragonFlyBSD partition used with Logical Volume Manager. 803The scheme-specific type is 804.Qq Li "!9dd4478f-1ca5-11dc-8817-01301bb8a9f5" 805for GPT. 806.It Cm ebr 807A partition subdivided into filesystems with a EBR. 808The scheme-specific type is 809.Qq Li "!5" 810for MBR. 811.It Cm fat16 812A partition that contains a FAT16 filesystem. 813The scheme-specific type is 814.Qq Li "!6" 815for MBR. 816.It Cm fat32 817A partition that contains a FAT32 filesystem. 818The scheme-specific type is 819.Qq Li "!11" 820for MBR. 821.It Cm fat32lba 822A partition that contains a FAT32 (LBA) filesystem. 823The scheme-specific type is 824.Qq Li "!12" 825for MBR. 826.It Cm linux-data 827A Linux partition that contains some filesystem with data. 828The scheme-specific types are 829.Qq Li "!131" 830for MBR and 831.Qq Li "!0fc63daf-8483-4772-8e79-3d69d8477de4" 832for GPT. 833.It Cm linux-lvm 834A Linux partition dedicated to Logical Volume Manager. 835The scheme-specific types are 836.Qq Li "!142" 837for MBR and 838.Qq Li "!e6d6d379-f507-44c2-a23c-238f2a3df928" 839for GPT. 840.It Cm linux-raid 841A Linux partition used in a software RAID configuration. 842The scheme-specific types are 843.Qq Li "!253" 844for MBR and 845.Qq Li "!a19d880f-05fc-4d3b-a006-743f0f84911e" 846for GPT. 847.It Cm linux-swap 848A Linux partition dedicated to swap space. 849The scheme-specific types are 850.Qq Li "!130" 851for MBR and 852.Qq Li "!0657fd6d-a4ab-43c4-84e5-0933c84b4f4f" 853for GPT. 854.It Cm mbr 855A partition that is sub-partitioned by a Master Boot Record (MBR). 856This type is known as 857.Qq Li "!024dee41-33e7-11d3-9d69-0008c781f39f" 858by GPT. 859.It Cm ms-basic-data 860A basic data partition (BDP) for Microsoft operating systems. 861In the GPT this type is the equivalent to partition types 862.Cm fat16 , fat32 863and 864.Cm ntfs 865in MBR. 866The scheme-specific type is 867.Qq Li "!ebd0a0a2-b9e5-4433-87c0-68b6b72699c7" 868for GPT. 869.It Cm ms-ldm-data 870A partition that contains Logical Disk Manager (LDM) volumes. 871The scheme-specific types are 872.Qq Li "!66" 873for MBR, 874.Qq Li "!af9b60a0-1431-4f62-bc68-3311714a69ad" 875for GPT. 876.It Cm ms-ldm-metadata 877A partition that contains Logical Disk Manager (LDM) database. 878The scheme-specific type is 879.Qq Li "!5808c8aa-7e8f-42e0-85d2-e1e90434cfb3" 880for GPT. 881.It Cm netbsd-ccd 882A NetBSD partition used with Concatenated Disk driver. 883The scheme-specific type is 884.Qq Li "!2db519c4-b10f-11dc-b99b-0019d1879648" 885for GPT. 886.It Cm netbsd-cgd 887An encrypted NetBSD partition. 888The scheme-specific type is 889.Qq Li "!2db519ec-b10f-11dc-b99b-0019d1879648" 890for GPT. 891.It Cm netbsd-ffs 892A NetBSD partition that contains an UFS filesystem. 893The scheme-specific type is 894.Qq Li "!49f48d5a-b10e-11dc-b99b-0019d1879648" 895for GPT. 896.It Cm netbsd-lfs 897A NetBSD partition that contains an LFS filesystem. 898The scheme-specific type is 899.Qq Li "!49f48d82-b10e-11dc-b99b-0019d1879648" 900for GPT. 901.It Cm netbsd-raid 902A NetBSD partition used in a software RAID configuration. 903The scheme-specific type is 904.Qq Li "!49f48daa-b10e-11dc-b99b-0019d1879648" 905for GPT. 906.It Cm netbsd-swap 907A NetBSD partition dedicated to swap space. 908The scheme-specific type is 909.Qq Li "!49f48d32-b10e-11dc-b99b-0019d1879648" 910for GPT. 911.It Cm ntfs 912A partition that contains a NTFS or exFAT filesystem. 913The scheme-specific type is 914.Qq Li "!7" 915for MBR. 916.It Cm prep-boot 917The system partition dedicated to storing boot loaders on some PowerPC systems, 918notably those made by IBM. 919The scheme-specific types are 920.Qq Li "!65" 921for MBR and 922.Qq Li "!0x9e1a2d38-c612-4316-aa26-8b49521e5a8b" 923for GPT. 924.It Cm vmware-vmfs 925A partition that contains a VMware File System (VMFS). 926The scheme-specific types are 927.Qq Li "!251" 928for MBR and 929.Qq Li "!aa31e02a-400f-11db-9590-000c2911d1b8" 930for GPT. 931.It Cm vmware-vmkdiag 932A partition that contains a VMware diagostic filesystem. 933The scheme-specific types are 934.Qq Li "!252" 935for MBR and 936.Qq Li "!9d275380-40ad-11db-bf97-000c2911d1b8" 937for GPT. 938.It Cm vmware-reserved 939A VMware reserved partition. 940The scheme-specific type is 941.Qq Li "!9198effc-31c0-11db-8f-78-000c2911d1b8" 942for GPT. 943.It Cm vmware-vsanhdr 944A partition claimed by VMware VSAN. 945The scheme-specific type is 946.Qq Li "!381cfccc-7288-11e0-92ee-000c2911d0b2" 947for GPT. 948.El 949.Sh ATTRIBUTES 950The scheme-specific attributes for EBR: 951.Bl -tag -width ".Cm active" 952.It Cm active 953.El 954.Pp 955The scheme-specific attributes for GPT: 956.Bl -tag -width ".Cm bootfailed" 957.It Cm bootme 958When set, the 959.Nm gptboot 960stage 1 boot loader will try to boot the system from this partition. 961Multiple partitions can be marked with the 962.Cm bootme 963attribute. 964See 965.Xr gptboot 8 966for more details. 967.It Cm bootonce 968Setting this attribute automatically sets the 969.Cm bootme 970attribute. 971When set, the 972.Nm gptboot 973stage 1 boot loader will try to boot the system from this partition only once. 974Multiple partitions can be marked with the 975.Cm bootonce 976and 977.Cm bootme 978attribute pairs. 979See 980.Xr gptboot 8 981for more details. 982.It Cm bootfailed 983This attribute should not be manually managed. 984It is managed by the 985.Nm gptboot 986stage 1 boot loader and the 987.Pa /etc/rc.d/gptboot 988start-up script. 989See 990.Xr gptboot 8 991for more details. 992.It Cm lenovofix 993Setting this attribute overwrites the Protective MBR with a new one where 994the 0xee partition is the second, rather than the first record. 995This resolves a BIOS compatibility issue with some Lenovo models including the 996X220, T420, and T520, allowing them to boot from GPT partitioned disks 997without using EFI. 998.El 999.Pp 1000The scheme-specific attributes for MBR: 1001.Bl -tag -width ".Cm active" 1002.It Cm active 1003.El 1004.Sh BOOTSTRAPPING 1005.Fx 1006supports several partitioning schemes and each scheme uses different 1007bootstrap code. 1008The bootstrap code is located in a specific disk area for each partitioning 1009scheme, and may vary in size for different schemes. 1010.Pp 1011Bootstrap code can be separated into two types. 1012The first type is embedded in the partitioning scheme's metadata, while the 1013second type is located on a specific partition. 1014Embedding bootstrap code should only be done with the 1015.Cm gpart bootcode 1016command with the 1017.Fl b Ar bootcode 1018option. 1019The GEOM PART class knows how to safely embed bootstrap code into 1020specific partitioning scheme metadata without causing any damage. 1021.Pp 1022The Master Boot Record (MBR) uses a 512-byte bootstrap code image, embedded 1023into the partition table's metadata area. 1024There are two variants of this bootstrap code: 1025.Pa /boot/mbr 1026and 1027.Pa /boot/boot0 . 1028.Pa /boot/mbr 1029searches for a partition with the 1030.Cm active 1031attribute (see the 1032.Sx ATTRIBUTES 1033section) in the partition table. 1034Then it runs next bootstrap stage. 1035The 1036.Pa /boot/boot0 1037image contains a boot manager with some additional interactive functions 1038for multi-booting from a user-selected partition. 1039.Pp 1040A BSD disklabel is usually created inside an MBR partition (slice) 1041with type 1042.Cm freebsd 1043(see the 1044.Sx "PARTITION TYPES" 1045section). 1046It uses 8 KB size bootstrap code image 1047.Pa /boot/boot , 1048embedded into the partition table's metadata area. 1049.Pp 1050Both types of bootstrap code are used to boot from the GUID Partition Table. 1051First, a protective MBR is embedded into the first disk sector from the 1052.Pa /boot/pmbr 1053image. 1054It searches through the GPT for a 1055.Cm freebsd-boot 1056partition (see the 1057.Sx "PARTITION TYPES" 1058section) and runs the next bootstrap stage from it. 1059The 1060.Cm freebsd-boot 1061partition should be smaller than 545 KB. 1062It can be located either before or after other 1063.Fx 1064partitions on the disk. 1065There are two variants of bootstrap code to write to this partition: 1066.Pa /boot/gptboot 1067and 1068.Pa /boot/gptzfsboot . 1069.Pp 1070.Pa /boot/gptboot 1071is used to boot from UFS partitions. 1072.Cm gptboot 1073searches through 1074.Cm freebsd-ufs 1075partitions in the GPT and selects one to boot based on the 1076.Cm bootonce 1077and 1078.Cm bootme 1079attributes. 1080If neither attribute is found, 1081.Pa /boot/gptboot 1082boots from the first 1083.Cm freebsd-ufs 1084partition. 1085.Pa /boot/loader 1086.Pq the third bootstrap stage 1087is loaded from the first partition that matches these conditions. 1088See 1089.Xr gptboot 8 1090for more information. 1091.Pp 1092.Pa /boot/gptzfsboot 1093is used to boot from ZFS. 1094It searches through the GPT for 1095.Cm freebsd-zfs 1096partitions, trying to detect ZFS pools. 1097After all pools are detected, 1098.Pa /boot/loader 1099is started from the first one found set as bootable. 1100.Pp 1101The VTOC8 scheme does not support embedding bootstrap code. 1102Instead, the 8 KBytes bootstrap code image 1103.Pa /boot/boot1 1104should be written with the 1105.Cm gpart bootcode 1106command with the 1107.Fl p Ar bootcode 1108option to all sufficiently large VTOC8 partitions. 1109To do this the 1110.Fl i Ar index 1111option could be omitted. 1112.Pp 1113The APM scheme also does not support embedding bootstrap code. 1114Instead, the 800 KBytes bootstrap code image 1115.Pa /boot/boot1.hfs 1116should be written with the 1117.Cm gpart bootcode 1118command to a partition of type 1119.Cm apple-boot , 1120which should also be 800 KB in size. 1121.Sh OPERATIONAL FLAGS 1122Actions other than the 1123.Cm commit 1124and 1125.Cm undo 1126actions take an optional 1127.Fl f Ar flags 1128option. 1129This option is used to specify action-specific operational flags. 1130By default, the 1131.Nm 1132utility defines the 1133.Ql C 1134flag so that the action is immediately 1135committed. 1136The user can specify 1137.Dq Fl f Cm x 1138to have the action result in a pending change that can later, with 1139other pending changes, be committed as a single compound change with 1140the 1141.Cm commit 1142action or reverted with the 1143.Cm undo 1144action. 1145.Sh RECOVERING 1146The GEOM PART class supports recovering of partition tables only for GPT. 1147The GPT primary metadata is stored at the beginning of the device. 1148For redundancy, a secondary 1149.Pq backup 1150copy of the metadata is stored at the end of the device. 1151As a result of having two copies, some corruption of metadata is not 1152fatal to the working of GPT. 1153When the kernel detects corrupt metadata, it marks this table as corrupt 1154and reports the problem. 1155.Cm destroy 1156and 1157.Cm recover 1158are the only operations allowed on corrupt tables. 1159.Pp 1160If one GPT header appears to be corrupt but the other copy remains intact, 1161the kernel will log the following: 1162.Bd -literal -offset indent 1163GEOM: provider: the primary GPT table is corrupt or invalid. 1164GEOM: provider: using the secondary instead -- recovery strongly advised. 1165.Ed 1166.Pp 1167or 1168.Bd -literal -offset indent 1169GEOM: provider: the secondary GPT table is corrupt or invalid. 1170GEOM: provider: using the primary only -- recovery suggested. 1171.Ed 1172.Pp 1173Also 1174.Nm 1175commands such as 1176.Cm show , status 1177and 1178.Cm list 1179will report about corrupt tables. 1180.Pp 1181If the size of the device has changed (e.g.,\& volume expansion) the 1182secondary GPT header will no longer be located in the last sector. 1183This is not a metadata corruption, but it is dangerous because any 1184corruption of the primary GPT will lead to loss of the partition table. 1185This problem is reported by the kernel with the message: 1186.Bd -literal -offset indent 1187GEOM: provider: the secondary GPT header is not in the last LBA. 1188.Ed 1189.Pp 1190This situation can be recovered with the 1191.Cm recover 1192command. 1193This command reconstructs the corrupt metadata using known valid 1194metadata and relocates the secondary GPT to the end of the device. 1195.Pp 1196.Em NOTE : 1197The GEOM PART class can detect the same partition table visible through 1198different GEOM providers, and some of them will be marked as corrupt. 1199Be careful when choosing a provider for recovery. 1200If you choose incorrectly you can destroy the metadata of another GEOM class, 1201e.g.,\& GEOM MIRROR or GEOM LABEL. 1202.Sh SYSCTL VARIABLES 1203The following 1204.Xr sysctl 8 1205variables can be used to control the behavior of the 1206.Nm PART 1207GEOM class. 1208The default value is shown next to each variable. 1209.Bl -tag -width indent 1210.It Va kern.geom.part.auto_resize: No 1 1211This variable controls automatic resize behavior of 1212.Nm 1213GEOM class. 1214When this variable is enable and new size of provider is detected, the schema 1215metadata is resized but all changes are not saved to disk, until 1216.Cm gpart commit 1217is run to confirm changes. 1218This behavior is also reported with diagnostic message: 1219.Sy "GEOM_PART: (provider) was automatically resized." 1220.Sy "Use `gpart commit (provider)` to save changes or `gpart undo (provider)`" 1221.Sy "to revert them." 1222.It Va kern.geom.part.check_integrity : No 1 1223This variable controls the behaviour of metadata integrity checks. 1224When integrity checks are enabled, the 1225.Nm PART 1226GEOM class verifies all generic partition parameters obtained from the 1227disk metadata. 1228If some inconsistency is detected, the partition table will be 1229rejected with a diagnostic message: 1230.Sy "GEOM_PART: Integrity check failed (provider, scheme)" . 1231.It Va kern.geom.part.ldm.debug : No 0 1232Debug level of the Logical Disk Manager (LDM) module. 1233This can be set to a number between 0 and 2 inclusive. 1234If set to 0 minimal debug information is printed, 1235and if set to 2 the maximum amount of debug information is printed. 1236.It Va kern.geom.part.ldm.show_mirrors : No 0 1237This variable controls how the Logical Disk Manager (LDM) module handles 1238mirrored volumes. 1239By default mirrored volumes are shown as partitions with type 1240.Cm ms-ldm-data 1241(see the 1242.Sx "PARTITION TYPES" 1243section). 1244If this variable set to 1 each component of the mirrored volume will be 1245present as independent partition. 1246.Em NOTE : 1247This may break a mirrored volume and lead to data damage. 1248.It Va kern.geom.part.mbr.enforce_chs : No 0 1249Specify how the Master Boot Record (MBR) module does alignment. 1250If this variable is set to a non-zero value, the module will automatically 1251recalculate the user-specified offset and size for alignment with the CHS 1252geometry. 1253Otherwise the values will be left unchanged. 1254.El 1255.Sh EXIT STATUS 1256Exit status is 0 on success, and 1 if the command fails. 1257.Sh EXAMPLES 1258The examples below assume that the disk's logical block size is 512 1259bytes, regardless of its physical block size. 1260.Ss GPT 1261In this example, we will format 1262.Pa ada0 1263with the GPT scheme and create boot, swap and root partitions. 1264First, we need to create the partition table: 1265.Bd -literal -offset indent 1266/sbin/gpart create -s GPT ada0 1267.Ed 1268.Pp 1269Next, we install a protective MBR with the first-stage bootstrap code. 1270The protective MBR lists a single, bootable partition spanning the 1271entire disk, thus allowing non-GPT-aware BIOSes to boot from the disk 1272and preventing tools which do not understand the GPT scheme from 1273considering the disk to be unformatted. 1274.Bd -literal -offset indent 1275/sbin/gpart bootcode -b /boot/pmbr ada0 1276.Ed 1277.Pp 1278We then create a dedicated 1279.Cm freebsd-boot 1280partition to hold the second-stage boot loader, which will load the 1281.Fx 1282kernel and modules from a UFS or ZFS filesystem. 1283This partition must be larger than the bootstrap code 1284.Po 1285either 1286.Pa /boot/gptboot 1287for UFS or 1288.Pa /boot/gptzfsboot 1289for ZFS 1290.Pc , 1291but smaller than 545 kB since the first-stage loader will load the 1292entire partition into memory during boot, regardless of how much data 1293it actually contains. 1294We create a 472-block (236 kB) boot partition at offset 40, which is 1295the size of the partition table (34 blocks or 17 kB) rounded up to the 1296nearest 4 kB boundary. 1297.Bd -literal -offset indent 1298/sbin/gpart add -b 40 -s 472 -t freebsd-boot ada0 1299/sbin/gpart bootcode -p /boot/gptboot -i 1 ada0 1300.Ed 1301.Pp 1302We now create a 4 GB swap partition at the first available offset, 1303which is 40 + 472 = 512 blocks (256 kB). 1304.Bd -literal -offset indent 1305/sbin/gpart add -s 4G -t freebsd-swap ada0 1306.Ed 1307.Pp 1308Aligning the swap partition and all subsequent partitions on a 256 kB 1309boundary ensures optimal performance on a wide range of media, from 1310plain old disks with 512-byte blocks, through modern 1311.Dq advanced format 1312disks with 4096-byte physical blocks, to RAID volumes with stripe 1313sizes of up to 256 kB. 1314.Pp 1315Finally, we create and format an 8 GB 1316.Cm freebsd-ufs 1317partition for the root filesystem, leaving the rest of the slice free 1318for additional filesystems: 1319.Bd -literal -offset indent 1320/sbin/gpart add -s 8G -t freebsd-ufs ada0 1321/sbin/newfs -Uj /dev/ada0p3 1322.Ed 1323.Ss MBR 1324In this example, we will format 1325.Pa ada0 1326with the MBR scheme and create a single partition which we subdivide 1327using a traditional 1328.Bx 1329disklabel. 1330.Pp 1331First, we create the partition table and a single 64 GB partition, 1332then we mark that partition active (bootable) and install the 1333first-stage boot loader: 1334.Bd -literal -offset indent 1335/sbin/gpart create -s MBR ada0 1336/sbin/gpart add -t freebsd -s 64G ada0 1337/sbin/gpart set -a active -i 1 ada0 1338/sbin/gpart bootcode -b /boot/boot0 ada0 1339.Ed 1340.Pp 1341Next, we create a disklabel in that partition 1342.Po 1343.Dq slice 1344in disklabel terminology 1345.Pc 1346with room for up to 20 partitions: 1347.Bd -literal -offset indent 1348/sbin/gpart create -s BSD -n 20 ada0s1 1349.Ed 1350.Pp 1351We then create an 8 GB root partition and a 4 GB swap partition: 1352.Bd -literal -offset indent 1353/sbin/gpart add -t freebsd-ufs -s 8G ada0s1 1354/sbin/gpart add -t freebsd-swap -s 4G ada0s1 1355.Ed 1356.Pp 1357Finally, we install the appropriate boot loader for the 1358.Bx 1359label: 1360.Bd -literal -offset indent 1361/sbin/gpart bootcode -b /boot/boot ada0s1 1362.Ed 1363.Ss VTOC8 1364.Pp 1365Create a VTOC8 scheme on 1366.Pa da0 : 1367.Bd -literal -offset indent 1368/sbin/gpart create -s VTOC8 da0 1369.Ed 1370.Pp 1371Create a 512MB-sized 1372.Cm freebsd-ufs 1373partition to contain a UFS filesystem from which the system can boot. 1374.Bd -literal -offset indent 1375/sbin/gpart add -s 512M -t freebsd-ufs da0 1376.Ed 1377.Pp 1378Create a 15GB-sized 1379.Cm freebsd-ufs 1380partition to contain a UFS filesystem and aligned on 4KB boundaries: 1381.Bd -literal -offset indent 1382/sbin/gpart add -s 15G -t freebsd-ufs -a 4k da0 1383.Ed 1384.Pp 1385After creating all required partitions, embed bootstrap code into them: 1386.Bd -literal -offset indent 1387/sbin/gpart bootcode -p /boot/boot1 da0 1388.Ed 1389.Ss Deleting Partitions and Destroying the Partitioning Scheme 1390If a 1391.Em "Device busy" 1392error is shown when trying to destroy a partition table, remember that 1393all of the partitions must be deleted first with the 1394.Cm delete 1395action. 1396In this example, 1397.Pa da0 1398has three partitions: 1399.Bd -literal -offset indent 1400/sbin/gpart delete -i 3 da0 1401/sbin/gpart delete -i 2 da0 1402/sbin/gpart delete -i 1 da0 1403/sbin/gpart destroy da0 1404.Ed 1405.Pp 1406Rather than deleting each partition and then destroying the partitioning 1407scheme, the 1408.Fl F 1409option can be given with 1410.Cm destroy 1411to delete all of the partitions before destroying the partitioning scheme. 1412This is equivalent to the previous example: 1413.Bd -literal -offset indent 1414/sbin/gpart destroy -F da0 1415.Ed 1416.Ss Backup and Restore 1417.Pp 1418Create a backup of the partition table from 1419.Pa da0 : 1420.Bd -literal -offset indent 1421/sbin/gpart backup da0 > da0.backup 1422.Ed 1423.Pp 1424Restore the partition table from the backup to 1425.Pa da0 : 1426.Bd -literal -offset indent 1427/sbin/gpart restore -l da0 < /mnt/da0.backup 1428.Ed 1429.Pp 1430Clone the partition table from 1431.Pa ada0 1432to 1433.Pa ada1 1434and 1435.Pa ada2 : 1436.Bd -literal -offset indent 1437/sbin/gpart backup ada0 | /sbin/gpart restore -F ada1 ada2 1438.Ed 1439.Sh SEE ALSO 1440.Xr geom 4 , 1441.Xr boot0cfg 8 , 1442.Xr geom 8 , 1443.Xr gptboot 8 1444.Sh HISTORY 1445The 1446.Nm 1447utility appeared in 1448.Fx 7.0 . 1449.Sh AUTHORS 1450.An Marcel Moolenaar Aq Mt marcel@FreeBSD.org 1451