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