1.\" Copyright (c) 1987, 1988, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" Symmetric Computer Systems. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. Neither the name of the University nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94 32.\" $FreeBSD: src/sbin/disklabel/disklabel.8,v 1.15.2.22 2003/04/17 17:56:34 trhodes Exp $ 33.\" 34.Dd August 3, 2012 35.Dt DISKLABEL64 8 36.Os 37.Sh NAME 38.Nm disklabel64 39.Nd read and write 64 bit disk pack label 40.Sh SYNOPSIS 41.Nm 42.Op Fl r 43.Ar disk 44.Nm 45.Fl w 46.Op Fl r 47.Op Fl n 48.Ar disk Ar disktype Ns / Ns Cm auto 49.Oo Ar packid Oc 50.Nm 51.Fl e 52.Op Fl r 53.Op Fl n 54.Ar disk 55.Nm 56.Fl R 57.Op Fl r 58.Op Fl n 59.Ar disk Ar protofile 60.Nm 61.Op Fl NW 62.Ar disk 63.Pp 64.Nm 65.Fl B 66.Oo 67.Fl b Ar boot1 68.Fl s Ar boot2 69.Oc 70.Ar disk 71.Oo Ar disktype Ns / Ns Cm auto Oc 72.Nm 73.Fl w 74.Fl B 75.Op Fl n 76.Oo 77.Fl b Ar boot1 78.Fl s Ar boot2 79.Oc 80.Ar disk Ar disktype Ns / Ns Cm auto 81.Oo Ar packid Oc 82.Nm 83.Fl R 84.Fl B 85.Op Fl n 86.Oo 87.Fl b Ar boot1 88.Fl s Ar boot2 89.Oc 90.Ar disk Ar protofile 91.Oo Ar disktype Ns / Ns Cm auto Oc 92.Sh DESCRIPTION 93The 94.Nm 95utility 96installs, examines or modifies a 64 bit label on a disk drive or pack. 97When writing 98the label, it can be used to change the drive identification, the disk 99partitions on the drive, or to replace a damaged label. 100There are several forms 101of the command that read (display), install or edit the label on a disk. 102In 103addition, 104.Nm 105can install bootstrap code. 106.Ss Raw or in-core label 107The disk label resides close to or at the beginning of each disk slice. 108For faster access, the kernel maintains a copy in core at all times. 109By 110default, most forms of the 111.Nm 112command access the in-core copy of the label. 113To access the raw (on-disk) 114copy, use the 115.Fl r 116option. 117This option allows a label to be installed on a disk without kernel 118support for a label, such as when labels are first installed on a system; it 119must be used when first installing a label on a disk. 120The specific effect of 121.Fl r 122is described under each command. 123.Ss Disk device name 124All 125.Nm 126forms require a disk device name, which should always be the raw 127device name representing the disk or slice. 128.Dx 129uses the following scheme for slice numbering: 130If the disk doesn't use GPT (typically laid out by 131.Xr gpt 8 ) , 132but e.g.\& MBR (typically laid out by 133.Xr fdisk 8 ) , 134then slice 0, e.g.\& 135.Pa da0s0 , 136represents the entire disk regardless of any DOS partitioning. 137Slice 0 is called the compatibility slice, 138and slice 1 and onward, e.g.\& 139.Pa da0s1 , 140represents a 141.Bx 142slice. 143If the disk does use GPT, then all slices are 144.Bx 145slices, slice 0 isn't special, it is just the first slice on the disk. 146You do not have to include the 147.Pa /dev/ 148path prefix when specifying the device. 149The 150.Nm 151utility will automatically prepend it. 152.Ss Reading the disk label 153To examine the label on a disk drive, use 154.Nm 155without options: 156.Pp 157.Nm 158.Op Fl r 159.Ar disk 160.Pp 161.Ar disk 162represents the raw disk in question, and may be in the form 163.Pa da0s1 164or 165.Pa /dev/da0s1 . 166It will display all of the parameters associated with the drive and its 167partition layout. 168Unless the 169.Fl r 170flag is given, 171the kernel's in-core copy of the label is displayed; 172if the disk has no label, or the partition types on the disk are incorrect, 173the kernel may have constructed or modified the label. 174If the 175.Fl r 176flag is given, 177.Nm 178reads the label from the raw disk and displays it. 179Both versions are usually 180identical except in the case where a label has not yet been initialized or 181is corrupt. 182.Ss Writing a standard label 183To write a standard label, use the form 184.Pp 185.Nm 186.Fl w 187.Op Fl r 188.Op Fl n 189.Ar disk Ar disktype Ns / Ns Cm auto 190.Oo Ar packid Oc 191.Pp 192The required arguments to 193.Nm 194are the drive to be labeled and the drive type as described in the 195.Xr disktab 5 196file. 197The drive parameters and partitions are taken from that file. 198If 199different disks of the same physical type are to have different partitions, it 200will be necessary to have separate disktab entries describing each, or to edit 201the label after installation as described below. 202The optional argument is a 203pack identification string, up to 16 characters long. 204The pack id must be 205quoted if it contains blanks. 206.Pp 207If the 208.Fl n 209flag is given, no data will be written to the device, and instead the 210disklabel that would have been written will be printed to stdout. 211.Pp 212If the 213.Fl r 214flag is given, the disk sectors containing the label and bootstrap 215will be written directly. 216A side-effect of this is that any existing bootstrap code will be overwritten 217and the disk rendered unbootable. 218See the boot options below for a method of 219writing the label and the bootstrap at the same time. 220If 221.Fl r 222is not specified, 223the existing label will be updated via the in-core copy and any bootstrap 224code will be unaffected. 225If the disk does not already have a label, the 226.Fl r 227flag must be used. 228In either case, the kernel's in-core label is replaced. 229.Pp 230For a virgin disk that is not known to 231.Xr disktab 5 , 232.Ar disktype 233can be specified as 234.Cm auto . 235In this case, the driver is requested to produce a virgin label for the 236disk. 237This might or might not be successful, depending on whether the 238driver for the disk is able to get the required data without reading 239anything from the disk at all. 240It will likely succeed for all SCSI 241disks, most IDE disks, and vnode devices. 242Writing a label to the 243disk is the only supported operation, and the 244.Ar disk 245itself must be provided as the canonical name, i.e.\& not as a full 246path name. 247.Pp 248For most harddisks, a label based on percentages for most partitions (and 249one partition with a size of 250.Ql * ) 251will produce a reasonable configuration. 252.Pp 253PC-based systems have special requirements in order for the BIOS to properly 254recognize a 255.Dx 256disklabel. 257Older systems may require what is known as a 258.Dq dangerously dedicated 259disklabel, which creates a fake DOS partition to work around problems older 260BIOSes have with modern disk geometries. 261On newer systems you generally want 262to create a normal DOS partition using 263.Ar fdisk 264and then create a 265.Dx 266disklabel within that slice. 267This is described 268later on in this page. 269.Pp 270Installing a new disklabel does not in of itself allow your system to boot 271a kernel using that label. 272You must also install boot blocks, which is 273described later on in this manual page. 274.Ss Editing an existing disk label 275To edit an existing disk label, use the form 276.Pp 277.Nm 278.Fl e 279.Op Fl r 280.Op Fl n 281.Ar disk 282.Pp 283This command reads the label from the in-core kernel copy, or directly from the 284disk if the 285.Fl r 286flag is also specified. 287The label is written to a file in ASCII and then 288supplied to an editor for changes. 289If no editor is specified in an 290.Ev EDITOR 291environment variable, 292.Xr vi 1 293is used. 294When the editor terminates, the label file is used to rewrite the disk label. 295Existing bootstrap code is unchanged regardless of whether 296.Fl r 297was specified. 298If 299.Fl n 300is specified, no data will be written to the device, and instead the 301disklabel that would have been written will be printed to stdout. 302This is 303useful to see how a partitioning scheme will work out for a specific disk. 304.Ss Restoring a disk label from a file 305To restore a disk label from a file, use the form 306.Pp 307.Nm 308.Fl R 309.Op Fl r 310.Op Fl n 311.Ar disk Ar protofile 312.Pp 313.Nm 314is capable of restoring a disk label that was previously saved in a file 315in ASCII format. 316The prototype file used to create the label should be in the same format 317as that produced when reading or editing a label. 318Comments are delimited by 319.Ql # 320and newline. 321As when writing a new label, any existing bootstrap code will be 322clobbered if 323.Fl r 324is specified and will be unaffected otherwise. 325See the boot options below for a 326method of restoring the label and writing the bootstrap at the same time. 327If 328.Fl n 329is used, no data will be written to the device, and instead the 330disklabel that would have been written will be printed to stdout. 331This is 332useful to see how a partitioning scheme will work out for a specific disk. 333.Ss Enabling and disabling writing to the disk label area 334By default, it is not possible to write to the disk label area at the beginning 335of a disk. 336The disk driver arranges for 337.Xr write 2 338and similar system calls 339to return 340.Er EROFS 341on any attempt to do so. 342If you need 343to write to this area (for example, to obliterate the label), use the form 344.Pp 345.Nm 346.Fl W 347.Ar disk 348.Pp 349To disallow writing to the label area after previously allowing it, 350use the command 351.Pp 352.Nm 353.Fl N 354.Ar disk 355.Ss Installing bootstraps 356The final three forms of 357.Nm 358are used to install bootstrap code, which allows boot from a 359.Xr HAMMER 5 360or 361.Xr UFS 5 362file system. 363If you are creating a 364.Dq dangerously-dedicated 365slice for compatibility with older PC systems, 366you generally want to specify the compatibility slice, such as 367.Pa da0s0 . 368If you are creating a label within an existing DOS slice, 369you should specify 370the slice name such as 371.Pa da0s1 . 372Making a slice bootable can be tricky. 373If you are using a normal DOS 374slice you typically install (or leave) a standard MBR on the base disk and 375then install the 376.Dx 377bootblocks in the slice. 378.Pp 379.Nm 380.Fl B 381.Oo 382.Fl b Ar boot1 383.Fl s Ar boot2 384.Oc 385.Ar disk 386.Oo Ar disktype Ns / Ns Cm auto Oc 387.Pp 388This form installs the bootstrap only. 389It does not change the disk label. 390You should never use this command on the compatibility slice unless you 391intend to create a 392.Dq dangerously-dedicated 393disk, such as 394.Ar da0s0 . 395This command is typically run on a 396.Bx 397slice such as 398.Ar da0s1 . 399.Pp 400.Nm 401.Fl w 402.Fl B 403.Op Fl n 404.Oo 405.Fl b Ar boot1 406.Fl s Ar boot2 407.Oc 408.Ar disk Ar disktype Ns / Ns Cm auto 409.Oo Ar packid Oc 410.Pp 411This form corresponds to the 412.Dq write label 413command described above. 414In addition to writing a new volume label, it also installs the bootstrap. 415If run on the compatibility slice this command will create a 416.Dq dangerously-dedicated 417label. 418This command is normally run on a 419.Bx 420slice rather than the compatibility slice. 421If 422.Fl n 423is used, no data will be written to the device, and instead the 424disklabel that would have been written will be printed to stdout. 425.Pp 426.Nm 427.Fl R 428.Fl B 429.Op Fl n 430.Oo 431.Fl b Ar boot1 432.Fl s Ar boot2 433.Oc 434.Ar disk Ar protofile 435.Oo Ar disktype Ns / Ns Cm auto Oc 436.Pp 437This form corresponds to the 438.Dq restore label 439command described above. 440In addition to restoring the volume label, it also installs the bootstrap. 441If run on the compatibility slice this command will create a 442.Dq dangerously-dedicated 443label. 444This command is normally run on a 445.Bx 446slice rather than the compatibility 447slice. 448.Pp 449The bootstrap commands always access the disk directly, 450so it is not necessary to specify the 451.Fl r 452flag. 453If 454.Fl n 455is used, no data will be written to the device, and instead the 456disklabel that would have been written will be printed to stdout. 457.Pp 458The bootstrap code is comprised of two boot programs. 459Specify the name of the 460boot programs to be installed in one of these ways: 461.Bl -enum 462.It 463Specify the names explicitly with the 464.Fl b 465and 466.Fl s 467flags. 468.Fl b 469indicates the primary boot program and 470.Fl s 471the secondary boot program. 472The boot programs are normally located in 473.Pa /boot . 474.It 475If the 476.Fl b 477and 478.Fl s 479flags are not specified, but 480.Ar disktype 481was specified, the names of the programs are taken from the 482.Dq b0 483and 484.Dq b1 485parameters of the 486.Xr disktab 5 487entry for the disk if the disktab entry exists and includes those parameters. 488.It 489Otherwise, the default boot image names are used: 490.Pa /boot/boot1_64 491and 492.Pa /boot/boot2_64 493for the standard stage1 and stage2 boot images. 494.El 495.Ss Initializing/Formatting a bootable disk from scratch 496To initialize a disk from scratch the following sequence is recommended. 497Please note that this will wipe everything that was previously on the disk, 498including any 499.No non- Ns Dx 500slices. 501.Bl -enum 502.It 503Use 504.Xr gpt 8 505or 506.Xr fdisk 8 507to initialize the hard disk, and create a GPT or MBR slice table, 508referred to as the 509.Dq "partition table" 510in 511.Tn DOS . 512.It 513Use 514.Nm 515or 516.Xr disklabel32 8 517to define partitions on 518.Dx 519slices created in the previous step. 520.It 521Finally use 522.Xr newfs_hammer 8 523or 524.Xr newfs 8 525to create file systems on new partitions. 526.El 527.Pp 528A typical partitioning scheme would be to have an 529.Ql a 530partition 531of approximately 512MB to hold the root file system, a 532.Ql b 533partition for 534swap (usually 4GB), a 535.Ql d 536partition for 537.Pa /var 538(usually 2GB), an 539.Ql e 540partition for 541.Pa /var/tmp 542(usually 2GB), an 543.Ql f 544partition for 545.Pa /usr 546(usually around 4GB), 547and finally a 548.Ql g 549partition for 550.Pa /home 551(usually all remaining space). 552If you are tight on space all sizes can be halved. 553Your mileage may vary. 554.Pp 555.Dl "gpt create da0" 556.Dl "gpt add da0" 557.Dl "disklabel64 -B -r -w da0s0 auto" 558.Dl "disklabel64 -e da0s0" 559.Sh ALIGNMENT 560When a virgin disklabel64 is laid down a 561.Dx 2.5 562or later kernel will align the partition start offset relative to the 563physical drive instead of relative to the slice start. 564This overcomes the issue of fdisk creating a badly aligned slice by default. 565The kernel will use a 1MiB (1024 * 1024 byte) alignment. 566The purpose of this alignment is to match swap and cluster operations 567against the physical block size of the underlying device. 568.Pp 569Even though nearly all devices still report a logical sector size of 512, 570newer hard drives are starting to use larger physical sector sizes 571and, in particular, solid state drives (SSDs) use a physical block size 572of 64K (SLC) or 128K (MLC). We choose a 1 megabyte alignment to cover our 573bases down the road. 64-bit disklabels are not designed to be put on 574ultra-tiny storage devices. 575.Pp 576It is worth noting that aligning cluster operations is particularly 577important for SSDs and doubly so when 578.Xr swapcache 8 579is used with a SSD. 580Swapcache is able to use large bulk writes which greatly reduces the degree 581of write magnification on SSD media and it is possible to get upwards of 5825x more endurance out of the device than the vendor spec sheet indicates. 583.Sh FILES 584.Bl -tag -width ".Pa /boot/boot2_64" -compact 585.It Pa /boot/boot1_64 586Default stage1 boot image. 587.It Pa /boot/boot2_64 588Default stage2 boot image. 589.It Pa /etc/disktab 590Disk description file. 591.El 592.Sh SAVED FILE FORMAT 593The 594.Nm 595utility uses an 596.Tn ASCII 597version of the label when examining, editing, or restoring a disk label. 598The format is: 599.Bd -literal -offset 4n 600# /dev/ad4s4: 601# 602# Informational fields calculated from the above 603# All byte equivalent offsets must be aligned 604# 605# boot space: 32768 bytes 606# data space: 121790552 blocks # 118936.09 MB (124713525248 bytes) 607# 608diskid: 5e3ef4db-4e24-11dd-8318-010e0cd0bad1 609label: 610boot2 data base: 0x000000001000 611partitions data base: 0x000000009000 612partitions data stop: 0x001d0981f000 613backup label: 0x001d0981f000 614total size: 0x001d09820000 # 118936.12 MB 615alignment: 4096 616display block size: 1024 # for partition display only 617 61816 partitions: 619# size offset fstype fsuuid 620 a: 524288 0 4.2BSD # 512.000MB 621 b: 4194304 524288 swap # 4096.000MB 622 d: 2097152 4718592 4.2BSD # 2048.000MB 623 e: 2097152 6815744 4.2BSD # 2048.000MB 624 f: 4194304 8912896 4.2BSD # 4096.000MB 625 g: 4194304 13107200 4.2BSD # 4096.000MB 626 h: 94003288 17301504 HAMMER # 91800.086MB 627 i: 5242880 111304792 ccd # 5120.000MB 628 j: 5242880 116547672 vinum # 5120.000MB 629 a-stor_uuid: 4370efdb-4e25-11dd-8318-010e0cd0bad1 630 b-stor_uuid: 4370eff4-4e25-11dd-8318-010e0cd0bad1 631 d-stor_uuid: 4370f00b-4e25-11dd-8318-010e0cd0bad1 632 e-stor_uuid: 4370f024-4e25-11dd-8318-010e0cd0bad1 633 f-stor_uuid: 4370f03a-4e25-11dd-8318-010e0cd0bad1 634 g-stor_uuid: 4370f053-4e25-11dd-8318-010e0cd0bad1 635 h-stor_uuid: 4370f06a-4e25-11dd-8318-010e0cd0bad1 636 i-stor_uuid: 4370f083-4e25-11dd-8318-010e0cd0bad1 637 j-stor_uuid: 4370f099-4e25-11dd-8318-010e0cd0bad1 638.Ed 639.Pp 640Lines starting with a 641.Ql # 642mark are comments. 643The specifications which can be changed are: 644.Bl -inset 645.It Ar label 646is an optional label, set by the 647.Ar packid 648option when writing a label. 649.It Ar "the partition table" 650is the 651.Ux 652partition table, not the 653.Tn DOS 654partition table described in 655.Xr fdisk 8 . 656.El 657.Pp 658The partition table can have up to 16 entries. 659It contains the following information: 660.Bl -tag -width indent 661.It Ar # 662The partition identifier is a single letter in the range 663.Ql a 664to 665.Ql p . 666.It Ar size 667The size of the partition in sectors, 668.Cm K 669(kilobytes - 1024), 670.Cm M 671(megabytes - 1024*1024), 672.Cm G 673(gigabytes - 1024*1024*1024), 674.Cm T 675(terabytes - 1024*1024*1024*1024), 676.Cm % 677(percentage of free space 678.Em after 679removing any fixed-size partitions), 680.Cm * 681(all remaining free space 682.Em after 683fixed-size and percentage partitions). 684Lowercase versions of 685.Cm K , M , G , 686and 687.Cm T 688are allowed. 689Size and type should be specified without any spaces between them. 690.Pp 691Example: 2097152, 1G, 1024M and 1048576K are all the same size 692(assuming 512-byte sectors). 693.It Ar offset 694The offset of the start of the partition from the beginning of the 695drive in sectors, or 696.Cm * 697to have 698.Nm 699calculate the correct offset to use (the end of the previous partition plus 700one. 701.It Ar fstype 702Describes the purpose of the partition. 703The example shows all currently used partition types. 704For 705.Xr UFS 5 706file systems, use type 707.Cm 4.2BSD . 708For 709.Xr HAMMER 5 710file systems, use type 711.Cm HAMMER . 712For 713.Xr hammer2 8 714file systems, use type 715.Cm HAMMER2 . 716For 717.Xr ccd 4 718partitions, use type 719.Cm ccd . 720For Vinum drives, use type 721.Cm vinum . 722Other common types are 723.Cm swap 724and 725.Cm unused . 726The 727.Nm 728utility 729also knows about a number of other partition types, 730none of which are in current use. 731(See 732.Dv fstypenames 733in 734.In sys/dtype.h 735for more details). 736.El 737.Pp 738The remainder of the line is a comment and shows the size of 739the partition in MB. 740.Sh EXAMPLES 741.Dl "disklabel64 da0s1" 742.Pp 743Display the in-core label for the first slice of the 744.Pa da0 745disk, as obtained via 746.Pa /dev/da0s1 . 747(If the disk is 748.Dq dangerously-dedicated , 749the compatibility slice name should be specified, such as 750.Pa da0s0 . ) 751.Pp 752.Dl "disklabel64 da0s1 > savedlabel" 753.Pp 754Save the in-core label for 755.Pa da0s1 756into the file 757.Pa savedlabel . 758This file can be used with the 759.Fl R 760option to restore the label at a later date. 761.Pp 762.Dl "disklabel64 -w -r /dev/da0s1 da2212 foo" 763.Pp 764Create a label for 765.Pa da0s1 766based on information for 767.Dq da2212 768found in 769.Pa /etc/disktab . 770Any existing bootstrap code will be clobbered 771and the disk rendered unbootable. 772.Pp 773.Dl "disklabel64 -e -r da0s1" 774.Pp 775Read the on-disk label for 776.Pa da0s1 , 777edit it, and reinstall in-core as well as on-disk. 778Existing bootstrap code is unaffected. 779.Pp 780.Dl "disklabel64 -e -r -n da0s1" 781.Pp 782Read the on-disk label for 783.Pa da0s1 , 784edit it, and display what the new label would be (in sectors). 785It does 786.Em not 787install the new label either in-core or on-disk. 788.Pp 789.Dl "disklabel64 -r -w da0s1 auto" 790.Pp 791Try to auto-detect the required information from 792.Pa da0s1 , 793and write a new label to the disk. 794Use another 795.Nm Fl e 796command to edit the partitioning information. 797.Pp 798.Dl "disklabel64 -R da0s1 savedlabel" 799.Pp 800Restore the on-disk and in-core label for 801.Pa da0s1 802from information in 803.Pa savedlabel . 804Existing bootstrap code is unaffected. 805.Pp 806.Dl "disklabel64 -R -n da0s1 label_layout" 807.Pp 808Display what the label would be for 809.Pa da0s1 810using the partition layout in 811.Pa label_layout . 812This is useful for determining how much space would be allotted for various 813partitions with a labelling scheme using 814.Cm % Ns -based 815or 816.Cm * 817partition sizes. 818.Pp 819.Dl "disklabel64 -B da0s1" 820.Pp 821Install a new bootstrap on 822.Pa da0s1 . 823The boot code comes from 824.Pa /boot/boot1_64 825and possibly 826.Pa /boot/boot2_64 . 827On-disk and in-core labels are unchanged. 828.Pp 829.Dl "disklabel64 -w -B /dev/da0s1 -b newboot1 -s newboot2 da2212" 830.Pp 831Install a new label and bootstrap. 832The label is derived from disktab information for 833.Dq da2212 834and installed both in-core and on-disk. 835The bootstrap code comes from the files 836.Pa newboot1 837and 838.Pa newboot2 . 839.Pp 840.Dl "dd if=/dev/zero of=/dev/da0 bs=512 count=32" 841.Dl "fdisk -BI da0" 842.Dl "dd if=/dev/zero of=/dev/da0s1 bs=512 count=32" 843.Dl "disklabel64 -w -B da0s1 auto" 844.Dl "disklabel64 -e da0s1" 845.Pp 846Completely wipe any prior information on the disk, creating a new bootable 847disk with a DOS partition table containing one 848.Dq whole-disk 849slice. 850Then 851initialize the slice, then edit it to your needs. 852The 853.Pa dd 854commands are optional, but may be necessary for some BIOSes to properly 855recognize the disk. 856.Pp 857.Dl "disklabel64 -W da0s1" 858.Dl "dd if=/dev/zero of=/dev/da0s1 bs=512 count=32" 859.Dl "disklabel -r -w da0s1 auto" 860.Dl "disklabel -N da0s1" 861.Pp 862Completely wipe any prior information on the slice, 863changing label format to 32 bit. 864The wiping is needed as 865.Nm disklabel 866and 867.Nm , 868as a safety measure, 869won't do any operations if label with other format is already installed. 870.Pp 871This is an example disklabel that uses some of the new partition size types 872such as 873.Cm % , M , G , 874and 875.Cm * , 876which could be used as a source file for 877.Pp 878.Dl "disklabel64 -R ad0s1 new_label_file" 879.Bd -literal -offset 4n 880# /dev/ad4s4: 881# 882# Informational fields calculated from the above 883# All byte equivalent offsets must be aligned 884# 885# boot space: 32768 bytes 886# data space: 121790552 blocks # 118936.09 MB (124713525248 bytes) 887# 888diskid: b1db58a3-4e26-11dd-8318-010e0cd0bad1 889label: 890boot2 data base: 0x000000001000 891partitions data base: 0x000000009000 892partitions data stop: 0x001d0981f000 893backup label: 0x001d0981f000 894total size: 0x001d09820000 # 118936.12 MB 895alignment: 4096 896display block size: 1024 # for partition display only 897 89816 partitions: 899# size offset fstype fsuuid 900 a: 512M 0 4.2BSD 901 b: 4G * swap 902 d: 2G * 4.2BSD 903 e: 2048M * 4.2BSD 904 f: 4G * 4.2BSD 905 g: 4G * 4.2BSD 906 h: 50G * HAMMER 907 i: * * HAMMER2 908 j: 5g * ccd 909 k: 5120m * vinum 910.Ed 911.Sh DIAGNOSTICS 912The kernel device drivers will not allow the size of a disk partition 913to be decreased or the offset of a partition to be changed while it is open. 914Some device drivers create a label containing only a single large partition 915if a disk is unlabeled; thus, the label must be written to the 916.Ql a 917partition of the disk while it is open. 918This sometimes requires the desired 919label to be set in two steps, the first one creating at least one other 920partition, and the second setting the label on the new partition while 921shrinking the 922.Ql a 923partition. 924.Sh SEE ALSO 925.Xr dd 1 , 926.Xr uuid 3 , 927.Xr ccd 4 , 928.Xr disklabel64 5 , 929.Xr disktab 5 , 930.Xr boot0cfg 8 , 931.Xr diskinfo 8 , 932.Xr disklabel32 8 , 933.Xr fdisk 8 , 934.Xr gpt 8 , 935.Xr hammer2 8 , 936.Xr newfs 8 , 937.Xr newfs_hammer 8 , 938.Xr vinum 8 939.Sh BUGS 940The 941.Nm 942utility 943does not perform all possible error checking. 944Warning 945.Em is 946given if partitions 947overlap; if an absolute offset does not match the expected offset; if a 948partition runs past the end of the device; and a number of other errors; but 949no warning is given if space remains unused. 950