18fae3551SRodney W. Grimes.\" Copyright (c) 1987, 1988, 1991, 1993 28fae3551SRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 38fae3551SRodney W. Grimes.\" 48fae3551SRodney W. Grimes.\" This code is derived from software contributed to Berkeley by 58fae3551SRodney W. Grimes.\" Symmetric Computer Systems. 68fae3551SRodney W. Grimes.\" 78fae3551SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 88fae3551SRodney W. Grimes.\" modification, are permitted provided that the following conditions 98fae3551SRodney W. Grimes.\" are met: 108fae3551SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 118fae3551SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 128fae3551SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 138fae3551SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 148fae3551SRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 158fae3551SRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software 166bd343a9SPhilippe Charnier.\" must display the following acknowledgment: 178fae3551SRodney W. Grimes.\" This product includes software developed by the University of 188fae3551SRodney W. Grimes.\" California, Berkeley and its contributors. 198fae3551SRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors 208fae3551SRodney W. Grimes.\" may be used to endorse or promote products derived from this software 218fae3551SRodney W. Grimes.\" without specific prior written permission. 228fae3551SRodney W. Grimes.\" 238fae3551SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 248fae3551SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 258fae3551SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 268fae3551SRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 278fae3551SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 288fae3551SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 298fae3551SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 308fae3551SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 318fae3551SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 328fae3551SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 338fae3551SRodney W. Grimes.\" SUCH DAMAGE. 348fae3551SRodney W. Grimes.\" 358fae3551SRodney W. Grimes.\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94 367f3dea24SPeter Wemm.\" $FreeBSD$ 378fae3551SRodney W. Grimes.\" 384cbdc634SGreg Lehey.Dd July 30, 1999 398fae3551SRodney W. Grimes.Dt DISKLABEL 8 409fe48c6eSRuslan Ermilov.Os 418fae3551SRodney W. Grimes.Sh NAME 428fae3551SRodney W. Grimes.Nm disklabel 438fae3551SRodney W. Grimes.Nd read and write disk pack label 448fae3551SRodney W. Grimes.Sh SYNOPSIS 457c7fb079SRuslan Ermilov.Nm 468fae3551SRodney W. Grimes.Op Fl r 478fae3551SRodney W. Grimes.Ar disk 487c7fb079SRuslan Ermilov.Nm 498fae3551SRodney W. Grimes.Fl w 508fae3551SRodney W. Grimes.Op Fl r 513233afaeSJohn W. De Boskey.Op Fl n 52ff7d5162SJordan K. Hubbard.Ar disk Ar disktype/auto 538fae3551SRodney W. Grimes.Oo Ar packid Oc 547c7fb079SRuslan Ermilov.Nm 558fae3551SRodney W. Grimes.Fl e 568fae3551SRodney W. Grimes.Op Fl r 573233afaeSJohn W. De Boskey.Op Fl n 588fae3551SRodney W. Grimes.Ar disk 597c7fb079SRuslan Ermilov.Nm 608fae3551SRodney W. Grimes.Fl R 618fae3551SRodney W. Grimes.Op Fl r 623233afaeSJohn W. De Boskey.Op Fl n 638fae3551SRodney W. Grimes.Ar disk Ar protofile 647c7fb079SRuslan Ermilov.Nm 658fae3551SRodney W. Grimes.Op Fl NW 668fae3551SRodney W. Grimes.Ar disk 67726b61abSRuslan Ermilov.Pp 687c7fb079SRuslan Ermilov.Nm 698fae3551SRodney W. Grimes.Fl B 708fae3551SRodney W. Grimes.Oo 718fae3551SRodney W. Grimes.Fl b Ar boot1 724cbdc634SGreg Lehey.Fl s Ar boot2 738fae3551SRodney W. Grimes.Oc 748fae3551SRodney W. Grimes.Ar disk 75ff7d5162SJordan K. Hubbard.Oo Ar disktype/auto Oc 767c7fb079SRuslan Ermilov.Nm 778fae3551SRodney W. Grimes.Fl w 788fae3551SRodney W. Grimes.Fl B 793233afaeSJohn W. De Boskey.Op Fl n 808fae3551SRodney W. Grimes.Oo 818fae3551SRodney W. Grimes.Fl b Ar boot1 824cbdc634SGreg Lehey.Fl s Ar boot2 838fae3551SRodney W. Grimes.Oc 84ff7d5162SJordan K. Hubbard.Ar disk Ar disktype/auto 858fae3551SRodney W. Grimes.Oo Ar packid Oc 867c7fb079SRuslan Ermilov.Nm 878fae3551SRodney W. Grimes.Fl R 888fae3551SRodney W. Grimes.Fl B 893233afaeSJohn W. De Boskey.Op Fl n 908fae3551SRodney W. Grimes.Oo 918fae3551SRodney W. Grimes.Fl b Ar boot1 924cbdc634SGreg Lehey.Fl s Ar boot2 938fae3551SRodney W. Grimes.Oc 948fae3551SRodney W. Grimes.Ar disk Ar protofile 95ff7d5162SJordan K. Hubbard.Oo Ar disktype/auto Oc 968fae3551SRodney W. Grimes.Sh DESCRIPTION 978fae3551SRodney W. Grimes.Nm Disklabel 985a6d7397STim Vanderhoekinstalls, examines or modifies the label on a disk drive or pack. When writing 994cbdc634SGreg Leheythe label, it can be used to change the drive identification, the disk 1004cbdc634SGreg Leheypartitions on the drive, or to replace a damaged label. There are several forms 1014cbdc634SGreg Leheyof the command that read (display), install or edit the label on a disk. In 1024cbdc634SGreg Leheyaddition, 1036bd343a9SPhilippe Charnier.Nm 1044cbdc634SGreg Leheycan install bootstrap code. 1054cbdc634SGreg Lehey.Ss Raw or in-core label 1064cbdc634SGreg Lehey.Pp 1074cbdc634SGreg LeheyThe disk label is resident close to or at the beginning of each disk partition. 1084cbdc634SGreg LeheyFor faster access, the kernel maintains a copy in core at all times. By 1094cbdc634SGreg Leheydefault, most 1104cbdc634SGreg Lehey.Nm 1114cbdc634SGreg Leheyaccess the in-core copy of the label. To access the raw (on-disk) copy, use the 1124cbdc634SGreg Lehey.Fl r 1134cbdc634SGreg Leheyoption. This option allows a label to be installed on a disk without kernel 1144cbdc634SGreg Leheysupport for a label, such as when labels are first installed on a system; it 1154cbdc634SGreg Leheymust be used when first installing a label on a disk. The specific effect of 1168fae3551SRodney W. Grimes.Fl r 1178fae3551SRodney W. Grimesis described under each command. 1188fae3551SRodney W. Grimes.Pp 1194cbdc634SGreg Lehey.Ss Disk device name 1204cbdc634SGreg Lehey.Pp 1214cbdc634SGreg LeheyAll 1227c7fb079SRuslan Ermilov.Nm 1234cbdc634SGreg Leheyforms require a disk device name, which should always be the raw 124ff7d5162SJordan K. Hubbarddevice name representing the disk or slice. For example 125ff7d5162SJordan K. Hubbard.Pa da0 126ff7d5162SJordan K. Hubbardrepresents the entire disk irregardless of any DOS partitioning, 127ff7d5162SJordan K. Hubbardand 128ff7d5162SJordan K. Hubbard.Pa da0s1 129ff7d5162SJordan K. Hubbardrepresents a slice. Some devices, most notably 130ff7d5162SJordan K. Hubbard.Ar ccd , 131ff7d5162SJordan K. Hubbardrequire that the 132726b61abSRuslan Ermilov.Dq whole-disk 133726b61abSRuslan Ermilov(or 134726b61abSRuslan Ermilov.Dq c ) 135ff7d5162SJordan K. Hubbardpartition be specified. For example 136ff7d5162SJordan K. Hubbard.Pa ccd0c . 137ff7d5162SJordan K. HubbardYou do not have to include the 138ff7d5162SJordan K. Hubbard.Pa /dev/ 139ff7d5162SJordan K. Hubbardpath prefix when specifying the device. 1404cbdc634SGreg Lehey.Nm 141ff7d5162SJordan K. Hubbardwill automatically prepend it. 1424cbdc634SGreg Lehey.Ss Reading the disk label 1434cbdc634SGreg Lehey.Pp 1444cbdc634SGreg LeheyTo examine or save the label on a disk drive, use 1454cbdc634SGreg Lehey.Nm 1464cbdc634SGreg Leheywithout options: 1474cbdc634SGreg Lehey.Pp 1487c7fb079SRuslan Ermilov.Nm 1494cbdc634SGreg Lehey.Op Fl r 1504cbdc634SGreg Lehey.Ar disk 1514cbdc634SGreg Lehey.Pp 1524cbdc634SGreg Lehey.Ar disk 1534cbdc634SGreg Leheyrepresents the raw disk in question, and may be in the form 1544cbdc634SGreg Lehey.Pa da0 1554cbdc634SGreg Leheyor 15607b0cf9aSDavid E. O'Brien.Pa /dev/da0c . 1574cbdc634SGreg LeheyIt will display all of the parameters associated with the drive and its 1584cbdc634SGreg Leheypartition layout. Unless the 1598fae3551SRodney W. Grimes.Fl r 1608fae3551SRodney W. Grimesflag is given, 1618fae3551SRodney W. Grimesthe kernel's in-core copy of the label is displayed; 1628fae3551SRodney W. Grimesif the disk has no label, or the partition types on the disk are incorrect, 1638fae3551SRodney W. Grimesthe kernel may have constructed or modified the label. 1648fae3551SRodney W. GrimesIf the 1658fae3551SRodney W. Grimes.Fl r 1664cbdc634SGreg Leheyflag is given, 1674cbdc634SGreg Lehey.Nm 168ff7d5162SJordan K. Hubbardreads the label from the raw disk and displays it. Both versions are usually 169ff7d5162SJordan K. Hubbardidentical except in the case where a label has not yet been initialized or 170ff7d5162SJordan K. Hubbardis corrupt. 1714cbdc634SGreg Lehey.Ss Writing a standard label 1728fae3551SRodney W. Grimes.Pp 1734cbdc634SGreg LeheyTo write a standard label, use the form 1744cbdc634SGreg Lehey.Pp 1757c7fb079SRuslan Ermilov.Nm 1768fae3551SRodney W. Grimes.Fl w 1774cbdc634SGreg Lehey.Op Fl r 1783233afaeSJohn W. De Boskey.Op Fl n 179ff7d5162SJordan K. Hubbard.Ar disk Ar disktype/auto 1804cbdc634SGreg Lehey.Oo Ar packid Oc 1814cbdc634SGreg Lehey.Pp 1827c7fb079SRuslan Ermilov.Nm 183ff7d5162SJordan K. Hubbard.Fl w 184ff7d5162SJordan K. Hubbard.Op Fl r 1853233afaeSJohn W. De Boskey.Op Fl n 186ff7d5162SJordan K. Hubbard.Ar disk 187ff7d5162SJordan K. Hubbardauto 188ff7d5162SJordan K. Hubbard.Pp 1898fae3551SRodney W. GrimesThe required arguments to 1906bd343a9SPhilippe Charnier.Nm 1914cbdc634SGreg Leheyare the drive to be labeled and the drive type as described in the 192d0353b83SRuslan Ermilov.Xr disktab 5 1934cbdc634SGreg Leheyfile. The drive parameters and partitions are taken from that file. If 1944cbdc634SGreg Leheydifferent disks of the same physical type are to have different partitions, it 1954cbdc634SGreg Leheywill be necessary to have separate disktab entries describing each, or to edit 1964cbdc634SGreg Leheythe label after installation as described below. The optional argument is a 1974cbdc634SGreg Leheypack identification string, up to 16 characters long. The pack id must be 1983233afaeSJohn W. De Boskeyquoted if it contains blanks. 1993233afaeSJohn W. De Boskey.Pp 2003233afaeSJohn W. De BoskeyIf the 2013233afaeSJohn W. De Boskey.Fl n 2023233afaeSJohn W. De Boskeyflag is given, no data will be written to the device, and instead the 2033233afaeSJohn W. De Boskeydisklabel that would have been written will be printed to stdout. 2043233afaeSJohn W. De Boskey.Pp 2053233afaeSJohn W. De BoskeyIf the 2068fae3551SRodney W. Grimes.Fl r 2078fae3551SRodney W. Grimesflag is given, the disk sectors containing the label and bootstrap 2088fae3551SRodney W. Grimeswill be written directly. 2098fae3551SRodney W. GrimesA side-effect of this is that any existing bootstrap code will be overwritten 2104cbdc634SGreg Leheyand the disk rendered unbootable. See the boot options below for a method of 2114cbdc634SGreg Leheywriting the label and the bootstrap at the same time. 2128fae3551SRodney W. GrimesIf 2138fae3551SRodney W. Grimes.Fl r 2148fae3551SRodney W. Grimesis not specified, 2158fae3551SRodney W. Grimesthe existing label will be updated via the in-core copy and any bootstrap 2168fae3551SRodney W. Grimescode will be unaffected. 2178fae3551SRodney W. GrimesIf the disk does not already have a label, the 2188fae3551SRodney W. Grimes.Fl r 2198fae3551SRodney W. Grimesflag must be used. 2208fae3551SRodney W. GrimesIn either case, the kernel's in-core label is replaced. 2218fae3551SRodney W. Grimes.Pp 222425bed3aSJoerg WunschFor a virgin disk that is not known to 223425bed3aSJoerg Wunsch.Xr disktab 5 , 224425bed3aSJoerg Wunsch.Ar disktype 225425bed3aSJoerg Wunschcan be specified as 226425bed3aSJoerg Wunsch.Dq auto . 227425bed3aSJoerg WunschIn this case, the driver is requested to produce a virgin label for the 228425bed3aSJoerg Wunschdisk. This might or might not be successful, depending on whether the 229425bed3aSJoerg Wunschdriver for the disk is able to get the required data without reading 230425bed3aSJoerg Wunschanything from the disk at all. It will likely succeed for all SCSI 231425bed3aSJoerg Wunschdisks, most IDE disks, and vnode devices. Writing a label to the 232425bed3aSJoerg Wunschdisk is the only supported operation, and the 233425bed3aSJoerg Wunsch.Ar disk 234425bed3aSJoerg Wunschitself must be provided as the canonical name, i.e. not as a full 235425bed3aSJoerg Wunschpath name. 236ff7d5162SJordan K. Hubbard.Pp 2373233afaeSJohn W. De BoskeyFor most harddisks, a label based on percentages for most partitions (and 2387733674eSRuslan Ermilovone partition with a size of 2397733674eSRuslan Ermilov.Ql * ) 2407733674eSRuslan Ermilovwill produce a reasonable configuration. 2413233afaeSJohn W. De Boskey.Pp 242ff7d5162SJordan K. HubbardPC-based systems have special requirements in order for the BIOS to properly 243b5c508fbSRuslan Ermilovrecognize a 244b5c508fbSRuslan Ermilov.Fx 245b5c508fbSRuslan Ermilovdisklabel. Older systems may require what is known as a 246726b61abSRuslan Ermilov.Dq dangerously dedicated 247ff7d5162SJordan K. Hubbarddisklabel, which creates a fake DOS partition to work around problems older 248ff7d5162SJordan K. HubbardBIOSes have with modern disk geometries. On newer systems you generally want 249ff7d5162SJordan K. Hubbardto create a normal DOS slice using 250ff7d5162SJordan K. Hubbard.Ar fdisk 251b5c508fbSRuslan Ermilovand then create a 252b5c508fbSRuslan Ermilov.Fx 253b5c508fbSRuslan Ermilovdisklabel within that slice. This is described 254ff7d5162SJordan K. Hubbardlater on in this page. 255ff7d5162SJordan K. Hubbard.Pp 256ff7d5162SJordan K. HubbardInstalling a new disklabel does not in of itself allow your system to boot 257ff7d5162SJordan K. Hubbarda kernel using that label. You must also install boot blocks, which is 258ff7d5162SJordan K. Hubbarddescribed later on in this manual page. 2594cbdc634SGreg Lehey.Ss Editing an existing disk label 260425bed3aSJoerg Wunsch.Pp 2614cbdc634SGreg LeheyTo edit an existing disk label, use the form 2624cbdc634SGreg Lehey.Pp 2637c7fb079SRuslan Ermilov.Nm 2648fae3551SRodney W. Grimes.Fl e 2654cbdc634SGreg Lehey.Op Fl r 2663233afaeSJohn W. De Boskey.Op Fl n 2674cbdc634SGreg Lehey.Ar disk 2684cbdc634SGreg Lehey.Pp 2694cbdc634SGreg LeheyThis command reads the label from the in-core kernel copy, or directly from the 2704cbdc634SGreg Leheydisk if the 2718fae3551SRodney W. Grimes.Fl r 2724cbdc634SGreg Leheyflag is also specified. The label is written to a file in ASCII and then 2734cbdc634SGreg Leheysupplied to an editor for changes. If no editor is specified in an 2748fae3551SRodney W. Grimes.Ev EDITOR 2758fae3551SRodney W. Grimesenvironment variable, 2768fae3551SRodney W. Grimes.Xr vi 1 2774cbdc634SGreg Leheyis used. When the editor terminates, the label file is used to rewrite the disk 2784cbdc634SGreg Leheylabel. Existing bootstrap code is unchanged regardless of whether 2798fae3551SRodney W. Grimes.Fl r 2803233afaeSJohn W. De Boskeywas specified. If 2813233afaeSJohn W. De Boskey.Fl n 2823233afaeSJohn W. De Boskeyis specified, no data will be written to the device, and instead the 2833233afaeSJohn W. De Boskeydisklabel that would have been written will be printed to stdout. This is 2843233afaeSJohn W. De Boskeyuseful to see how a partitioning scheme will work out for a specific disk. 2854cbdc634SGreg Lehey.Ss Restoring a disk label from a file 2868fae3551SRodney W. Grimes.Pp 2874cbdc634SGreg LeheyTo restore a disk label from a file, use the form 2884cbdc634SGreg Lehey.Pp 2897c7fb079SRuslan Ermilov.Nm 2908fae3551SRodney W. Grimes.Fl R 2914cbdc634SGreg Lehey.Op Fl r 2923233afaeSJohn W. De Boskey.Op Fl n 2934cbdc634SGreg Lehey.Ar disk Ar protofile 2948fae3551SRodney W. Grimes.Pp 2956bd343a9SPhilippe Charnier.Nm 2965ef18a82SGreg Leheyis capable of restoring a disk label that was previously saved in a file in ASCII format. 2974cbdc634SGreg LeheyThe prototype file used to create the label should be in the same format as that 2984cbdc634SGreg Leheyproduced when reading or editing a label. Comments are delimited by 2994cbdc634SGreg Lehey.Ar \&# 3004cbdc634SGreg Leheyand newline. As when writing a new label, any existing bootstrap code will be 3014cbdc634SGreg Leheyclobbered if 3024cbdc634SGreg Lehey.Fl r 3034cbdc634SGreg Leheyis specified and will be unaffected otherwise. See the boot options below for a 3044cbdc634SGreg Leheymethod of restoring the label and writing the bootstrap at the same time. 3053233afaeSJohn W. De BoskeyIf 3063233afaeSJohn W. De Boskey.Fl n 3073233afaeSJohn W. De Boskeyis used, no data will be written to the device, and instead the 3083233afaeSJohn W. De Boskeydisklabel that would have been written will be printed to stdout. This is 3093233afaeSJohn W. De Boskeyuseful to see how a partitioning scheme will work out for a specific disk. 3104cbdc634SGreg Lehey.Ss Enabling and disabling writing to the disk label area 3114cbdc634SGreg Lehey.Pp 3124cbdc634SGreg LeheyBy default, it is not possible to write to the disk label area at the beginning 3134cbdc634SGreg Leheyof a disk. The disk driver silently ignores any attempt to do so. If you need 3144cbdc634SGreg Leheyto write to this area (for example, to obliterate the label), use the form 3154cbdc634SGreg Lehey.Pp 3167c7fb079SRuslan Ermilov.Nm 3174cbdc634SGreg Lehey.Op Fl W 3184cbdc634SGreg Lehey.Ar disk 3194cbdc634SGreg Lehey.Pp 3204cbdc634SGreg LeheyTo disallow writing to the label area after previously allowing it, use the 3214cbdc634SGreg Leheycommand 3224cbdc634SGreg Lehey.Pp 3237c7fb079SRuslan Ermilov.Nm 3244cbdc634SGreg Lehey.Op Fl N 3254cbdc634SGreg Lehey.Ar disk 3264cbdc634SGreg Lehey.Ss Installing bootstraps 3278fae3551SRodney W. Grimes.Pp 3288fae3551SRodney W. GrimesThe final three forms of 3296bd343a9SPhilippe Charnier.Nm 330ff7d5162SJordan K. Hubbardare used to install bootstrap code. If you are creating a 331726b61abSRuslan Ermilov.Dq dangerously-dedicated 332726b61abSRuslan Ermilovpartition for compatibility with older PC systems, 333ff7d5162SJordan K. Hubbardyou generally want to specify the raw disk name such as 334ff7d5162SJordan K. Hubbard.Pa da0 . 335ff7d5162SJordan K. HubbardIf you are creating a label within an existing DOS slice, you should specify 336ff7d5162SJordan K. Hubbardthe slice name such as 337ff7d5162SJordan K. Hubbard.Pa da0s1 . 338ff7d5162SJordan K. HubbardMaking a partition bootable can be tricky. If you are using a normal DOS 339ff7d5162SJordan K. Hubbardslice you typically install (or leave) a standard MBR on the base disk and 340b5c508fbSRuslan Ermilovthen install the 341b5c508fbSRuslan Ermilov.Fx 342b5c508fbSRuslan Ermilovbootblocks in the slice. 3434cbdc634SGreg Lehey.Pp 3447c7fb079SRuslan Ermilov.Nm 3458fae3551SRodney W. Grimes.Fl B 3464cbdc634SGreg Lehey.Oo 3474cbdc634SGreg Lehey.Fl b Ar boot1 3484cbdc634SGreg Lehey.Fl s Ar boot2 3494cbdc634SGreg Lehey.Oc 3504cbdc634SGreg Lehey.Ar disk 3514cbdc634SGreg Lehey.Oo Ar disktype Oc 3524cbdc634SGreg Lehey.Pp 3534cbdc634SGreg LeheyThis form installs the bootstrap only. It does not change the disk label. 354726b61abSRuslan ErmilovYou should never use this command on a base disk unless you intend to create a 355726b61abSRuslan Ermilov.Dq dangerously-dedicated 356726b61abSRuslan Ermilovdisk, such as 357ff7d5162SJordan K. Hubbard.Ar da0 . 358ff7d5162SJordan K. HubbardThis command is typically run on a slice such as 359ff7d5162SJordan K. Hubbard.Ar da0s1 . 3604cbdc634SGreg Lehey.Pp 3617c7fb079SRuslan Ermilov.Nm 3624cbdc634SGreg Lehey.Fl w 3634cbdc634SGreg Lehey.Fl B 3643233afaeSJohn W. De Boskey.Op Fl n 3654cbdc634SGreg Lehey.Oo 3664cbdc634SGreg Lehey.Fl b Ar boot1 3674cbdc634SGreg Lehey.Fl s Ar boot2 3684cbdc634SGreg Lehey.Oc 3694cbdc634SGreg Lehey.Ar disk Ar disktype 3704cbdc634SGreg Lehey.Oo Ar packid Oc 3714cbdc634SGreg Lehey.Pp 372726b61abSRuslan ErmilovThis form corresponds to the 373726b61abSRuslan Ermilov.Dq write label 374726b61abSRuslan Ermilovcommand described above. 3754cbdc634SGreg LeheyIn addition to writing a new volume label, it also installs the bootstrap. 376726b61abSRuslan ErmilovIf run on a base disk this command will create a 377726b61abSRuslan Ermilov.Dq dangerously-dedicated 378b60884cdSBen Smithurstlabel. This command is normally run on a slice rather than a base disk. 3793233afaeSJohn W. De BoskeyIf 3803233afaeSJohn W. De Boskey.Fl n 3813233afaeSJohn W. De Boskeyis used, no data will be written to the device, and instead the 3823233afaeSJohn W. De Boskeydisklabel that would have been written will be printed to stdout. 3834cbdc634SGreg Lehey.Pp 3847c7fb079SRuslan Ermilov.Nm 3854cbdc634SGreg Lehey.Fl R 3864cbdc634SGreg Lehey.Fl B 3873233afaeSJohn W. De Boskey.Op Fl n 3884cbdc634SGreg Lehey.Oo 3894cbdc634SGreg Lehey.Fl b Ar boot1 3904cbdc634SGreg Lehey.Fl s Ar boot2 3914cbdc634SGreg Lehey.Oc 3924cbdc634SGreg Lehey.Ar disk Ar protofile 3934cbdc634SGreg Lehey.Oo Ar disktype Oc 3944cbdc634SGreg Lehey.Pp 395726b61abSRuslan ErmilovThis form corresponds to the 396726b61abSRuslan Ermilov.Dq restore label 397726b61abSRuslan Ermilovcommand described above. 3984cbdc634SGreg LeheyIn addition to restoring the volume label, it also installs the bootstrap. 399726b61abSRuslan ErmilovIf run on a base disk this command will create a 400726b61abSRuslan Ermilov.Dq dangerously-dedicated 401b60884cdSBen Smithurstlabel. This command is normally run on a slice rather than a base disk. 4024cbdc634SGreg Lehey.Pp 4034cbdc634SGreg LeheyThe bootstrap commands always access the disk directly, so it is not necessary 4044cbdc634SGreg Leheyto specify the 4058fae3551SRodney W. Grimes.Fl r 4063233afaeSJohn W. De Boskeyflag. If 4073233afaeSJohn W. De Boskey.Fl n 4083233afaeSJohn W. De Boskeyis used, no data will be written to the device, and instead the 4093233afaeSJohn W. De Boskeydisklabel that would have been written will be printed to stdout. 4104cbdc634SGreg Lehey.Pp 4114cbdc634SGreg LeheyThe bootstrap code is comprised of two boot programs. Specify the name of the 4124cbdc634SGreg Leheyboot programs to be installed in one of these ways: 4134cbdc634SGreg Lehey.Bl -enum 4144cbdc634SGreg Lehey.It 4154cbdc634SGreg LeheySpecify the names explicitly with the 4168fae3551SRodney W. Grimes.Fl b 4178fae3551SRodney W. Grimesand 4188fae3551SRodney W. Grimes.Fl s 4198fae3551SRodney W. Grimesflags. 4208fae3551SRodney W. Grimes.Fl b 4218fae3551SRodney W. Grimesindicates the primary boot program and 4228fae3551SRodney W. Grimes.Fl s 4234cbdc634SGreg Leheythe secondary boot program. The boot programs are located in 424efba76d7SJordan K. Hubbard.Pa /boot . 4254cbdc634SGreg Lehey.It 4264cbdc634SGreg LeheyIf the 4274cbdc634SGreg Lehey.Fl b 4284cbdc634SGreg Leheyand 4294cbdc634SGreg Lehey.Fl s 4304cbdc634SGreg Leheyflags are not specified, but 4318fae3551SRodney W. Grimes.Ar disktype 4324cbdc634SGreg Leheywas specified, the names of the programs are taken from the 433726b61abSRuslan Ermilov.Dq b0 434726b61abSRuslan Ermilovand 435726b61abSRuslan Ermilov.Dq b1 4364cbdc634SGreg Leheyparameters of the 4374cbdc634SGreg Lehey.Xr disktab 5 4384cbdc634SGreg Leheyentry for the disk if the disktab entry exists and includes those parameters. 4394cbdc634SGreg Lehey.It 4404cbdc634SGreg LeheyOtherwise, the default boot image names are used: 441efba76d7SJordan K. Hubbard.Pa /boot/boot1 4428fae3551SRodney W. Grimesand 443efba76d7SJordan K. Hubbard.Pa /boot/boot2 444efba76d7SJordan K. Hubbardfor the standard stage1 and stage2 boot images (details may vary 445efba76d7SJordan K. Hubbardon architectures like the Alpha, where only a single-stage boot is used). 4464cbdc634SGreg Lehey.El 447ff7d5162SJordan K. Hubbard.Ss Initializing/Formatting a bootable disk from scratch 448ff7d5162SJordan K. Hubbard.Pp 449ff7d5162SJordan K. HubbardTo initialize a disk from scratch the following sequence is recommended. 450ff7d5162SJordan K. HubbardPlease note that this will wipe everything that was previously on the disk, 451b5c508fbSRuslan Ermilovincluding any 452b5c508fbSRuslan Ermilov.No non- Ns Fx 453b5c508fbSRuslan Ermilovslices. 454ff7d5162SJordan K. Hubbard.Bl -enum 455ff7d5162SJordan K. Hubbard.It 456ff7d5162SJordan K. HubbardUse 457ff7d5162SJordan K. Hubbard.Ar fdisk 458ff7d5162SJordan K. Hubbardto initialize the DOS partition table, creating a real whole-disk slice to 459b5c508fbSRuslan Ermilovhold the 460b5c508fbSRuslan Ermilov.Fx 461b5c508fbSRuslan Ermilovdisklabel, and installing a master boot record. 462ff7d5162SJordan K. Hubbard.It 463ff7d5162SJordan K. HubbardUse 464ff7d5162SJordan K. Hubbard.Ar disklabel 465b5c508fbSRuslan Ermilovto initialize a virgin 466b5c508fbSRuslan Ermilov.Fx 467b5c508fbSRuslan Ermilovdisklabel and install 468b5c508fbSRuslan Ermilov.Fx 469b5c508fbSRuslan Ermilovboot blocks. 470ff7d5162SJordan K. Hubbard.It 471ff7d5162SJordan K. HubbardUse 472ff7d5162SJordan K. Hubbard.Ar disklabel 473b60884cdSBen Smithurstto edit your newly created label, adding appropriate partitions. 474ff7d5162SJordan K. Hubbard.It 475ff7d5162SJordan K. HubbardFinally newfs the filesystem partitions you created in the label. A typical 476b60884cdSBen Smithurstdisklabel partitioning scheme would be to have an 477726b61abSRuslan Ermilov.Dq a 478726b61abSRuslan Ermilovpartition 479726b61abSRuslan Ermilovof approximately 128MB to hold the root filesystem, a 480726b61abSRuslan Ermilov.Dq b 481726b61abSRuslan Ermilovpartition for 482726b61abSRuslan Ermilovswap, a 483726b61abSRuslan Ermilov.Dq d 484726b61abSRuslan Ermilovpartition for /var (usually 128MB), an 485726b61abSRuslan Ermilov.Dq e 486726b61abSRuslan Ermilovpartition 487726b61abSRuslan Ermilovfor /var/tmp (usually 128MB), an 488726b61abSRuslan Ermilov.Dq f 489726b61abSRuslan Ermilovpartition for /usr (usually around 2G), 490726b61abSRuslan Ermilovand finally a 491726b61abSRuslan Ermilov.Dq g 492b60884cdSBen Smithurstpartition for /home (usually all remaining space). 493ff7d5162SJordan K. HubbardYour mileage may vary. 494ff7d5162SJordan K. Hubbard.El 495ff7d5162SJordan K. Hubbard.Pp 4967c7fb079SRuslan Ermilov.Nm fdisk Fl BI Ar da0 497ff7d5162SJordan K. Hubbard.Pp 4987c7fb079SRuslan Ermilov.Nm 499ff7d5162SJordan K. Hubbard.Fl w 500ff7d5162SJordan K. Hubbard.Fl r 501ff7d5162SJordan K. Hubbard.Fl B 502ff7d5162SJordan K. Hubbard.Ar da0s1 503ff7d5162SJordan K. Hubbardauto 504ff7d5162SJordan K. Hubbard.Pp 505ff7d5162SJordan K. Hubbard.Pp 5067c7fb079SRuslan Ermilov.Nm 507ff7d5162SJordan K. Hubbard.Fl e 508ff7d5162SJordan K. Hubbard.Ar da0s1 5098fae3551SRodney W. Grimes.Sh FILES 5108fae3551SRodney W. Grimes.Bl -tag -width Pa -compact 5118fae3551SRodney W. Grimes.It Pa /etc/disktab 512efba76d7SJordan K. Hubbard.It Pa /boot/ 513efba76d7SJordan K. Hubbard.It Pa /boot/boot<n> 5148fae3551SRodney W. Grimes.El 5154cbdc634SGreg Lehey.Sh SAVED FILE FORMAT 5164cbdc634SGreg Lehey.Nm 5174cbdc634SGreg Leheyuses an ASCII version of the label when examining, editing or restoring a disk 5184cbdc634SGreg Leheylabel. The format is: 5194cbdc634SGreg Lehey.Bd -literal -offset 4n 52007b0cf9aSDavid E. O'Brien# /dev/da1c: 5214cbdc634SGreg Leheytype: SCSI 52207b0cf9aSDavid E. O'Briendisk: da0s1 5234cbdc634SGreg Leheylabel: 5244cbdc634SGreg Leheyflags: 5254cbdc634SGreg Leheybytes/sector: 512 5264cbdc634SGreg Leheysectors/track: 51 5274cbdc634SGreg Leheytracks/cylinder: 19 5284cbdc634SGreg Leheysectors/cylinder: 969 5294cbdc634SGreg Leheycylinders: 1211 5304cbdc634SGreg Leheysectors/unit: 1173930 5314cbdc634SGreg Leheyrpm: 3600 5324cbdc634SGreg Leheyinterleave: 1 5334cbdc634SGreg Leheytrackskew: 0 5344cbdc634SGreg Leheycylinderskew: 0 5354cbdc634SGreg Leheyheadswitch: 0 # milliseconds 5364cbdc634SGreg Leheytrack-to-track seek: 0 # milliseconds 5374cbdc634SGreg Leheydrivedata: 0 5384cbdc634SGreg Lehey 5394cbdc634SGreg Lehey8 partitions: 5404cbdc634SGreg Lehey# size offset fstype [fsize bsize bps/cpg] 5414cbdc634SGreg Lehey a: 81920 0 4.2BSD 1024 8192 16 # (Cyl. 0 - 84*) 5424cbdc634SGreg Lehey b: 160000 81920 swap # (Cyl. 84* - 218*) 5434cbdc634SGreg Lehey c: 1173930 0 unused 0 0 # (Cyl. 0 - 1211*) 5444cbdc634SGreg Lehey h: 962010 211920 vinum # (Cyl. 218*- 1211*) 5454cbdc634SGreg Lehey.Ed 5464cbdc634SGreg Lehey.Pp 5474cbdc634SGreg LeheyLines starting with a # mark are comments. Most of the other specifications are 5484cbdc634SGreg Leheyno longer used. The ones which must still be set correctly are: 5494cbdc634SGreg Lehey.Pp 5504cbdc634SGreg Lehey.Bl -hang -width 20n 5514cbdc634SGreg Lehey.It Nm label 5524cbdc634SGreg Leheyis an optional label, set by the 5534cbdc634SGreg Lehey.Ar packid 5544cbdc634SGreg Leheyoption when writing a label. 5554cbdc634SGreg Lehey.It Nm flags 5564cbdc634SGreg LeheyFlags may be 5574cbdc634SGreg Lehey.Ar removable , 5584cbdc634SGreg Lehey.Ar ecc 5594cbdc634SGreg Leheyor 5604cbdc634SGreg Lehey.Ar badsect . 5614cbdc634SGreg Lehey.Ar removable 562b5c508fbSRuslan Ermilovis set for removable media drives, but no current 563b5c508fbSRuslan Ermilov.Fx 564b5c508fbSRuslan Ermilovdriver evaluates this 5654cbdc634SGreg Leheyflag. 5664cbdc634SGreg Lehey.Ar ecc 5674cbdc634SGreg Leheyis no longer supported; 5684cbdc634SGreg Lehey.Ar badsect 5694cbdc634SGreg Leheyspecifies that the drive can perform bad sector remapping. 5704cbdc634SGreg Lehey.It Nm sectors/unit 5714cbdc634SGreg Leheydescribes the total size of the disk. This value must be correct. 5724cbdc634SGreg Lehey.It Nm the partition table 5737733674eSRuslan ErmilovThis is the 5747733674eSRuslan Ermilov.Ux 5757733674eSRuslan Ermilovpartition table, not the Microsoft partition table described in 5764cbdc634SGreg Lehey.Xr fdisk 8 . 5774cbdc634SGreg Lehey.El 5784cbdc634SGreg Lehey.Pp 5794cbdc634SGreg LeheyThe partition table can have up to 8 entries. It contains the following 5804cbdc634SGreg Leheyinformation: 5814cbdc634SGreg Lehey.Bl -hang -width 10n 5824cbdc634SGreg Lehey.It identifier 5834cbdc634SGreg LeheyThe partition identifier is a single letter in the range 5847733674eSRuslan Ermilov.Dq a 5854cbdc634SGreg Leheyto 5867733674eSRuslan Ermilov.Dq h . 5874cbdc634SGreg LeheyBy convention, partition 5887733674eSRuslan Ermilov.Dq c 5894cbdc634SGreg Leheyis reserved to describe the entire disk. 5904cbdc634SGreg Lehey.It size 5913233afaeSJohn W. De Boskeyis the size of the partition in sectors, 5927733674eSRuslan Ermilov.Cm K 5933233afaeSJohn W. De Boskey(kilobytes - 1024), 5947733674eSRuslan Ermilov.Cm M 5953233afaeSJohn W. De Boskey(megabytes - 1024*1024), 5967733674eSRuslan Ermilov.Cm G 5973233afaeSJohn W. De Boskey(gigabytes - 1024*1024*1024), 5987733674eSRuslan Ermilov.Cm % 5993233afaeSJohn W. De Boskey(percentage of free space AFTER removing any fixed-size partitions other 6003233afaeSJohn W. De Boskeythan partition 6017733674eSRuslan Ermilov.Dq c) , 6027733674eSRuslan Ermilovor 6037733674eSRuslan Ermilov.Cm * 6047733674eSRuslan Ermilov(all remaining free space AFTER fixed-size and percentage 6053233afaeSJohn W. De Boskeypartitions). For partition 6067733674eSRuslan Ermilov.Dq c , 6077733674eSRuslan Ermilova size of 6087733674eSRuslan Ermilov.Cm * 6097733674eSRuslan Ermilovindicates the entire disk. Lowercase versions of 6107733674eSRuslan Ermilov.Cm K , M , 6117733674eSRuslan Ermilovand 6127733674eSRuslan Ermilov.Cm G 6133233afaeSJohn W. De Boskeyare allowed. 6143233afaeSJohn W. De BoskeySize and type should be specifed without any spaces between them. 6153233afaeSJohn W. De Boskey.Pp 6163233afaeSJohn W. De BoskeyExample: 2097152, 1g, 1024m and 1048576k are all the same size 6173233afaeSJohn W. De Boskey(assuming 512-byte sectors). 6184cbdc634SGreg Lehey.It offset 6193233afaeSJohn W. De Boskeyis the offset of the start of the partition from the beginning of the 6207733674eSRuslan Ermilovdrive in sectors, or 6217733674eSRuslan Ermilov.Cm * 6227733674eSRuslan Ermilovto have 6233233afaeSJohn W. De Boskey.Nm 6243233afaeSJohn W. De Boskeycalculate the correct offset to use (the end of the previous partition plus 6253233afaeSJohn W. De Boskeyone, ignoring partition 6267733674eSRuslan Ermilov.Dq c . 6273233afaeSJohn W. De BoskeyFor partition 6287733674eSRuslan Ermilov.Dq c , 6297733674eSRuslan Ermilov.Cm * 6307733674eSRuslan Ermilovwill be interpreted as an offset of 0. 6314cbdc634SGreg Lehey.It fstype 63270e48365SGreg Leheydescribes the purpose of the partition. The example shows all currently used 63370e48365SGreg Leheypartition types. 63470e48365SGreg LeheyFor UFS file systems and ccd partitions, use type 6357733674eSRuslan Ermilov.Cm 4.2BSD . 63670e48365SGreg LeheyFor Vinum drives, use type 63770e48365SGreg Lehey.Cm vinum . 6383233afaeSJohn W. De BoskeyOther common types are 6397733674eSRuslan Ermilov.Cm unused 6403233afaeSJohn W. De Boskeyand 6417733674eSRuslan Ermilov.Cm swap . 6422f1aba69SRuslan ErmilovBy convention, partition 6432f1aba69SRuslan Ermilov.Dq c 6442f1aba69SRuslan Ermilovrepresents the entire slice and should be of type 64570e48365SGreg Lehey.Cm unused , 64670e48365SGreg Leheythough 64770e48365SGreg Lehey.Nm 64870e48365SGreg Leheydoes not enforce this convention. 64970e48365SGreg Lehey.Nm 65070e48365SGreg Leheyalso knows about a number of other partition types, none of which are in current 65170e48365SGreg Leheyuse. 65270e48365SGreg LeheySee the definitions starting with 6532f1aba69SRuslan Ermilov.Dv FS_UNUSED 6542f1aba69SRuslan Ermilovin 6554cbdc634SGreg Lehey.Pa /usr/include/sys/disklabel.h 65670e48365SGreg Leheyfor more details. 6574cbdc634SGreg Lehey.It fsize 6583233afaeSJohn W. De BoskeyFor 6597733674eSRuslan Ermilov.Cm 4.2BSD 6603233afaeSJohn W. De Boskeyand LFS file systems only, the fragment size. Defaults to 8192 for 6613233afaeSJohn W. De Boskeypartitions smaller than 1 GB, 16384 for partitions 1GB or larger. 6624cbdc634SGreg Lehey.It bsize 6633233afaeSJohn W. De BoskeyFor 6647733674eSRuslan Ermilov.Cm 4.2BSD 6653233afaeSJohn W. De Boskeyand LFS file systems only, the block size. Defaults to 1024 for 6663233afaeSJohn W. De Boskeypartitions smaller than 1 GB, 4096 for partitions 1GB or larger. 6674cbdc634SGreg Lehey.It bps/cpg 6683233afaeSJohn W. De BoskeyFor 6697733674eSRuslan Ermilov.Cm 4.2BSD 6703233afaeSJohn W. De Boskeyfile systems, the number of cylinders in a cylinder group. For LFS file 6713233afaeSJohn W. De Boskeysystems, the segment shift value. Defaults to 16 for 6723233afaeSJohn W. De Boskeypartitions smaller than 1 GB, 64 for partitions 1GB or larger. 6734cbdc634SGreg Lehey.El 674b60884cdSBen Smithurst.Pp 6754cbdc634SGreg LeheyThe remainder of the line is a comment and shows the cylinder allocations based 6764cbdc634SGreg Leheyon the obsolete (but possibly correct) geometry information about the drive. 6774cbdc634SGreg LeheyThe asterisk (*) indicates that the partition does not begin or end exactly on a 6784cbdc634SGreg Leheycylinder boundary. 6798fae3551SRodney W. Grimes.Sh EXAMPLES 6809f9930a2SRobert Nordier.Dl disklabel da0 6818fae3551SRodney W. Grimes.Pp 6824cbdc634SGreg LeheyDisplay the in-core label for 683ff7d5162SJordan K. Hubbard.Pa da0s1 6844cbdc634SGreg Leheyas obtained via 685ff7d5162SJordan K. Hubbard.Pa /dev/da0s1 . 686b5c508fbSRuslan ErmilovWhen reading a label, 687b5c508fbSRuslan Ermilov.Fx 688b5c508fbSRuslan Ermilovwill allow you to specify the base disk name 689ff7d5162SJordan K. Hubbardeven if the label resides on a slice. However, to be proper you should 690726b61abSRuslan Ermilovspecify the base disk name only if you are using a 691726b61abSRuslan Ermilov.Dq dangerously-dedicated 692ff7d5162SJordan K. Hubbardlabel. Normally you specify the slice. 6938fae3551SRodney W. Grimes.Pp 694ff7d5162SJordan K. Hubbard.Dl disklabel da0s1 > savedlabel 6954cbdc634SGreg Lehey.Pp 6964cbdc634SGreg LeheySave the in-core label for 697ff7d5162SJordan K. Hubbard.Pa da0s1 6984cbdc634SGreg Leheyinto the file 6994cbdc634SGreg Lehey.Pa savedlabel . 7004cbdc634SGreg LeheyThis file can be used with the 7014cbdc634SGreg Lehey.Fl R 7024cbdc634SGreg Leheyflag to restore the label at a later date. 7034cbdc634SGreg Lehey.Pp 704ff7d5162SJordan K. Hubbard.Dl disklabel -w -r /dev/da0s1 da2212 foo 7058fae3551SRodney W. Grimes.Pp 7064cbdc634SGreg LeheyCreate a label for 707ff7d5162SJordan K. Hubbard.Pa da0s1 7084cbdc634SGreg Leheybased on information for 709726b61abSRuslan Ermilov.Dq da2212 710726b61abSRuslan Ermilovfound in 7118fae3551SRodney W. Grimes.Pa /etc/disktab . 7128fae3551SRodney W. GrimesAny existing bootstrap code will be clobbered. 7138fae3551SRodney W. Grimes.Pp 714ff7d5162SJordan K. Hubbard.Dl disklabel -e -r da0s1 7158fae3551SRodney W. Grimes.Pp 7164cbdc634SGreg LeheyRead the on-disk label for 717ff7d5162SJordan K. Hubbard.Pa da0s1 , 7184cbdc634SGreg Leheyedit it and reinstall in-core as well as on-disk. Existing bootstrap code is 7194cbdc634SGreg Leheyunaffected. 7208fae3551SRodney W. Grimes.Pp 7213233afaeSJohn W. De Boskey.Dl disklabel -e -r -n da0s1 7223233afaeSJohn W. De Boskey.Pp 7233233afaeSJohn W. De BoskeyRead the on-disk label for 7243233afaeSJohn W. De Boskey.Pa da0s1 , 7253233afaeSJohn W. De Boskeyedit it, and display what the new label would be (in sectors). It does 7263233afaeSJohn W. De BoskeyNOT install the new label either in-core or on-disk. 7273233afaeSJohn W. De Boskey.Pp 728ff7d5162SJordan K. Hubbard.Dl disklabel -r -w da0s1 auto 729425bed3aSJoerg Wunsch.Pp 7304cbdc634SGreg LeheyTry to auto-detect the required information from 731ff7d5162SJordan K. Hubbard.Pa da0s1 , 7324cbdc634SGreg Leheyand write a new label to the disk. Use another disklabel -e command to edit the 733425bed3aSJoerg Wunschpartitioning and file system information. 734425bed3aSJoerg Wunsch.Pp 735ff7d5162SJordan K. Hubbard.Dl disklabel -R da0s1 savedlabel 7368fae3551SRodney W. Grimes.Pp 7374cbdc634SGreg LeheyRestore the on-disk and in-core label for 738ff7d5162SJordan K. Hubbard.Pa da0s1 7394cbdc634SGreg Leheyfrom information in 7404cbdc634SGreg Lehey.Pa savedlabel . 7418fae3551SRodney W. GrimesExisting bootstrap code is unaffected. 7428fae3551SRodney W. Grimes.Pp 7433233afaeSJohn W. De Boskey.Dl disklabel -R -n da0s1 label_layout 7443233afaeSJohn W. De Boskey.Pp 7453233afaeSJohn W. De BoskeyDisplay what the label would be for 7463233afaeSJohn W. De Boskey.Pa da0s1 7473233afaeSJohn W. De Boskeyusing the partition layout in 7483233afaeSJohn W. De Boskey.Pa label_layout . 7493233afaeSJohn W. De BoskeyThis is useful for determining how much space would be alloted for various 7507733674eSRuslan Ermilovpartitions with a labelling scheme using 7517733674eSRuslan Ermilov.Cm % Ns -based 7527733674eSRuslan Ermilovor 7537733674eSRuslan Ermilov.Cm * 7547733674eSRuslan Ermilovpartition sizes. 7553233afaeSJohn W. De Boskey.Pp 756ff7d5162SJordan K. Hubbard.Dl disklabel -B da0s1 7578fae3551SRodney W. Grimes.Pp 7584cbdc634SGreg LeheyInstall a new bootstrap on 759ff7d5162SJordan K. Hubbard.Pa da0s1 . 7608fae3551SRodney W. GrimesThe boot code comes from 761efba76d7SJordan K. Hubbard.Pa /boot/boot1 7628fae3551SRodney W. Grimesand possibly 763efba76d7SJordan K. Hubbard.Pa /boot/boot2 . 7648fae3551SRodney W. GrimesOn-disk and in-core labels are unchanged. 7658fae3551SRodney W. Grimes.Pp 766ff7d5162SJordan K. Hubbard.Dl disklabel -w -B /dev/da0s1 -b newboot1 -s newboot da2212 7678fae3551SRodney W. Grimes.Pp 7688fae3551SRodney W. GrimesInstall a new label and bootstrap. 769726b61abSRuslan ErmilovThe label is derived from disktab information for 770726b61abSRuslan Ermilov.Dq da2212 771726b61abSRuslan Ermilovand installed both in-core and on-disk. 7724cbdc634SGreg LeheyThe bootstrap code comes from the files 7734cbdc634SGreg Lehey.Pa /boot/newboot1 7744cbdc634SGreg Leheyand 7754cbdc634SGreg Lehey.Pa /boot/newboot2 . 776ff7d5162SJordan K. Hubbard.Pp 777ff7d5162SJordan K. Hubbard.Dl dd if=/dev/zero of=/dev/da0 bs=512 count=32 778ff7d5162SJordan K. Hubbard.Dl fdisk -BI da0 779ff7d5162SJordan K. Hubbard.Dl dd if=/dev/zero of=/dev/da0s1 bs=512 count=32 780ff7d5162SJordan K. Hubbard.Dl disklabel -w -r -B da0s1 auto 781ff7d5162SJordan K. Hubbard.Dl disklabel -e da0s1 782ff7d5162SJordan K. Hubbard.Pp 783ff7d5162SJordan K. HubbardCompletely wipe any prior information on the disk, creating a new bootable 784726b61abSRuslan Ermilovdisk with a DOS partition table containing one 785726b61abSRuslan Ermilov.Dq whole-disk 786726b61abSRuslan Ermilovslice. Then 787ff7d5162SJordan K. Hubbardinitialize the slice, then edit it to your needs. The 788ff7d5162SJordan K. Hubbard.Pa dd 789ff7d5162SJordan K. Hubbardcommands are optional, but may be necessary for some BIOSes to properly 790ff7d5162SJordan K. Hubbardrecognize the disk. 7913233afaeSJohn W. De Boskey.Pp 7923233afaeSJohn W. De BoskeyThis is an example disklabel that uses some of the new partition size types 7937733674eSRuslan Ermilovsuch as 7947733674eSRuslan Ermilov.Cm % , M , G , 7957733674eSRuslan Ermilovand 7967733674eSRuslan Ermilov.Cm * , 7977733674eSRuslan Ermilovwhich could be used as a source file for 7983233afaeSJohn W. De Boskey.Pp 7993233afaeSJohn W. De Boskey.Dl disklabel -R ad0s1c new_label_file 8003233afaeSJohn W. De Boskey.Bd -literal -offset 4n 8013233afaeSJohn W. De Boskey# /dev/ad0s1c: 8023233afaeSJohn W. De Boskeytype: ESDI 8033233afaeSJohn W. De Boskeydisk: ad0s1 8043233afaeSJohn W. De Boskeylabel: 8053233afaeSJohn W. De Boskeyflags: 8063233afaeSJohn W. De Boskeybytes/sector: 512 8073233afaeSJohn W. De Boskeysectors/track: 63 8083233afaeSJohn W. De Boskeytracks/cylinder: 16 8093233afaeSJohn W. De Boskeysectors/cylinder: 1008 8103233afaeSJohn W. De Boskeycylinders: 40633 8113233afaeSJohn W. De Boskeysectors/unit: 40959009 8123233afaeSJohn W. De Boskeyrpm: 3600 8133233afaeSJohn W. De Boskeyinterleave: 1 8143233afaeSJohn W. De Boskeytrackskew: 0 8153233afaeSJohn W. De Boskeycylinderskew: 0 8163233afaeSJohn W. De Boskeyheadswitch: 0 # milliseconds 8173233afaeSJohn W. De Boskeytrack-to-track seek: 0 # milliseconds 8183233afaeSJohn W. De Boskeydrivedata: 0 8193233afaeSJohn W. De Boskey 8203233afaeSJohn W. De Boskey8 partitions: 8213233afaeSJohn W. De Boskey# size offset fstype [fsize bsize bps/cpg] 8223233afaeSJohn W. De Boskey a: 400M 0 4.2BSD 4096 16384 75 # (Cyl. 0 - 812*) 8233233afaeSJohn W. De Boskey b: 1G * swap 8243233afaeSJohn W. De Boskey c: * * unused 8253233afaeSJohn W. De Boskey e: 204800 * 4.2BSD 8263233afaeSJohn W. De Boskey f: 5g * 4.2BSD 8273233afaeSJohn W. De Boskey g: * * 4.2BSD 8283233afaeSJohn W. De Boskey.Ed 8298fae3551SRodney W. Grimes.Sh SEE ALSO 83070e48365SGreg Lehey.Xr ccd 4 , 831af202156SWolfram Schneider.Xr disklabel 5 , 8324cbdc634SGreg Lehey.Xr disktab 5 , 833aa7c9adaSMike Pritchard.Xr boot0cfg 8 , 83470e48365SGreg Lehey.Xr fdisk 8 , 83570e48365SGreg Lehey.Xr vinum 8 8368fae3551SRodney W. Grimes.Sh DIAGNOSTICS 8378fae3551SRodney W. GrimesThe kernel device drivers will not allow the size of a disk partition 8388fae3551SRodney W. Grimesto be decreased or the offset of a partition to be changed while it is open. 8398fae3551SRodney W. GrimesSome device drivers create a label containing only a single large partition 8404cbdc634SGreg Leheyif a disk is unlabeled; thus, the label must be written to the 841726b61abSRuslan Ermilov.Dq a 8424cbdc634SGreg Leheypartition of the disk while it is open. This sometimes requires the desired 8434cbdc634SGreg Leheylabel to be set in two steps, the first one creating at least one other 8444cbdc634SGreg Leheypartition, and the second setting the label on the new partition while shrinking 8454cbdc634SGreg Leheythe 846726b61abSRuslan Ermilov.Dq a 8474cbdc634SGreg Leheypartition. 8488fae3551SRodney W. Grimes.Pp 8498fae3551SRodney W. GrimesOn some machines the bootstrap code may not fit entirely in the area 8508fae3551SRodney W. Grimesallocated for it by some filesystems. 8518fae3551SRodney W. GrimesAs a result, it may not be possible to have filesystems on some partitions 852726b61abSRuslan Ermilovof a 853726b61abSRuslan Ermilov.Dq bootable 854726b61abSRuslan Ermilovdisk. 8558fae3551SRodney W. GrimesWhen installing bootstrap code, 8566bd343a9SPhilippe Charnier.Nm 8578fae3551SRodney W. Grimeschecks for these cases. 8588fae3551SRodney W. GrimesIf the installed boot code would overlap a partition of type FS_UNUSED 8598fae3551SRodney W. Grimesit is marked as type FS_BOOT. 8608fae3551SRodney W. GrimesThe 8618fae3551SRodney W. Grimes.Xr newfs 8 8628fae3551SRodney W. Grimesutility will disallow creation of filesystems on FS_BOOT partitions. 8638fae3551SRodney W. GrimesConversely, if a partition has a type other than FS_UNUSED or FS_BOOT, 8646bd343a9SPhilippe Charnier.Nm 8658fae3551SRodney W. Grimeswill not install bootstrap code that overlaps it. 8668fae3551SRodney W. Grimes.Sh BUGS 8678fae3551SRodney W. GrimesWhen a disk name is given without a full pathname, 868726b61abSRuslan Ermilovthe constructed device name uses the 869726b61abSRuslan Ermilov.Dq c 870726b61abSRuslan Ermilovpartition. 871d70e4e53SJoerg Wunsch.Pp 872d70e4e53SJoerg WunschFor the i386 architecture, the primary bootstrap sector contains 873d70e4e53SJoerg Wunschan embedded 874d70e4e53SJoerg Wunsch.Em fdisk 875d70e4e53SJoerg Wunschtable. 876d70e4e53SJoerg Wunsch.Nm Disklabel 877d70e4e53SJoerg Wunschtakes care to not clobber it when installing a bootstrap only 878d70e4e53SJoerg Wunsch.Pq Fl B , 879d70e4e53SJoerg Wunschor when editing an existing label 880d70e4e53SJoerg Wunsch.Pq Fl e , 881d70e4e53SJoerg Wunschbut it unconditionally writes the primary bootstrap program onto 882d70e4e53SJoerg Wunschthe disk for 883d70e4e53SJoerg Wunsch.Fl w 884d70e4e53SJoerg Wunschor 885d70e4e53SJoerg Wunsch.Fl R , 886d70e4e53SJoerg Wunschthus replacing the 887d70e4e53SJoerg Wunsch.Em fdisk 888d70e4e53SJoerg Wunschtable by the dummy one in the bootstrap program. This is only of 889d70e4e53SJoerg Wunschconcern if the disk is fully dedicated, so that the BSD disklabel 890d70e4e53SJoerg Wunschstarts at absolute block 0 on the disk. 8914cbdc634SGreg Lehey.Pp 8924cbdc634SGreg Lehey.Nm 8933233afaeSJohn W. De Boskeydoes not perform all possible error checking. Warning *is* given if partitions 8947733674eSRuslan Ermilovoverlap; if an absolute offset does not match the expected offset; if the 8957733674eSRuslan Ermilov.Dq c 8967733674eSRuslan Ermilovpartition does not start at 0 or does not cover the entire slice; if a 8973233afaeSJohn W. De Boskeypartition runs past the end of the device; and a number of other errors; but 8983233afaeSJohn W. De Boskeyno warning is given if space remains unused. 899