1ce19f97eSMatthew Dillon.\" Copyright (c) 1987, 1988, 1991, 1993 2ce19f97eSMatthew Dillon.\" The Regents of the University of California. All rights reserved. 3ce19f97eSMatthew Dillon.\" 4ce19f97eSMatthew Dillon.\" This code is derived from software contributed to Berkeley by 5ce19f97eSMatthew Dillon.\" Symmetric Computer Systems. 6ce19f97eSMatthew Dillon.\" 7ce19f97eSMatthew Dillon.\" Redistribution and use in source and binary forms, with or without 8ce19f97eSMatthew Dillon.\" modification, are permitted provided that the following conditions 9ce19f97eSMatthew Dillon.\" are met: 10ce19f97eSMatthew Dillon.\" 1. Redistributions of source code must retain the above copyright 11ce19f97eSMatthew Dillon.\" notice, this list of conditions and the following disclaimer. 12ce19f97eSMatthew Dillon.\" 2. Redistributions in binary form must reproduce the above copyright 13ce19f97eSMatthew Dillon.\" notice, this list of conditions and the following disclaimer in the 14ce19f97eSMatthew Dillon.\" documentation and/or other materials provided with the distribution. 15*956f4b31Szrj.\" 3. Neither the name of the University nor the names of its contributors 16ce19f97eSMatthew Dillon.\" may be used to endorse or promote products derived from this software 17ce19f97eSMatthew Dillon.\" without specific prior written permission. 18ce19f97eSMatthew Dillon.\" 19ce19f97eSMatthew Dillon.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20ce19f97eSMatthew Dillon.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21ce19f97eSMatthew Dillon.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22ce19f97eSMatthew Dillon.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23ce19f97eSMatthew Dillon.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24ce19f97eSMatthew Dillon.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25ce19f97eSMatthew Dillon.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26ce19f97eSMatthew Dillon.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27ce19f97eSMatthew Dillon.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28ce19f97eSMatthew Dillon.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29ce19f97eSMatthew Dillon.\" SUCH DAMAGE. 30ce19f97eSMatthew Dillon.\" 31ce19f97eSMatthew Dillon.\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94 32ce19f97eSMatthew Dillon.\" $FreeBSD: src/sbin/disklabel/disklabel.8,v 1.15.2.22 2003/04/17 17:56:34 trhodes Exp $ 33ce19f97eSMatthew Dillon.\" 34f61a91d2SSascha Wildner.Dd August 3, 2012 35c61a095dSThomas Nikolajsen.Dt DISKLABEL32 8 36ce19f97eSMatthew Dillon.Os 37ce19f97eSMatthew Dillon.Sh NAME 38c61a095dSThomas Nikolajsen.Nm disklabel32 39ce19f97eSMatthew Dillon.Nd read and write 32 bit disk pack label 40ce19f97eSMatthew Dillon.Sh SYNOPSIS 41ce19f97eSMatthew Dillon.Nm 42ce19f97eSMatthew Dillon.Op Fl r 43ce19f97eSMatthew Dillon.Ar disk 44ce19f97eSMatthew Dillon.Nm 45ce19f97eSMatthew Dillon.Fl w 46ce19f97eSMatthew Dillon.Op Fl r 47ce19f97eSMatthew Dillon.Op Fl n 48ce19f97eSMatthew Dillon.Ar disk Ar disktype Ns / Ns Cm auto 49ce19f97eSMatthew Dillon.Oo Ar packid Oc 50ce19f97eSMatthew Dillon.Nm 51ce19f97eSMatthew Dillon.Fl e 52ce19f97eSMatthew Dillon.Op Fl r 53ce19f97eSMatthew Dillon.Op Fl n 54ce19f97eSMatthew Dillon.Ar disk 55ce19f97eSMatthew Dillon.Nm 56ce19f97eSMatthew Dillon.Fl R 57ce19f97eSMatthew Dillon.Op Fl r 58ce19f97eSMatthew Dillon.Op Fl n 59ce19f97eSMatthew Dillon.Ar disk Ar protofile 60ce19f97eSMatthew Dillon.Nm 61ce19f97eSMatthew Dillon.Op Fl NW 62ce19f97eSMatthew Dillon.Ar disk 63ce19f97eSMatthew Dillon.Pp 64ce19f97eSMatthew Dillon.Nm 65ce19f97eSMatthew Dillon.Fl B 66ce19f97eSMatthew Dillon.Oo 67ce19f97eSMatthew Dillon.Fl b Ar boot1 68ce19f97eSMatthew Dillon.Fl s Ar boot2 69ce19f97eSMatthew Dillon.Oc 70ce19f97eSMatthew Dillon.Ar disk 71ce19f97eSMatthew Dillon.Oo Ar disktype Ns / Ns Cm auto Oc 72ce19f97eSMatthew Dillon.Nm 73ce19f97eSMatthew Dillon.Fl w 74ce19f97eSMatthew Dillon.Fl B 75ce19f97eSMatthew Dillon.Op Fl n 76ce19f97eSMatthew Dillon.Oo 77ce19f97eSMatthew Dillon.Fl b Ar boot1 78ce19f97eSMatthew Dillon.Fl s Ar boot2 79ce19f97eSMatthew Dillon.Oc 80ce19f97eSMatthew Dillon.Ar disk Ar disktype Ns / Ns Cm auto 81ce19f97eSMatthew Dillon.Oo Ar packid Oc 82ce19f97eSMatthew Dillon.Nm 83ce19f97eSMatthew Dillon.Fl R 84ce19f97eSMatthew Dillon.Fl B 85ce19f97eSMatthew Dillon.Op Fl n 86ce19f97eSMatthew Dillon.Oo 87ce19f97eSMatthew Dillon.Fl b Ar boot1 88ce19f97eSMatthew Dillon.Fl s Ar boot2 89ce19f97eSMatthew Dillon.Oc 90ce19f97eSMatthew Dillon.Ar disk Ar protofile 91ce19f97eSMatthew Dillon.Oo Ar disktype Ns / Ns Cm auto Oc 92ce19f97eSMatthew Dillon.Nm 93ce19f97eSMatthew Dillon.Fl f Ar slice_start_lba 94ce19f97eSMatthew Dillon.Oo Ar options Oc 95ce19f97eSMatthew Dillon.Sh DESCRIPTION 96ce19f97eSMatthew DillonThe 97ce19f97eSMatthew Dillon.Nm 98ce19f97eSMatthew Dillonutility 99ce19f97eSMatthew Dilloninstalls, examines or modifies a 32 bit label on a disk drive or pack. 100ce19f97eSMatthew DillonWhen writing 101ce19f97eSMatthew Dillonthe label, it can be used to change the drive identification, the disk 102ce19f97eSMatthew Dillonpartitions on the drive, or to replace a damaged label. 103ce19f97eSMatthew DillonThere are several forms 104ce19f97eSMatthew Dillonof the command that read (display), install or edit the label on a disk. 105ce19f97eSMatthew DillonIn 106ce19f97eSMatthew Dillonaddition, 107ce19f97eSMatthew Dillon.Nm 108ce19f97eSMatthew Dilloncan install bootstrap code. 109ce19f97eSMatthew Dillon.Ss Raw or in-core label 110ce19f97eSMatthew DillonThe disk label resides close to or at the beginning of each disk slice. 111ce19f97eSMatthew DillonFor faster access, the kernel maintains a copy in core at all times. 112ce19f97eSMatthew DillonBy 113ce19f97eSMatthew Dillondefault, most forms of the 114ce19f97eSMatthew Dillon.Nm 115ce19f97eSMatthew Dilloncommand access the in-core copy of the label. 116ce19f97eSMatthew DillonTo access the raw (on-disk) 117ce19f97eSMatthew Dilloncopy, use the 118ce19f97eSMatthew Dillon.Fl r 119ce19f97eSMatthew Dillonoption. 120ce19f97eSMatthew DillonThis option allows a label to be installed on a disk without kernel 121ce19f97eSMatthew Dillonsupport for a label, such as when labels are first installed on a system; it 122ce19f97eSMatthew Dillonmust be used when first installing a label on a disk. 123ce19f97eSMatthew DillonThe specific effect of 124ce19f97eSMatthew Dillon.Fl r 125ce19f97eSMatthew Dillonis described under each command. 126ce19f97eSMatthew Dillon.Ss Disk device name 127ce19f97eSMatthew DillonAll 128ce19f97eSMatthew Dillon.Nm 129ce19f97eSMatthew Dillonforms require a disk device name, which should always be the raw 130ce19f97eSMatthew Dillondevice name representing the disk or slice. 131ce19f97eSMatthew Dillon.Dx 132ce19f97eSMatthew Dillonuses the following scheme for slice numbering: 133ce19f97eSMatthew DillonIf the disk doesn't use GPT (typically laid out by 134ce19f97eSMatthew Dillon.Xr gpt 8 ) , 135ce19f97eSMatthew Dillonbut e.g.\& MBR (typically laid out by 136ce19f97eSMatthew Dillon.Xr fdisk 8 ) , 137ce19f97eSMatthew Dillonthen slice 0, e.g.\& 138ce19f97eSMatthew Dillon.Pa da0s0 , 139ce19f97eSMatthew Dillonrepresents the entire disk regardless of any DOS partitioning. 140ce19f97eSMatthew DillonSlice 0 is called the compatibility slice, 141ce19f97eSMatthew Dillonand slice 1 and onward, e.g.\& 142ce19f97eSMatthew Dillon.Pa da0s1 , 143ce19f97eSMatthew Dillonrepresents a 144ce19f97eSMatthew Dillon.Bx 145ce19f97eSMatthew Dillonslice. 146ce19f97eSMatthew DillonIf the disk does use GPT, then all slices are 147ce19f97eSMatthew Dillon.Bx 148ce19f97eSMatthew Dillonslices, slice 0 isn't special, it is just the first slice on the disk. 149ce19f97eSMatthew DillonYou do not have to include the 150ce19f97eSMatthew Dillon.Pa /dev/ 151ce19f97eSMatthew Dillonpath prefix when specifying the device. 152ce19f97eSMatthew DillonThe 153ce19f97eSMatthew Dillon.Nm 154ce19f97eSMatthew Dillonutility will automatically prepend it. 155ce19f97eSMatthew Dillon.Ss Reading the disk label 156ce19f97eSMatthew DillonTo examine the label on a disk drive, use 157ce19f97eSMatthew Dillon.Nm 158ce19f97eSMatthew Dillonwithout options: 159ce19f97eSMatthew Dillon.Pp 160ce19f97eSMatthew Dillon.Nm 161ce19f97eSMatthew Dillon.Op Fl r 162ce19f97eSMatthew Dillon.Ar disk 163ce19f97eSMatthew Dillon.Pp 164ce19f97eSMatthew Dillon.Ar disk 165ce19f97eSMatthew Dillonrepresents the raw disk in question, and may be in the form 166ce19f97eSMatthew Dillon.Pa da0s1 167ce19f97eSMatthew Dillonor 168ce19f97eSMatthew Dillon.Pa /dev/da0s1 . 169ce19f97eSMatthew DillonIt will display all of the parameters associated with the drive and its 170ce19f97eSMatthew Dillonpartition layout. 171ce19f97eSMatthew DillonUnless the 172ce19f97eSMatthew Dillon.Fl r 173ce19f97eSMatthew Dillonflag is given, 174ce19f97eSMatthew Dillonthe kernel's in-core copy of the label is displayed; 175ce19f97eSMatthew Dillonif the disk has no label, or the partition types on the disk are incorrect, 176ce19f97eSMatthew Dillonthe kernel may have constructed or modified the label. 177ce19f97eSMatthew DillonIf the 178ce19f97eSMatthew Dillon.Fl r 179ce19f97eSMatthew Dillonflag is given, 180ce19f97eSMatthew Dillon.Nm 181ce19f97eSMatthew Dillonreads the label from the raw disk and displays it. 182ce19f97eSMatthew DillonBoth versions are usually 183ce19f97eSMatthew Dillonidentical except in the case where a label has not yet been initialized or 184ce19f97eSMatthew Dillonis corrupt. 185ce19f97eSMatthew Dillon.Ss Writing a standard label 186ce19f97eSMatthew DillonTo write a standard label, use the form 187ce19f97eSMatthew Dillon.Pp 188ce19f97eSMatthew Dillon.Nm 189ce19f97eSMatthew Dillon.Fl w 190ce19f97eSMatthew Dillon.Op Fl r 191ce19f97eSMatthew Dillon.Op Fl n 192ce19f97eSMatthew Dillon.Ar disk Ar disktype Ns / Ns Cm auto 193ce19f97eSMatthew Dillon.Oo Ar packid Oc 194ce19f97eSMatthew Dillon.Pp 195ce19f97eSMatthew DillonThe required arguments to 196ce19f97eSMatthew Dillon.Nm 197ce19f97eSMatthew Dillonare the drive to be labeled and the drive type as described in the 198ce19f97eSMatthew Dillon.Xr disktab 5 199ce19f97eSMatthew Dillonfile. 200ce19f97eSMatthew DillonThe drive parameters and partitions are taken from that file. 201ce19f97eSMatthew DillonIf 202ce19f97eSMatthew Dillondifferent disks of the same physical type are to have different partitions, it 203ce19f97eSMatthew Dillonwill be necessary to have separate disktab entries describing each, or to edit 204ce19f97eSMatthew Dillonthe label after installation as described below. 205ce19f97eSMatthew DillonThe optional argument is a 206ce19f97eSMatthew Dillonpack identification string, up to 16 characters long. 207ce19f97eSMatthew DillonThe pack id must be 208ce19f97eSMatthew Dillonquoted if it contains blanks. 209ce19f97eSMatthew Dillon.Pp 210ce19f97eSMatthew DillonIf the 211ce19f97eSMatthew Dillon.Fl n 212ce19f97eSMatthew Dillonflag is given, no data will be written to the device, and instead the 213ce19f97eSMatthew Dillondisklabel that would have been written will be printed to stdout. 214ce19f97eSMatthew Dillon.Pp 215ce19f97eSMatthew DillonIf the 216ce19f97eSMatthew Dillon.Fl r 217ce19f97eSMatthew Dillonflag is given, the disk sectors containing the label and bootstrap 218ce19f97eSMatthew Dillonwill be written directly. 219ce19f97eSMatthew DillonA side-effect of this is that any existing bootstrap code will be overwritten 220ce19f97eSMatthew Dillonand the disk rendered unbootable. 221ce19f97eSMatthew DillonSee the boot options below for a method of 222ce19f97eSMatthew Dillonwriting the label and the bootstrap at the same time. 223ce19f97eSMatthew DillonIf 224ce19f97eSMatthew Dillon.Fl r 225ce19f97eSMatthew Dillonis not specified, 226ce19f97eSMatthew Dillonthe existing label will be updated via the in-core copy and any bootstrap 227ce19f97eSMatthew Dilloncode will be unaffected. 228ce19f97eSMatthew DillonIf the disk does not already have a label, the 229ce19f97eSMatthew Dillon.Fl r 230ce19f97eSMatthew Dillonflag must be used. 231ce19f97eSMatthew DillonIn either case, the kernel's in-core label is replaced. 232ce19f97eSMatthew Dillon.Pp 233ce19f97eSMatthew DillonFor a virgin disk that is not known to 234ce19f97eSMatthew Dillon.Xr disktab 5 , 235ce19f97eSMatthew Dillon.Ar disktype 236ce19f97eSMatthew Dilloncan be specified as 237ce19f97eSMatthew Dillon.Cm auto . 238ce19f97eSMatthew DillonIn this case, the driver is requested to produce a virgin label for the 239ce19f97eSMatthew Dillondisk. 240ce19f97eSMatthew DillonThis might or might not be successful, depending on whether the 241ce19f97eSMatthew Dillondriver for the disk is able to get the required data without reading 242ce19f97eSMatthew Dillonanything from the disk at all. 243ce19f97eSMatthew DillonIt will likely succeed for all SCSI 244ce19f97eSMatthew Dillondisks, most IDE disks, and vnode devices. 245ce19f97eSMatthew DillonWriting a label to the 246ce19f97eSMatthew Dillondisk is the only supported operation, and the 247ce19f97eSMatthew Dillon.Ar disk 248ce19f97eSMatthew Dillonitself must be provided as the canonical name, i.e.\& not as a full 249ce19f97eSMatthew Dillonpath name. 250ce19f97eSMatthew Dillon.Pp 251ce19f97eSMatthew DillonFor most harddisks, a label based on percentages for most partitions (and 252ce19f97eSMatthew Dillonone partition with a size of 253ce19f97eSMatthew Dillon.Ql * ) 254ce19f97eSMatthew Dillonwill produce a reasonable configuration. 255ce19f97eSMatthew Dillon.Pp 256ce19f97eSMatthew DillonPC-based systems have special requirements in order for the BIOS to properly 257ce19f97eSMatthew Dillonrecognize a 258ce19f97eSMatthew Dillon.Dx 259ce19f97eSMatthew Dillondisklabel. 260ce19f97eSMatthew DillonOlder systems may require what is known as a 261ce19f97eSMatthew Dillon.Dq dangerously dedicated 262ce19f97eSMatthew Dillondisklabel, which creates a fake DOS partition to work around problems older 263ce19f97eSMatthew DillonBIOSes have with modern disk geometries. 264ce19f97eSMatthew DillonOn newer systems you generally want 265ce19f97eSMatthew Dillonto create a normal DOS partition using 266ce19f97eSMatthew Dillon.Ar fdisk 267ce19f97eSMatthew Dillonand then create a 268ce19f97eSMatthew Dillon.Dx 269ce19f97eSMatthew Dillondisklabel within that slice. 270ce19f97eSMatthew DillonThis is described 271ce19f97eSMatthew Dillonlater on in this page. 272ce19f97eSMatthew Dillon.Pp 273ce19f97eSMatthew DillonInstalling a new disklabel does not in of itself allow your system to boot 274ce19f97eSMatthew Dillona kernel using that label. 275ce19f97eSMatthew DillonYou must also install boot blocks, which is 276ce19f97eSMatthew Dillondescribed later on in this manual page. 277ce19f97eSMatthew Dillon.Ss Editing an existing disk label 278ce19f97eSMatthew DillonTo edit an existing disk label, use the form 279ce19f97eSMatthew Dillon.Pp 280ce19f97eSMatthew Dillon.Nm 281ce19f97eSMatthew Dillon.Fl e 282ce19f97eSMatthew Dillon.Op Fl r 283ce19f97eSMatthew Dillon.Op Fl n 284ce19f97eSMatthew Dillon.Ar disk 285ce19f97eSMatthew Dillon.Pp 286ce19f97eSMatthew DillonThis command reads the label from the in-core kernel copy, or directly from the 287ce19f97eSMatthew Dillondisk if the 288ce19f97eSMatthew Dillon.Fl r 289ce19f97eSMatthew Dillonflag is also specified. 290ce19f97eSMatthew DillonThe label is written to a file in ASCII and then 291ce19f97eSMatthew Dillonsupplied to an editor for changes. 292ce19f97eSMatthew DillonIf no editor is specified in an 293ce19f97eSMatthew Dillon.Ev EDITOR 294ce19f97eSMatthew Dillonenvironment variable, 295ce19f97eSMatthew Dillon.Xr vi 1 296ce19f97eSMatthew Dillonis used. 297ce19f97eSMatthew DillonWhen the editor terminates, the label file is used to rewrite the disk label. 298ce19f97eSMatthew DillonExisting bootstrap code is unchanged regardless of whether 299ce19f97eSMatthew Dillon.Fl r 300ce19f97eSMatthew Dillonwas specified. 301ce19f97eSMatthew DillonIf 302ce19f97eSMatthew Dillon.Fl n 303ce19f97eSMatthew Dillonis specified, no data will be written to the device, and instead the 304ce19f97eSMatthew Dillondisklabel that would have been written will be printed to stdout. 305ce19f97eSMatthew DillonThis is 306ce19f97eSMatthew Dillonuseful to see how a partitioning scheme will work out for a specific disk. 307ce19f97eSMatthew Dillon.Ss Restoring a disk label from a file 308ce19f97eSMatthew DillonTo restore a disk label from a file, use the form 309ce19f97eSMatthew Dillon.Pp 310ce19f97eSMatthew Dillon.Nm 311ce19f97eSMatthew Dillon.Fl R 312ce19f97eSMatthew Dillon.Op Fl r 313ce19f97eSMatthew Dillon.Op Fl n 314ce19f97eSMatthew Dillon.Ar disk Ar protofile 315ce19f97eSMatthew Dillon.Pp 316ce19f97eSMatthew Dillon.Nm 317ce19f97eSMatthew Dillonis capable of restoring a disk label that was previously saved in a file 318ce19f97eSMatthew Dillonin ASCII format. 319ce19f97eSMatthew DillonThe prototype file used to create the label should be in the same format 320ce19f97eSMatthew Dillonas that produced when reading or editing a label. 321ce19f97eSMatthew DillonComments are delimited by 322ce19f97eSMatthew Dillon.Ql # 323ce19f97eSMatthew Dillonand newline. 324ce19f97eSMatthew DillonAs when writing a new label, any existing bootstrap code will be 325ce19f97eSMatthew Dillonclobbered if 326ce19f97eSMatthew Dillon.Fl r 327ce19f97eSMatthew Dillonis specified and will be unaffected otherwise. 328ce19f97eSMatthew DillonSee the boot options below for a 329ce19f97eSMatthew Dillonmethod of restoring the label and writing the bootstrap at the same time. 330ce19f97eSMatthew DillonIf 331ce19f97eSMatthew Dillon.Fl n 332ce19f97eSMatthew Dillonis used, no data will be written to the device, and instead the 333ce19f97eSMatthew Dillondisklabel that would have been written will be printed to stdout. 334ce19f97eSMatthew DillonThis is 335ce19f97eSMatthew Dillonuseful to see how a partitioning scheme will work out for a specific disk. 336ce19f97eSMatthew Dillon.Ss Enabling and disabling writing to the disk label area 337ce19f97eSMatthew DillonBy default, it is not possible to write to the disk label area at the beginning 338ce19f97eSMatthew Dillonof a disk. 339ce19f97eSMatthew DillonThe disk driver arranges for 340ce19f97eSMatthew Dillon.Xr write 2 341ce19f97eSMatthew Dillonand similar system calls 342ce19f97eSMatthew Dillonto return 343ce19f97eSMatthew Dillon.Er EROFS 344ce19f97eSMatthew Dillonon any attempt to do so. 345ce19f97eSMatthew DillonIf you need 346ce19f97eSMatthew Dillonto write to this area (for example, to obliterate the label), use the form 347ce19f97eSMatthew Dillon.Pp 348ce19f97eSMatthew Dillon.Nm 349ce19f97eSMatthew Dillon.Fl W 350ce19f97eSMatthew Dillon.Ar disk 351ce19f97eSMatthew Dillon.Pp 352ce19f97eSMatthew DillonTo disallow writing to the label area after previously allowing it, 353ce19f97eSMatthew Dillonuse the command 354ce19f97eSMatthew Dillon.Pp 355ce19f97eSMatthew Dillon.Nm 356ce19f97eSMatthew Dillon.Fl N 357ce19f97eSMatthew Dillon.Ar disk 358ce19f97eSMatthew Dillon.Ss Installing bootstraps 359ce19f97eSMatthew DillonThe final three forms of 360ce19f97eSMatthew Dillon.Nm 361ce19f97eSMatthew Dillonare used to install bootstrap code, which allows boot from a 362ce19f97eSMatthew Dillon.Xr UFS 5 363ce19f97eSMatthew Dillonfile system. 364ce19f97eSMatthew DillonIf you are creating a 365ce19f97eSMatthew Dillon.Dq dangerously-dedicated 366ce19f97eSMatthew Dillonslice for compatibility with older PC systems, 367ce19f97eSMatthew Dillonyou generally want to specify the compatibility slice, such as 368ce19f97eSMatthew Dillon.Pa da0s0 . 369ce19f97eSMatthew DillonIf you are creating a label within an existing DOS slice, 370ce19f97eSMatthew Dillonyou should specify 371ce19f97eSMatthew Dillonthe slice name such as 372ce19f97eSMatthew Dillon.Pa da0s1 . 373ce19f97eSMatthew DillonMaking a slice bootable can be tricky. 374ce19f97eSMatthew DillonIf you are using a normal DOS 375ce19f97eSMatthew Dillonslice you typically install (or leave) a standard MBR on the base disk and 376ce19f97eSMatthew Dillonthen install the 377ce19f97eSMatthew Dillon.Dx 378ce19f97eSMatthew Dillonbootblocks in the slice. 379ce19f97eSMatthew Dillon.Pp 380ce19f97eSMatthew Dillon.Nm 381ce19f97eSMatthew Dillon.Fl B 382ce19f97eSMatthew Dillon.Oo 383ce19f97eSMatthew Dillon.Fl b Ar boot1 384ce19f97eSMatthew Dillon.Fl s Ar boot2 385ce19f97eSMatthew Dillon.Oc 386ce19f97eSMatthew Dillon.Ar disk 387ce19f97eSMatthew Dillon.Oo Ar disktype Ns / Ns Cm auto Oc 388ce19f97eSMatthew Dillon.Pp 389ce19f97eSMatthew DillonThis form installs the bootstrap only. 390ce19f97eSMatthew DillonIt does not change the disk label. 391ce19f97eSMatthew DillonYou should never use this command on the compatibility slice unless you 392ce19f97eSMatthew Dillonintend to create a 393ce19f97eSMatthew Dillon.Dq dangerously-dedicated 394ce19f97eSMatthew Dillondisk, such as 395ce19f97eSMatthew Dillon.Ar da0s0 . 396ce19f97eSMatthew DillonThis command is typically run on a 397ce19f97eSMatthew Dillon.Bx 398ce19f97eSMatthew Dillonslice such as 399ce19f97eSMatthew Dillon.Ar da0s1 . 400ce19f97eSMatthew Dillon.Pp 401ce19f97eSMatthew Dillon.Nm 402ce19f97eSMatthew Dillon.Fl w 403ce19f97eSMatthew Dillon.Fl B 404ce19f97eSMatthew Dillon.Op Fl n 405ce19f97eSMatthew Dillon.Oo 406ce19f97eSMatthew Dillon.Fl b Ar boot1 407ce19f97eSMatthew Dillon.Fl s Ar boot2 408ce19f97eSMatthew Dillon.Oc 409ce19f97eSMatthew Dillon.Ar disk Ar disktype Ns / Ns Cm auto 410ce19f97eSMatthew Dillon.Oo Ar packid Oc 411ce19f97eSMatthew Dillon.Pp 412ce19f97eSMatthew DillonThis form corresponds to the 413ce19f97eSMatthew Dillon.Dq write label 414ce19f97eSMatthew Dilloncommand described above. 415ce19f97eSMatthew DillonIn addition to writing a new volume label, it also installs the bootstrap. 416ce19f97eSMatthew DillonIf run on the compatibility slice this command will create a 417ce19f97eSMatthew Dillon.Dq dangerously-dedicated 418ce19f97eSMatthew Dillonlabel. 419ce19f97eSMatthew DillonThis command is normally run on a 420ce19f97eSMatthew Dillon.Bx 421ce19f97eSMatthew Dillonslice rather than the compatibility slice. 422ce19f97eSMatthew DillonIf 423ce19f97eSMatthew Dillon.Fl n 424ce19f97eSMatthew Dillonis used, no data will be written to the device, and instead the 425ce19f97eSMatthew Dillondisklabel that would have been written will be printed to stdout. 426ce19f97eSMatthew Dillon.Pp 427ce19f97eSMatthew Dillon.Nm 428ce19f97eSMatthew Dillon.Fl R 429ce19f97eSMatthew Dillon.Fl B 430ce19f97eSMatthew Dillon.Op Fl n 431ce19f97eSMatthew Dillon.Oo 432ce19f97eSMatthew Dillon.Fl b Ar boot1 433ce19f97eSMatthew Dillon.Fl s Ar boot2 434ce19f97eSMatthew Dillon.Oc 435ce19f97eSMatthew Dillon.Ar disk Ar protofile 436ce19f97eSMatthew Dillon.Oo Ar disktype Ns / Ns Cm auto Oc 437ce19f97eSMatthew Dillon.Pp 438ce19f97eSMatthew DillonThis form corresponds to the 439ce19f97eSMatthew Dillon.Dq restore label 440ce19f97eSMatthew Dilloncommand described above. 441ce19f97eSMatthew DillonIn addition to restoring the volume label, it also installs the bootstrap. 442ce19f97eSMatthew DillonIf run on the compatibility slice this command will create a 443ce19f97eSMatthew Dillon.Dq dangerously-dedicated 444ce19f97eSMatthew Dillonlabel. 445ce19f97eSMatthew DillonThis command is normally run on a 446ce19f97eSMatthew Dillon.Bx 447ce19f97eSMatthew Dillonslice rather than the compatibility 448ce19f97eSMatthew Dillonslice. 449ce19f97eSMatthew Dillon.Pp 450ce19f97eSMatthew DillonThe bootstrap commands always access the disk directly, 451ce19f97eSMatthew Dillonso it is not necessary to specify the 452ce19f97eSMatthew Dillon.Fl r 453ce19f97eSMatthew Dillonflag. 454ce19f97eSMatthew DillonIf 455ce19f97eSMatthew Dillon.Fl n 456ce19f97eSMatthew Dillonis used, no data will be written to the device, and instead the 457ce19f97eSMatthew Dillondisklabel that would have been written will be printed to stdout. 458ce19f97eSMatthew Dillon.Pp 459ce19f97eSMatthew DillonThe bootstrap code is comprised of two boot programs. 460ce19f97eSMatthew DillonSpecify the name of the 461ce19f97eSMatthew Dillonboot programs to be installed in one of these ways: 462ce19f97eSMatthew Dillon.Bl -enum 463ce19f97eSMatthew Dillon.It 464ce19f97eSMatthew DillonSpecify the names explicitly with the 465ce19f97eSMatthew Dillon.Fl b 466ce19f97eSMatthew Dillonand 467ce19f97eSMatthew Dillon.Fl s 468ce19f97eSMatthew Dillonflags. 469ce19f97eSMatthew Dillon.Fl b 470ce19f97eSMatthew Dillonindicates the primary boot program and 471ce19f97eSMatthew Dillon.Fl s 472ce19f97eSMatthew Dillonthe secondary boot program. 473ce19f97eSMatthew DillonThe boot programs are normally located in 474ce19f97eSMatthew Dillon.Pa /boot . 475ce19f97eSMatthew Dillon.It 476ce19f97eSMatthew DillonIf the 477ce19f97eSMatthew Dillon.Fl b 478ce19f97eSMatthew Dillonand 479ce19f97eSMatthew Dillon.Fl s 480ce19f97eSMatthew Dillonflags are not specified, but 481ce19f97eSMatthew Dillon.Ar disktype 482ce19f97eSMatthew Dillonwas specified, the names of the programs are taken from the 483ce19f97eSMatthew Dillon.Dq b0 484ce19f97eSMatthew Dillonand 485ce19f97eSMatthew Dillon.Dq b1 486ce19f97eSMatthew Dillonparameters of the 487ce19f97eSMatthew Dillon.Xr disktab 5 488ce19f97eSMatthew Dillonentry for the disk if the disktab entry exists and includes those parameters. 489ce19f97eSMatthew Dillon.It 490ce19f97eSMatthew DillonOtherwise, the default boot image names are used: 491ce19f97eSMatthew Dillon.Pa /boot/boot1 492ce19f97eSMatthew Dillonand 493ce19f97eSMatthew Dillon.Pa /boot/boot2 494ce19f97eSMatthew Dillonfor the standard stage1 and stage2 boot images. 495ce19f97eSMatthew Dillon.El 496ce19f97eSMatthew Dillon.Ss Initializing/Formatting a bootable disk from scratch 497ce19f97eSMatthew DillonTo initialize a disk from scratch the following sequence is recommended. 498ce19f97eSMatthew DillonPlease note that this will wipe everything that was previously on the disk, 499ce19f97eSMatthew Dillonincluding any 500ce19f97eSMatthew Dillon.No non- Ns Dx 501ce19f97eSMatthew Dillonslices. 502ce19f97eSMatthew Dillon.Bl -enum 503ce19f97eSMatthew Dillon.It 504ce19f97eSMatthew DillonUse 505ce19f97eSMatthew Dillon.Xr gpt 8 506ce19f97eSMatthew Dillonor 507ce19f97eSMatthew Dillon.Xr fdisk 8 508ce19f97eSMatthew Dillonto initialize the hard disk, and create a GPT or MBR slice table, 509ce19f97eSMatthew Dillonreferred to as the 510ce19f97eSMatthew Dillon.Dq "partition table" 511ce19f97eSMatthew Dillonin 512ce19f97eSMatthew Dillon.Tn DOS . 513ce19f97eSMatthew Dillon.It 514ce19f97eSMatthew DillonUse 515ce19f97eSMatthew Dillon.Nm 516ce19f97eSMatthew Dillonor 517ce19f97eSMatthew Dillon.Xr disklabel64 8 518ce19f97eSMatthew Dillonto define partitions on 519ce19f97eSMatthew Dillon.Dx 520ce19f97eSMatthew Dillonslices created in the previous step. 521ce19f97eSMatthew Dillon.It 522ce19f97eSMatthew DillonFinally use 523ce19f97eSMatthew Dillon.Xr newfs_hammer 8 524ce19f97eSMatthew Dillonor 525ce19f97eSMatthew Dillon.Xr newfs 8 526ce19f97eSMatthew Dillonto create file systems on new partitions. 527ce19f97eSMatthew Dillon.El 528ce19f97eSMatthew Dillon.Pp 529ce19f97eSMatthew DillonA typical partitioning scheme would be to have an 530ce19f97eSMatthew Dillon.Ql a 531ce19f97eSMatthew Dillonpartition 532ce19f97eSMatthew Dillonof approximately 512MB to hold the root file system, a 533ce19f97eSMatthew Dillon.Ql b 534ce19f97eSMatthew Dillonpartition for 535ce19f97eSMatthew Dillonswap (usually 4GB), a 536ce19f97eSMatthew Dillon.Ql d 537ce19f97eSMatthew Dillonpartition for 538ce19f97eSMatthew Dillon.Pa /var 539ce19f97eSMatthew Dillon(usually 2GB), an 540ce19f97eSMatthew Dillon.Ql e 541ce19f97eSMatthew Dillonpartition for 542ce19f97eSMatthew Dillon.Pa /var/tmp 543ce19f97eSMatthew Dillon(usually 2GB), an 544ce19f97eSMatthew Dillon.Ql f 545ce19f97eSMatthew Dillonpartition for 546ce19f97eSMatthew Dillon.Pa /usr 547ce19f97eSMatthew Dillon(usually around 4GB), 548ce19f97eSMatthew Dillonand finally a 549ce19f97eSMatthew Dillon.Ql g 550ce19f97eSMatthew Dillonpartition for 551ce19f97eSMatthew Dillon.Pa /home 552ce19f97eSMatthew Dillon(usually all remaining space). 553ce19f97eSMatthew DillonIf you are tight on space all sizes can be halved. 554ce19f97eSMatthew DillonYour mileage may vary. 555ce19f97eSMatthew Dillon.Pp 556ce19f97eSMatthew Dillon.Dl "fdisk -BI da0" 557c61a095dSThomas Nikolajsen.Dl "disklabel32 -w -B da0s1 auto" 558c61a095dSThomas Nikolajsen.Dl "disklabel32 -e da0s1" 559ce19f97eSMatthew Dillon.Ss Manual offset 560ce19f97eSMatthew Dillon.Dx 561ce19f97eSMatthew Dillonno longer snoop-adjusts the on-disk label when reading or writing 562ce19f97eSMatthew Dillonraw labels. 563ce19f97eSMatthew Dillon.Nm 564ce19f97eSMatthew Dillonis now responsible for adjusting the label when operating in raw mode. 565c61a095dSThomas NikolajsenTraditional (32 bit, 566ce19f97eSMatthew Dillon.Bx ) 567ce19f97eSMatthew Dillondisklabels store offsets as absolute block numbers 568ce19f97eSMatthew Dillonrather than slice-relative block numbers. 569ce19f97eSMatthew DillonIf 570ce19f97eSMatthew Dillon.Nm 571ce19f97eSMatthew Dillonis unable to issue the 572ce19f97eSMatthew Dillon.Dv DIOCGPART 573ce19f97eSMatthew Dillonioctl to get slice information it will 574ce19f97eSMatthew Dillonrefuse to read or write the label in raw mode. 575ce19f97eSMatthew DillonThe 576ce19f97eSMatthew Dillon.Fl f 577ce19f97eSMatthew Dillonoption may be used to force the operation by supplying a manual offset. 578ce19f97eSMatthew Dillon.Sh FILES 579ce19f97eSMatthew Dillon.Bl -tag -width ".Pa /etc/disktab" -compact 580ce19f97eSMatthew Dillon.It Pa /boot/boot1 581ce19f97eSMatthew DillonDefault stage1 boot image. 582ce19f97eSMatthew Dillon.It Pa /boot/boot2 583ce19f97eSMatthew DillonDefault stage2 boot image. 584ce19f97eSMatthew Dillon.It Pa /etc/disktab 585ce19f97eSMatthew DillonDisk description file. 586ce19f97eSMatthew Dillon.El 587ce19f97eSMatthew Dillon.Sh SAVED FILE FORMAT 588ce19f97eSMatthew DillonThe 589ce19f97eSMatthew Dillon.Nm 590ce19f97eSMatthew Dillonutility uses an 591ce19f97eSMatthew Dillon.Tn ASCII 592ce19f97eSMatthew Dillonversion of the label when examining, editing, or restoring a disk label. 593ce19f97eSMatthew DillonThe format is: 594ce19f97eSMatthew Dillon.Bd -literal -offset 4n 595ce19f97eSMatthew Dillon# /dev/ad4s4: 596ce19f97eSMatthew Dillontype: unknown 597ce19f97eSMatthew Dillondisk: amnesiac 598ce19f97eSMatthew Dillonlabel: fictitious 599ce19f97eSMatthew Dillonflags: 600ce19f97eSMatthew Dillonbytes/sector: 512 601ce19f97eSMatthew Dillonsectors/track: 63 602ce19f97eSMatthew Dillontracks/cylinder: 24 603ce19f97eSMatthew Dillonsectors/cylinder: 1512 604ce19f97eSMatthew Dilloncylinders: 161098 605ce19f97eSMatthew Dillonsectors/unit: 243581184 606ce19f97eSMatthew Dillonrpm: 3600 607ce19f97eSMatthew Dilloninterleave: 1 608ce19f97eSMatthew Dillontrackskew: 0 609ce19f97eSMatthew Dilloncylinderskew: 0 610ce19f97eSMatthew Dillonheadswitch: 0 # milliseconds 611ce19f97eSMatthew Dillontrack-to-track seek: 0 # milliseconds 612ce19f97eSMatthew Dillondrivedata: 0 613ce19f97eSMatthew Dillon 614ce19f97eSMatthew Dillon16 partitions: 615ce19f97eSMatthew Dillon# size offset fstype 616ce19f97eSMatthew Dillon a: 1048560 16 4.2BSD # 511.992MB 617ce19f97eSMatthew Dillon b: 8388608 1048576 swap # 4096.000MB 618ce19f97eSMatthew Dillon c: 243581184 0 unused # 118936.125MB 619ce19f97eSMatthew Dillon d: 4194304 9437184 4.2BSD # 2048.000MB 620ce19f97eSMatthew Dillon e: 4194304 13631488 4.2BSD # 2048.000MB 621ce19f97eSMatthew Dillon f: 8388608 17825792 4.2BSD # 4096.000MB 622ce19f97eSMatthew Dillon h: 196395264 26214400 HAMMER # 95896.125MB 623ce19f97eSMatthew Dillon i: 10485760 222609664 ccd # 5120.000MB 624ce19f97eSMatthew Dillon j: 10485760 233095424 vinum # 5120.000MB 625ce19f97eSMatthew Dillon.Ed 626ce19f97eSMatthew Dillon.Pp 627ce19f97eSMatthew DillonLines starting with a 628ce19f97eSMatthew Dillon.Ql # 629ce19f97eSMatthew Dillonmark are comments. 630ce19f97eSMatthew DillonMost of the other specifications are no longer used. 631ce19f97eSMatthew DillonThe ones which must still be set correctly are: 632ce19f97eSMatthew Dillon.Bl -inset 633ce19f97eSMatthew Dillon.It Ar label 634ce19f97eSMatthew Dillonis an optional label, set by the 635ce19f97eSMatthew Dillon.Ar packid 636ce19f97eSMatthew Dillonoption when writing a label. 637ce19f97eSMatthew Dillon.It Ar flags 638ce19f97eSMatthew Dillonmay be 639ce19f97eSMatthew Dillon.Cm removable , ecc 640ce19f97eSMatthew Dillonor 641ce19f97eSMatthew Dillon.Cm badsect . 642ce19f97eSMatthew Dillon.Cm removable 643ce19f97eSMatthew Dillonis set for removable media drives, but no current 644ce19f97eSMatthew Dillon.Dx 645ce19f97eSMatthew Dillondriver evaluates this 646ce19f97eSMatthew Dillonflag. 647ce19f97eSMatthew Dillon.Cm ecc 648ce19f97eSMatthew Dillonis no longer supported; 649ce19f97eSMatthew Dillon.Cm badsect 650ce19f97eSMatthew Dillonspecifies that the drive can perform bad sector remapping. 651ce19f97eSMatthew Dillon.It Ar sectors/unit 652ce19f97eSMatthew Dillondescribes the total size of the disk. 653ce19f97eSMatthew DillonThis value must be correct. 654ce19f97eSMatthew Dillon.It Ar "the partition table" 655ce19f97eSMatthew Dillonis the 656ce19f97eSMatthew Dillon.Ux 657ce19f97eSMatthew Dillonpartition table, not the 658ce19f97eSMatthew Dillon.Tn DOS 659ce19f97eSMatthew Dillonpartition table described in 660ce19f97eSMatthew Dillon.Xr fdisk 8 . 661ce19f97eSMatthew Dillon.El 662ce19f97eSMatthew Dillon.Pp 663ce19f97eSMatthew DillonThe partition table can have up to 16 entries. 664ce19f97eSMatthew DillonIt contains the following information: 665ce19f97eSMatthew Dillon.Bl -tag -width indent 666ce19f97eSMatthew Dillon.It Ar # 667ce19f97eSMatthew DillonThe partition identifier is a single letter in the range 668ce19f97eSMatthew Dillon.Ql a 669ce19f97eSMatthew Dillonto 670ce19f97eSMatthew Dillon.Ql p . 671ce19f97eSMatthew DillonBy convention, partition 672ce19f97eSMatthew Dillon.Ql c 673ce19f97eSMatthew Dillonis reserved to describe the entire disk. 674ce19f97eSMatthew Dillon.It Ar size 675ce19f97eSMatthew DillonThe size of the partition in sectors, 676ce19f97eSMatthew Dillon.Cm K 677ce19f97eSMatthew Dillon(kilobytes - 1024), 678ce19f97eSMatthew Dillon.Cm M 679ce19f97eSMatthew Dillon(megabytes - 1024*1024), 680ce19f97eSMatthew Dillon.Cm G 681ce19f97eSMatthew Dillon(gigabytes - 1024*1024*1024), 682f61a91d2SSascha Wildner.Cm T 683f61a91d2SSascha Wildner(gigabytes - 1024*1024*1024*1024), 684ce19f97eSMatthew Dillon.Cm % 685ce19f97eSMatthew Dillon(percentage of free space 686ce19f97eSMatthew Dillon.Em after 687ce19f97eSMatthew Dillonremoving any fixed-size partitions other than partition 688ce19f97eSMatthew Dillon.Ql c ) , 689ce19f97eSMatthew Dillonor 690ce19f97eSMatthew Dillon.Cm * 691ce19f97eSMatthew Dillon(all remaining free space 692ce19f97eSMatthew Dillon.Em after 693ce19f97eSMatthew Dillonfixed-size and percentage partitions). 694ce19f97eSMatthew DillonFor partition 695ce19f97eSMatthew Dillon.Ql c , 696ce19f97eSMatthew Dillona size of 697ce19f97eSMatthew Dillon.Cm * 698ce19f97eSMatthew Dillonindicates the entire disk. 699ce19f97eSMatthew DillonLowercase versions of 700f61a91d2SSascha Wildner.Cm K , M , G , 701ce19f97eSMatthew Dillonand 702f61a91d2SSascha Wildner.Cm T 703ce19f97eSMatthew Dillonare allowed. 704ce19f97eSMatthew DillonSize and type should be specified without any spaces between them. 705ce19f97eSMatthew Dillon.Pp 706ce19f97eSMatthew DillonExample: 2097152, 1G, 1024M and 1048576K are all the same size 707ce19f97eSMatthew Dillon(assuming 512-byte sectors). 708ce19f97eSMatthew Dillon.It Ar offset 709ce19f97eSMatthew DillonThe offset of the start of the partition from the beginning of the 710ce19f97eSMatthew Dillondrive in sectors, or 711ce19f97eSMatthew Dillon.Cm * 712ce19f97eSMatthew Dillonto have 713ce19f97eSMatthew Dillon.Nm 714ce19f97eSMatthew Dilloncalculate the correct offset to use (the end of the previous partition plus 715ce19f97eSMatthew Dillonone, ignoring partition 716ce19f97eSMatthew Dillon.Ql c . 717ce19f97eSMatthew DillonFor partition 718ce19f97eSMatthew Dillon.Ql c , 719ce19f97eSMatthew Dillon.Cm * 720ce19f97eSMatthew Dillonwill be interpreted as an offset of 0. 721ce19f97eSMatthew Dillon.It Ar fstype 722ce19f97eSMatthew DillonDescribes the purpose of the partition. 723ce19f97eSMatthew DillonThe example shows all currently used partition types. 724ce19f97eSMatthew DillonFor 725ce19f97eSMatthew Dillon.Xr UFS 5 726ce19f97eSMatthew Dillonfile systems, use type 727ce19f97eSMatthew Dillon.Cm 4.2BSD . 728ce19f97eSMatthew DillonFor 729ce19f97eSMatthew Dillon.Xr HAMMER 5 730ce19f97eSMatthew Dillonfile systems, use type 731ce19f97eSMatthew Dillon.Cm HAMMER . 732ce19f97eSMatthew DillonFor 733ce19f97eSMatthew Dillon.Xr ccd 4 734ce19f97eSMatthew Dillonpartitions, use type 735ce19f97eSMatthew Dillon.Cm ccd . 736ce19f97eSMatthew DillonFor Vinum drives, use type 737ce19f97eSMatthew Dillon.Cm vinum . 738ce19f97eSMatthew DillonOther common types are 739ce19f97eSMatthew Dillon.Cm swap 740ce19f97eSMatthew Dillonand 741ce19f97eSMatthew Dillon.Cm unused . 742ce19f97eSMatthew DillonBy convention, partition 743ce19f97eSMatthew Dillon.Ql c 744ce19f97eSMatthew Dillonrepresents the entire slice and should be of type 745ce19f97eSMatthew Dillon.Cm unused , 746ce19f97eSMatthew Dillonthough 747ce19f97eSMatthew Dillon.Nm 748ce19f97eSMatthew Dillondoes not enforce this convention. 749ce19f97eSMatthew DillonThe 750ce19f97eSMatthew Dillon.Nm 751ce19f97eSMatthew Dillonutility 752ce19f97eSMatthew Dillonalso knows about a number of other partition types, 753ce19f97eSMatthew Dillonnone of which are in current use. 754ce19f97eSMatthew Dillon(See 755ce19f97eSMatthew Dillon.Dv fstypenames 756ce19f97eSMatthew Dillonin 757ce19f97eSMatthew Dillon.In sys/dtype.h 758ce19f97eSMatthew Dillonfor more details). 759ce19f97eSMatthew Dillon.El 760ce19f97eSMatthew Dillon.Pp 761ce19f97eSMatthew DillonThe remainder of the line is a comment and shows the size of 762ce19f97eSMatthew Dillonthe partition in MB. 763ce19f97eSMatthew Dillon.Sh EXAMPLES 764c61a095dSThomas Nikolajsen.Dl "disklabel32 da0s1" 765ce19f97eSMatthew Dillon.Pp 766ce19f97eSMatthew DillonDisplay the in-core label for the first slice of the 767ce19f97eSMatthew Dillon.Pa da0 768ce19f97eSMatthew Dillondisk, as obtained via 769ce19f97eSMatthew Dillon.Pa /dev/da0s1 . 770ce19f97eSMatthew Dillon(If the disk is 771ce19f97eSMatthew Dillon.Dq dangerously-dedicated , 772ce19f97eSMatthew Dillonthe compatibility slice name should be specified, such as 773ce19f97eSMatthew Dillon.Pa da0s0 . ) 774ce19f97eSMatthew Dillon.Pp 775c61a095dSThomas Nikolajsen.Dl "disklabel32 da0s1 > savedlabel" 776ce19f97eSMatthew Dillon.Pp 777ce19f97eSMatthew DillonSave the in-core label for 778ce19f97eSMatthew Dillon.Pa da0s1 779ce19f97eSMatthew Dilloninto the file 780ce19f97eSMatthew Dillon.Pa savedlabel . 781ce19f97eSMatthew DillonThis file can be used with the 782ce19f97eSMatthew Dillon.Fl R 783ce19f97eSMatthew Dillonoption to restore the label at a later date. 784ce19f97eSMatthew Dillon.Pp 785c61a095dSThomas Nikolajsen.Dl "disklabel32 -w -r /dev/da0s1 da2212 foo" 786ce19f97eSMatthew Dillon.Pp 787ce19f97eSMatthew DillonCreate a label for 788ce19f97eSMatthew Dillon.Pa da0s1 789ce19f97eSMatthew Dillonbased on information for 790ce19f97eSMatthew Dillon.Dq da2212 791ce19f97eSMatthew Dillonfound in 792ce19f97eSMatthew Dillon.Pa /etc/disktab . 793ce19f97eSMatthew DillonAny existing bootstrap code will be clobbered 794ce19f97eSMatthew Dillonand the disk rendered unbootable. 795ce19f97eSMatthew Dillon.Pp 796c61a095dSThomas Nikolajsen.Dl "disklabel32 -e -r da0s1" 797ce19f97eSMatthew Dillon.Pp 798ce19f97eSMatthew DillonRead the on-disk label for 799ce19f97eSMatthew Dillon.Pa da0s1 , 800ce19f97eSMatthew Dillonedit it, and reinstall in-core as well as on-disk. 801ce19f97eSMatthew DillonExisting bootstrap code is unaffected. 802ce19f97eSMatthew Dillon.Pp 803c61a095dSThomas Nikolajsen.Dl "disklabel32 -e -r -n da0s1" 804ce19f97eSMatthew Dillon.Pp 805ce19f97eSMatthew DillonRead the on-disk label for 806ce19f97eSMatthew Dillon.Pa da0s1 , 807ce19f97eSMatthew Dillonedit it, and display what the new label would be (in sectors). 808ce19f97eSMatthew DillonIt does 809ce19f97eSMatthew Dillon.Em not 810ce19f97eSMatthew Dilloninstall the new label either in-core or on-disk. 811ce19f97eSMatthew Dillon.Pp 812c61a095dSThomas Nikolajsen.Dl "disklabel32 -r -w da0s1 auto" 813ce19f97eSMatthew Dillon.Pp 814ce19f97eSMatthew DillonTry to auto-detect the required information from 815ce19f97eSMatthew Dillon.Pa da0s1 , 816ce19f97eSMatthew Dillonand write a new label to the disk. 817ce19f97eSMatthew DillonUse another 818ce19f97eSMatthew Dillon.Nm Fl e 819ce19f97eSMatthew Dilloncommand to edit the 820ce19f97eSMatthew Dillonpartitioning and file system information. 821ce19f97eSMatthew Dillon.Pp 822c61a095dSThomas Nikolajsen.Dl "disklabel32 -R da0s1 savedlabel" 823ce19f97eSMatthew Dillon.Pp 824ce19f97eSMatthew DillonRestore the on-disk and in-core label for 825ce19f97eSMatthew Dillon.Pa da0s1 826ce19f97eSMatthew Dillonfrom information in 827ce19f97eSMatthew Dillon.Pa savedlabel . 828ce19f97eSMatthew DillonExisting bootstrap code is unaffected. 829ce19f97eSMatthew Dillon.Pp 830c61a095dSThomas Nikolajsen.Dl "disklabel32 -R -n da0s1 label_layout" 831ce19f97eSMatthew Dillon.Pp 832ce19f97eSMatthew DillonDisplay what the label would be for 833ce19f97eSMatthew Dillon.Pa da0s1 834ce19f97eSMatthew Dillonusing the partition layout in 835ce19f97eSMatthew Dillon.Pa label_layout . 836ce19f97eSMatthew DillonThis is useful for determining how much space would be allotted for various 837ce19f97eSMatthew Dillonpartitions with a labelling scheme using 838ce19f97eSMatthew Dillon.Cm % Ns -based 839ce19f97eSMatthew Dillonor 840ce19f97eSMatthew Dillon.Cm * 841ce19f97eSMatthew Dillonpartition sizes. 842ce19f97eSMatthew Dillon.Pp 843c61a095dSThomas Nikolajsen.Dl "disklabel32 -B da0s1" 844ce19f97eSMatthew Dillon.Pp 845ce19f97eSMatthew DillonInstall a new bootstrap on 846ce19f97eSMatthew Dillon.Pa da0s1 . 847ce19f97eSMatthew DillonThe boot code comes from 848ce19f97eSMatthew Dillon.Pa /boot/boot1 849ce19f97eSMatthew Dillonand possibly 850ce19f97eSMatthew Dillon.Pa /boot/boot2 . 851ce19f97eSMatthew DillonOn-disk and in-core labels are unchanged. 852ce19f97eSMatthew Dillon.Pp 853c61a095dSThomas Nikolajsen.Dl "disklabel32 -w -B /dev/da0s1 -b newboot1 -s newboot2 da2212" 854ce19f97eSMatthew Dillon.Pp 855ce19f97eSMatthew DillonInstall a new label and bootstrap. 856ce19f97eSMatthew DillonThe label is derived from disktab information for 857ce19f97eSMatthew Dillon.Dq da2212 858ce19f97eSMatthew Dillonand installed both in-core and on-disk. 859ce19f97eSMatthew DillonThe bootstrap code comes from the files 860ce19f97eSMatthew Dillon.Pa newboot1 861ce19f97eSMatthew Dillonand 862ce19f97eSMatthew Dillon.Pa newboot2 . 863ce19f97eSMatthew Dillon.Pp 864ce19f97eSMatthew Dillon.Dl "dd if=/dev/zero of=/dev/da0 bs=512 count=32" 865ce19f97eSMatthew Dillon.Dl "fdisk -BI da0" 866ce19f97eSMatthew Dillon.Dl "dd if=/dev/zero of=/dev/da0s1 bs=512 count=32" 867c61a095dSThomas Nikolajsen.Dl "disklabel32 -w -B da0s1 auto" 868c61a095dSThomas Nikolajsen.Dl "disklabel32 -e da0s1" 869ce19f97eSMatthew Dillon.Pp 870ce19f97eSMatthew DillonCompletely wipe any prior information on the disk, creating a new bootable 871ce19f97eSMatthew Dillondisk with a DOS partition table containing one 872ce19f97eSMatthew Dillon.Dq whole-disk 873ce19f97eSMatthew Dillonslice. 874ce19f97eSMatthew DillonThen 875ce19f97eSMatthew Dilloninitialize the slice, then edit it to your needs. 876ce19f97eSMatthew DillonThe 877ce19f97eSMatthew Dillon.Pa dd 878ce19f97eSMatthew Dilloncommands are optional, but may be necessary for some BIOSes to properly 879ce19f97eSMatthew Dillonrecognize the disk. 880ce19f97eSMatthew Dillon.Pp 881c61a095dSThomas Nikolajsen.Dl "disklabel32 -W da0s1" 882ce19f97eSMatthew Dillon.Dl "dd if=/dev/zero of=/dev/da0s1 bs=512 count=32" 883ce19f97eSMatthew Dillon.Dl "disklabel64 -r -w da0s1 auto" 884ce19f97eSMatthew Dillon.Dl "disklabel64 -N da0s1" 885ce19f97eSMatthew Dillon.Pp 886ce19f97eSMatthew DillonCompletely wipe any prior information on the slice, 887ce19f97eSMatthew Dillonchanging label format to 64 bit. 888ce19f97eSMatthew DillonThe wiping is needed as 889ce19f97eSMatthew Dillon.Nm disklabel64 890ce19f97eSMatthew Dillonand 891ce19f97eSMatthew Dillon.Nm , 892ce19f97eSMatthew Dillonas a safety measure, 893ce19f97eSMatthew Dillonwon't do any operations if label with other format is already installed. 894ce19f97eSMatthew Dillon.Pp 895ce19f97eSMatthew DillonThis is an example disklabel that uses some of the new partition size types 896ce19f97eSMatthew Dillonsuch as 897ce19f97eSMatthew Dillon.Cm % , M , G , 898ce19f97eSMatthew Dillonand 899ce19f97eSMatthew Dillon.Cm * , 900ce19f97eSMatthew Dillonwhich could be used as a source file for 901ce19f97eSMatthew Dillon.Pp 902c61a095dSThomas Nikolajsen.Dl "disklabel32 -R ad0s1 new_label_file" 903ce19f97eSMatthew Dillon.Bd -literal -offset 4n 904ce19f97eSMatthew Dillon# /dev/ad0s1: 905ce19f97eSMatthew Dillontype: ESDI 906ce19f97eSMatthew Dillondisk: ad0s1 907ce19f97eSMatthew Dillonlabel: 908ce19f97eSMatthew Dillonflags: 909ce19f97eSMatthew Dillonbytes/sector: 512 910ce19f97eSMatthew Dillonsectors/track: 63 911ce19f97eSMatthew Dillontracks/cylinder: 16 912ce19f97eSMatthew Dillonsectors/cylinder: 1008 913ce19f97eSMatthew Dilloncylinders: 40633 914ce19f97eSMatthew Dillonsectors/unit: 40959009 915ce19f97eSMatthew Dillonrpm: 3600 916ce19f97eSMatthew Dilloninterleave: 1 917ce19f97eSMatthew Dillontrackskew: 0 918ce19f97eSMatthew Dilloncylinderskew: 0 919ce19f97eSMatthew Dillonheadswitch: 0 # milliseconds 920ce19f97eSMatthew Dillontrack-to-track seek: 0 # milliseconds 921ce19f97eSMatthew Dillondrivedata: 0 922ce19f97eSMatthew Dillon 923ce19f97eSMatthew Dillon16 partitions: 924ce19f97eSMatthew Dillon# size offset fstype 925ce19f97eSMatthew Dillon a: 400M 0 4.2BSD 926ce19f97eSMatthew Dillon b: 1G * swap 927ce19f97eSMatthew Dillon c: * * unused 928ce19f97eSMatthew Dillon e: 204800 * 4.2BSD 929ce19f97eSMatthew Dillon f: 5g * 4.2BSD 930ce19f97eSMatthew Dillon g: * * 4.2BSD 931ce19f97eSMatthew Dillon.Ed 932ce19f97eSMatthew Dillon.Sh DIAGNOSTICS 933ce19f97eSMatthew DillonThe kernel device drivers will not allow the size of a disk partition 934ce19f97eSMatthew Dillonto be decreased or the offset of a partition to be changed while it is open. 935ce19f97eSMatthew DillonSome device drivers create a label containing only a single large partition 936ce19f97eSMatthew Dillonif a disk is unlabeled; thus, the label must be written to the 937ce19f97eSMatthew Dillon.Ql a 938ce19f97eSMatthew Dillonpartition of the disk while it is open. 939ce19f97eSMatthew DillonThis sometimes requires the desired 940ce19f97eSMatthew Dillonlabel to be set in two steps, the first one creating at least one other 941ce19f97eSMatthew Dillonpartition, and the second setting the label on the new partition while 942ce19f97eSMatthew Dillonshrinking the 943ce19f97eSMatthew Dillon.Ql a 944ce19f97eSMatthew Dillonpartition. 945ce19f97eSMatthew Dillon.Pp 946ce19f97eSMatthew DillonOn some machines the bootstrap code may not fit entirely in the area 947ce19f97eSMatthew Dillonallocated for it by some file systems. 948ce19f97eSMatthew DillonAs a result, it may not be possible to have file systems on some partitions 949ce19f97eSMatthew Dillonof a 950ce19f97eSMatthew Dillon.Dq bootable 951ce19f97eSMatthew Dillondisk. 952ce19f97eSMatthew DillonWhen installing bootstrap code, 953ce19f97eSMatthew Dillon.Nm 954ce19f97eSMatthew Dillonchecks for these cases. 955ce19f97eSMatthew DillonIf the installed boot code would overlap a partition of type 956ce19f97eSMatthew Dillon.Dv FS_UNUSED 957ce19f97eSMatthew Dillonit is marked as type 958ce19f97eSMatthew Dillon.Dv FS_BOOT . 959ce19f97eSMatthew DillonThe 960ce19f97eSMatthew Dillon.Xr newfs 8 961ce19f97eSMatthew Dillonutility will disallow creation of file systems on 962ce19f97eSMatthew Dillon.Dv FS_BOOT 963ce19f97eSMatthew Dillonpartitions. 964ce19f97eSMatthew DillonConversely, if a partition has a type other than 965ce19f97eSMatthew Dillon.Dv FS_UNUSED 966ce19f97eSMatthew Dillonor 967ce19f97eSMatthew Dillon.Dv FS_BOOT , 968ce19f97eSMatthew Dillon.Nm 969ce19f97eSMatthew Dillonwill not install bootstrap code that overlaps it. 970ce19f97eSMatthew Dillon.Sh COMPATIBILITY 971ce19f97eSMatthew DillonDue to 972c61a095dSThomas Nikolajsen.Xr disklabel32 5 973ce19f97eSMatthew Dillonstoring sector numbers in 32 bit format 974ce19f97eSMatthew Dillon.Nm 975ce19f97eSMatthew Dillonis restricted to 2TB, using the prevalent sector size of 512B. 976ce19f97eSMatthew Dillon.Xr disklabel64 5 977ce19f97eSMatthew Dillonlabels should be used to partition larger disks. 978ce19f97eSMatthew Dillon.Pp 979ce19f97eSMatthew DillonThe various 980ce19f97eSMatthew Dillon.Bx Ns s 981ce19f97eSMatthew Dillonuse slightly different versions of 982ce19f97eSMatthew Dillon.Bx 983ce19f97eSMatthew Dillondisklabels 984ce19f97eSMatthew Dillonand are not generally compatible. 985ce19f97eSMatthew DillonThe 986ce19f97eSMatthew Dillon.Dx 987ce19f97eSMatthew Dillonkernel can often use labels from other 988ce19f97eSMatthew Dillon.Bx Ns s 989ce19f97eSMatthew Dillonfor read-only operation. 990ce19f97eSMatthew Dillon.Sh SEE ALSO 991ce19f97eSMatthew Dillon.Xr dd 1 , 992ce19f97eSMatthew Dillon.Xr ccd 4 , 993c61a095dSThomas Nikolajsen.Xr disklabel32 5 , 994ce19f97eSMatthew Dillon.Xr disktab 5 , 995ce19f97eSMatthew Dillon.Xr boot0cfg 8 , 996ce19f97eSMatthew Dillon.Xr diskinfo 8 , 997ce19f97eSMatthew Dillon.Xr disklabel64 8 , 998ce19f97eSMatthew Dillon.Xr fdisk 8 , 999ce19f97eSMatthew Dillon.Xr gpt 8 , 1000ce19f97eSMatthew Dillon.Xr newfs 8 , 1001ce19f97eSMatthew Dillon.Xr newfs_hammer 8 , 1002ce19f97eSMatthew Dillon.Xr vinum 8 1003ce19f97eSMatthew Dillon.Sh BUGS 1004ce19f97eSMatthew DillonThe 1005ce19f97eSMatthew Dillon.Nm 1006ce19f97eSMatthew Dillonutility 1007ce19f97eSMatthew Dillondoes not perform all possible error checking. 1008ce19f97eSMatthew DillonWarning 1009ce19f97eSMatthew Dillon.Em is 1010ce19f97eSMatthew Dillongiven if partitions 1011ce19f97eSMatthew Dillonoverlap; if an absolute offset does not match the expected offset; if the 1012ce19f97eSMatthew Dillon.Ql c 1013ce19f97eSMatthew Dillonpartition does not start at 0 or does not cover the entire slice; if a 1014ce19f97eSMatthew Dillonpartition runs past the end of the device; and a number of other errors; but 1015ce19f97eSMatthew Dillonno warning is given if space remains unused. 1016