xref: /freebsd/sbin/bsdlabel/bsdlabel.8 (revision e1205e80e5c937ac999f02f51edfb25d5b7a7ad6)
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
97e1205e80SPhilippe CharnierThe
98e1205e80SPhilippe Charnier.Nm
99e1205e80SPhilippe Charnierutility
1005a6d7397STim Vanderhoekinstalls, examines or modifies the label on a disk drive or pack.  When writing
1014cbdc634SGreg Leheythe label, it can be used to change the drive identification, the disk
1024cbdc634SGreg Leheypartitions on the drive, or to replace a damaged label.  There are several forms
1034cbdc634SGreg Leheyof the command that read (display), install or edit the label on a disk.  In
1044cbdc634SGreg Leheyaddition,
1056bd343a9SPhilippe Charnier.Nm
1064cbdc634SGreg Leheycan install bootstrap code.
1074cbdc634SGreg Lehey.Ss Raw or in-core label
1084cbdc634SGreg Lehey.Pp
1092c80d96eSTom RhodesThe disk label resides close to or at the beginning of each disk slice.
1104cbdc634SGreg LeheyFor faster access, the kernel maintains a copy in core at all times.  By
1114cbdc634SGreg Leheydefault, most
1124cbdc634SGreg Lehey.Nm
1134cbdc634SGreg Leheyaccess the in-core copy of the label.  To access the raw (on-disk) copy, use the
1144cbdc634SGreg Lehey.Fl r
1154cbdc634SGreg Leheyoption.  This option allows a label to be installed on a disk without kernel
1164cbdc634SGreg Leheysupport for a label, such as when labels are first installed on a system; it
1174cbdc634SGreg Leheymust be used when first installing a label on a disk.  The specific effect of
1188fae3551SRodney W. Grimes.Fl r
1198fae3551SRodney W. Grimesis described under each command.
1208fae3551SRodney W. Grimes.Pp
1214cbdc634SGreg Lehey.Ss Disk device name
1224cbdc634SGreg Lehey.Pp
1234cbdc634SGreg LeheyAll
1247c7fb079SRuslan Ermilov.Nm
1254cbdc634SGreg Leheyforms require a disk device name, which should always be the raw
126ff7d5162SJordan K. Hubbarddevice name representing the disk or slice.  For example
127ff7d5162SJordan K. Hubbard.Pa da0
1282c80d96eSTom Rhodesrepresents the entire disk regardless of any DOS partitioning,
129ff7d5162SJordan K. Hubbardand
130ff7d5162SJordan K. Hubbard.Pa da0s1
131ff7d5162SJordan K. Hubbardrepresents a slice.  Some devices, most notably
132ff7d5162SJordan K. Hubbard.Ar ccd ,
133ff7d5162SJordan K. Hubbardrequire that the
134726b61abSRuslan Ermilov.Dq whole-disk
135726b61abSRuslan Ermilov(or
136726b61abSRuslan Ermilov.Dq c )
137ff7d5162SJordan K. Hubbardpartition be specified.  For example
138ff7d5162SJordan K. Hubbard.Pa ccd0c .
139ff7d5162SJordan K. HubbardYou do not have to include the
140ff7d5162SJordan K. Hubbard.Pa /dev/
141ff7d5162SJordan K. Hubbardpath prefix when specifying the device.
142e1205e80SPhilippe CharnierThe
1434cbdc634SGreg Lehey.Nm
144e1205e80SPhilippe Charnierutility will automatically prepend it.
1454cbdc634SGreg Lehey.Ss Reading the disk label
1464cbdc634SGreg Lehey.Pp
147e40fcc98SDima DorfmanTo examine the label on a disk drive, use
1484cbdc634SGreg Lehey.Nm
1494cbdc634SGreg Leheywithout options:
1504cbdc634SGreg Lehey.Pp
1517c7fb079SRuslan Ermilov.Nm
1524cbdc634SGreg Lehey.Op Fl r
1534cbdc634SGreg Lehey.Ar disk
1544cbdc634SGreg Lehey.Pp
1554cbdc634SGreg Lehey.Ar disk
1564cbdc634SGreg Leheyrepresents the raw disk in question, and may be in the form
1574cbdc634SGreg Lehey.Pa da0
1584cbdc634SGreg Leheyor
15907b0cf9aSDavid E. O'Brien.Pa /dev/da0c .
1604cbdc634SGreg LeheyIt will display all of the parameters associated with the drive and its
1614cbdc634SGreg Leheypartition layout.  Unless the
1628fae3551SRodney W. Grimes.Fl r
1638fae3551SRodney W. Grimesflag is given,
1648fae3551SRodney W. Grimesthe kernel's in-core copy of the label is displayed;
1658fae3551SRodney W. Grimesif the disk has no label, or the partition types on the disk are incorrect,
1668fae3551SRodney W. Grimesthe kernel may have constructed or modified the label.
1678fae3551SRodney W. GrimesIf the
1688fae3551SRodney W. Grimes.Fl r
1694cbdc634SGreg Leheyflag is given,
1704cbdc634SGreg Lehey.Nm
171ff7d5162SJordan K. Hubbardreads the label from the raw disk and displays it.  Both versions are usually
172ff7d5162SJordan K. Hubbardidentical except in the case where a label has not yet been initialized or
173ff7d5162SJordan K. Hubbardis corrupt.
1744cbdc634SGreg Lehey.Ss Writing a standard label
1758fae3551SRodney W. Grimes.Pp
1764cbdc634SGreg LeheyTo write a standard label, use the form
1774cbdc634SGreg Lehey.Pp
1787c7fb079SRuslan Ermilov.Nm
1798fae3551SRodney W. Grimes.Fl w
1804cbdc634SGreg Lehey.Op Fl r
1813233afaeSJohn W. De Boskey.Op Fl n
182ff7d5162SJordan K. Hubbard.Ar disk Ar disktype/auto
1834cbdc634SGreg Lehey.Oo Ar packid Oc
1844cbdc634SGreg Lehey.Pp
1857c7fb079SRuslan Ermilov.Nm
186ff7d5162SJordan K. Hubbard.Fl w
187ff7d5162SJordan K. Hubbard.Op Fl r
1883233afaeSJohn W. De Boskey.Op Fl n
189ff7d5162SJordan K. Hubbard.Ar disk
190ff7d5162SJordan K. Hubbardauto
191ff7d5162SJordan K. Hubbard.Pp
1928fae3551SRodney W. GrimesThe required arguments to
1936bd343a9SPhilippe Charnier.Nm
1944cbdc634SGreg Leheyare the drive to be labeled and the drive type as described in the
195d0353b83SRuslan Ermilov.Xr disktab 5
1964cbdc634SGreg Leheyfile.  The drive parameters and partitions are taken from that file.  If
1974cbdc634SGreg Leheydifferent disks of the same physical type are to have different partitions, it
1984cbdc634SGreg Leheywill be necessary to have separate disktab entries describing each, or to edit
1994cbdc634SGreg Leheythe label after installation as described below.  The optional argument is a
2004cbdc634SGreg Leheypack identification string, up to 16 characters long.  The pack id must be
2013233afaeSJohn W. De Boskeyquoted if it contains blanks.
2023233afaeSJohn W. De Boskey.Pp
2033233afaeSJohn W. De BoskeyIf the
2043233afaeSJohn W. De Boskey.Fl n
2053233afaeSJohn W. De Boskeyflag is given, no data will be written to the device, and instead the
2063233afaeSJohn W. De Boskeydisklabel that would have been written will be printed to stdout.
2073233afaeSJohn W. De Boskey.Pp
2083233afaeSJohn W. De BoskeyIf the
2098fae3551SRodney W. Grimes.Fl r
2108fae3551SRodney W. Grimesflag is given, the disk sectors containing the label and bootstrap
2118fae3551SRodney W. Grimeswill be written directly.
2128fae3551SRodney W. GrimesA side-effect of this is that any existing bootstrap code will be overwritten
2134cbdc634SGreg Leheyand the disk rendered unbootable.  See the boot options below for a method of
2144cbdc634SGreg Leheywriting the label and the bootstrap at the same time.
2158fae3551SRodney W. GrimesIf
2168fae3551SRodney W. Grimes.Fl r
2178fae3551SRodney W. Grimesis not specified,
2188fae3551SRodney W. Grimesthe existing label will be updated via the in-core copy and any bootstrap
2198fae3551SRodney W. Grimescode will be unaffected.
2208fae3551SRodney W. GrimesIf the disk does not already have a label, the
2218fae3551SRodney W. Grimes.Fl r
2228fae3551SRodney W. Grimesflag must be used.
2238fae3551SRodney W. GrimesIn either case, the kernel's in-core label is replaced.
2248fae3551SRodney W. Grimes.Pp
225425bed3aSJoerg WunschFor a virgin disk that is not known to
226425bed3aSJoerg Wunsch.Xr disktab 5 ,
227425bed3aSJoerg Wunsch.Ar disktype
228425bed3aSJoerg Wunschcan be specified as
229425bed3aSJoerg Wunsch.Dq auto .
230425bed3aSJoerg WunschIn this case, the driver is requested to produce a virgin label for the
231425bed3aSJoerg Wunschdisk.  This might or might not be successful, depending on whether the
232425bed3aSJoerg Wunschdriver for the disk is able to get the required data without reading
233425bed3aSJoerg Wunschanything from the disk at all.  It will likely succeed for all SCSI
234425bed3aSJoerg Wunschdisks, most IDE disks, and vnode devices.  Writing a label to the
235425bed3aSJoerg Wunschdisk is the only supported operation, and the
236425bed3aSJoerg Wunsch.Ar disk
237425bed3aSJoerg Wunschitself must be provided as the canonical name, i.e. not as a full
238425bed3aSJoerg Wunschpath name.
239ff7d5162SJordan K. Hubbard.Pp
2403233afaeSJohn W. De BoskeyFor most harddisks, a label based on percentages for most partitions (and
2417733674eSRuslan Ermilovone partition with a size of
2427733674eSRuslan Ermilov.Ql * )
2437733674eSRuslan Ermilovwill produce a reasonable configuration.
2443233afaeSJohn W. De Boskey.Pp
245ff7d5162SJordan K. HubbardPC-based systems have special requirements in order for the BIOS to properly
246b5c508fbSRuslan Ermilovrecognize a
247b5c508fbSRuslan Ermilov.Fx
248b5c508fbSRuslan Ermilovdisklabel.  Older systems may require what is known as a
249726b61abSRuslan Ermilov.Dq dangerously dedicated
250ff7d5162SJordan K. Hubbarddisklabel, which creates a fake DOS partition to work around problems older
2512c80d96eSTom RhodesBIOSes have with modern disk geometries.
2522c80d96eSTom RhodesOn newer systems you generally want
2532c80d96eSTom Rhodesto create a normal DOS partition using
254ff7d5162SJordan K. Hubbard.Ar fdisk
255b5c508fbSRuslan Ermilovand then create a
256b5c508fbSRuslan Ermilov.Fx
257b5c508fbSRuslan Ermilovdisklabel within that slice.  This is described
258ff7d5162SJordan K. Hubbardlater on in this page.
259ff7d5162SJordan K. Hubbard.Pp
260ff7d5162SJordan K. HubbardInstalling a new disklabel does not in of itself allow your system to boot
261ff7d5162SJordan K. Hubbarda kernel using that label.  You must also install boot blocks, which is
262ff7d5162SJordan K. Hubbarddescribed later on in this manual page.
2634cbdc634SGreg Lehey.Ss Editing an existing disk label
264425bed3aSJoerg Wunsch.Pp
2654cbdc634SGreg LeheyTo edit an existing disk label, use the form
2664cbdc634SGreg Lehey.Pp
2677c7fb079SRuslan Ermilov.Nm
2688fae3551SRodney W. Grimes.Fl e
2694cbdc634SGreg Lehey.Op Fl r
2703233afaeSJohn W. De Boskey.Op Fl n
2714cbdc634SGreg Lehey.Ar disk
2724cbdc634SGreg Lehey.Pp
2734cbdc634SGreg LeheyThis command reads the label from the in-core kernel copy, or directly from the
2744cbdc634SGreg Leheydisk if the
2758fae3551SRodney W. Grimes.Fl r
2764cbdc634SGreg Leheyflag is also specified.  The label is written to a file in ASCII and then
2774cbdc634SGreg Leheysupplied to an editor for changes.  If no editor is specified in an
2788fae3551SRodney W. Grimes.Ev EDITOR
2798fae3551SRodney W. Grimesenvironment variable,
2808fae3551SRodney W. Grimes.Xr vi 1
2814cbdc634SGreg Leheyis used.  When the editor terminates, the label file is used to rewrite the disk
2824cbdc634SGreg Leheylabel.  Existing bootstrap code is unchanged regardless of whether
2838fae3551SRodney W. Grimes.Fl r
2843233afaeSJohn W. De Boskeywas specified.  If
2853233afaeSJohn W. De Boskey.Fl n
2863233afaeSJohn W. De Boskeyis specified, no data will be written to the device, and instead the
2873233afaeSJohn W. De Boskeydisklabel that would have been written will be printed to stdout.  This is
2883233afaeSJohn W. De Boskeyuseful to see how a partitioning scheme will work out for a specific disk.
2894cbdc634SGreg Lehey.Ss Restoring a disk label from a file
2908fae3551SRodney W. Grimes.Pp
2914cbdc634SGreg LeheyTo restore a disk label from a file, use the form
2924cbdc634SGreg Lehey.Pp
2937c7fb079SRuslan Ermilov.Nm
2948fae3551SRodney W. Grimes.Fl R
2954cbdc634SGreg Lehey.Op Fl r
2963233afaeSJohn W. De Boskey.Op Fl n
2974cbdc634SGreg Lehey.Ar disk Ar protofile
2988fae3551SRodney W. Grimes.Pp
2996bd343a9SPhilippe Charnier.Nm
3005ef18a82SGreg Leheyis capable of restoring a disk label that was previously saved in a file in ASCII format.
3014cbdc634SGreg LeheyThe prototype file used to create the label should be in the same format as that
3024cbdc634SGreg Leheyproduced when reading or editing a label.  Comments are delimited by
3034cbdc634SGreg Lehey.Ar \&#
3044cbdc634SGreg Leheyand newline.  As when writing a new label, any existing bootstrap code will be
3054cbdc634SGreg Leheyclobbered if
3064cbdc634SGreg Lehey.Fl r
3074cbdc634SGreg Leheyis specified and will be unaffected otherwise.  See the boot options below for a
3084cbdc634SGreg Leheymethod of restoring the label and writing the bootstrap at the same time.
3093233afaeSJohn W. De BoskeyIf
3103233afaeSJohn W. De Boskey.Fl n
3113233afaeSJohn W. De Boskeyis used, no data will be written to the device, and instead the
3123233afaeSJohn W. De Boskeydisklabel that would have been written will be printed to stdout.  This is
3133233afaeSJohn W. De Boskeyuseful to see how a partitioning scheme will work out for a specific disk.
3144cbdc634SGreg Lehey.Ss Enabling and disabling writing to the disk label area
3154cbdc634SGreg Lehey.Pp
3164cbdc634SGreg LeheyBy default, it is not possible to write to the disk label area at the beginning
3174cbdc634SGreg Leheyof a disk.  The disk driver silently ignores any attempt to do so.  If you need
3184cbdc634SGreg Leheyto write to this area (for example, to obliterate the label), use the form
3194cbdc634SGreg Lehey.Pp
3207c7fb079SRuslan Ermilov.Nm
3211c1a8b56SDima Dorfman.Fl W
3224cbdc634SGreg Lehey.Ar disk
3234cbdc634SGreg Lehey.Pp
3244cbdc634SGreg LeheyTo disallow writing to the label area after previously allowing it, use the
3254cbdc634SGreg Leheycommand
3264cbdc634SGreg Lehey.Pp
3277c7fb079SRuslan Ermilov.Nm
3281c1a8b56SDima Dorfman.Fl N
3294cbdc634SGreg Lehey.Ar disk
3304cbdc634SGreg Lehey.Ss Installing bootstraps
3318fae3551SRodney W. Grimes.Pp
3328fae3551SRodney W. GrimesThe final three forms of
3336bd343a9SPhilippe Charnier.Nm
334ff7d5162SJordan K. Hubbardare used to install bootstrap code.  If you are creating a
335726b61abSRuslan Ermilov.Dq dangerously-dedicated
3362c80d96eSTom Rhodesslice for compatibility with older PC systems,
337ff7d5162SJordan K. Hubbardyou generally want to specify the raw disk name such as
338ff7d5162SJordan K. Hubbard.Pa da0 .
3392c80d96eSTom RhodesIf you are creating a label within an existing DOS slice,
3402c80d96eSTom Rhodesyou should specify
3412c80d96eSTom Rhodesthe partition name such as
3422c80d96eSTom Rhodes.Pa da0s1a .
3432c80d96eSTom RhodesMaking a slice bootable can be tricky.  If you are using a normal DOS
344ff7d5162SJordan K. Hubbardslice you typically install (or leave) a standard MBR on the base disk and
345b5c508fbSRuslan Ermilovthen install the
346b5c508fbSRuslan Ermilov.Fx
347b5c508fbSRuslan Ermilovbootblocks in the slice.
3484cbdc634SGreg Lehey.Pp
3497c7fb079SRuslan Ermilov.Nm
3508fae3551SRodney W. Grimes.Fl B
3514cbdc634SGreg Lehey.Oo
3524cbdc634SGreg Lehey.Fl b Ar boot1
3534cbdc634SGreg Lehey.Fl s Ar boot2
3544cbdc634SGreg Lehey.Oc
3554cbdc634SGreg Lehey.Ar disk
3564cbdc634SGreg Lehey.Oo Ar disktype Oc
3574cbdc634SGreg Lehey.Pp
3584cbdc634SGreg LeheyThis form installs the bootstrap only.  It does not change the disk label.
359726b61abSRuslan ErmilovYou should never use this command on a base disk unless you intend to create a
360726b61abSRuslan Ermilov.Dq dangerously-dedicated
361726b61abSRuslan Ermilovdisk, such as
362ff7d5162SJordan K. Hubbard.Ar da0 .
363ff7d5162SJordan K. HubbardThis command is typically run on a slice such as
364ff7d5162SJordan K. Hubbard.Ar da0s1 .
3654cbdc634SGreg Lehey.Pp
3667c7fb079SRuslan Ermilov.Nm
3674cbdc634SGreg Lehey.Fl w
3684cbdc634SGreg Lehey.Fl B
3693233afaeSJohn W. De Boskey.Op Fl n
3704cbdc634SGreg Lehey.Oo
3714cbdc634SGreg Lehey.Fl b Ar boot1
3724cbdc634SGreg Lehey.Fl s Ar boot2
3734cbdc634SGreg Lehey.Oc
3744cbdc634SGreg Lehey.Ar disk Ar disktype
3754cbdc634SGreg Lehey.Oo Ar packid Oc
3764cbdc634SGreg Lehey.Pp
377726b61abSRuslan ErmilovThis form corresponds to the
378726b61abSRuslan Ermilov.Dq write label
379726b61abSRuslan Ermilovcommand described above.
3804cbdc634SGreg LeheyIn addition to writing a new volume label, it also installs the bootstrap.
381726b61abSRuslan ErmilovIf run on a base disk this command will create a
382726b61abSRuslan Ermilov.Dq dangerously-dedicated
383b60884cdSBen Smithurstlabel.  This command is normally run on a slice rather than a base disk.
3843233afaeSJohn W. De BoskeyIf
3853233afaeSJohn W. De Boskey.Fl n
3863233afaeSJohn W. De Boskeyis used, no data will be written to the device, and instead the
3873233afaeSJohn W. De Boskeydisklabel that would have been written will be printed to stdout.
3884cbdc634SGreg Lehey.Pp
3897c7fb079SRuslan Ermilov.Nm
3904cbdc634SGreg Lehey.Fl R
3914cbdc634SGreg Lehey.Fl B
3923233afaeSJohn W. De Boskey.Op Fl n
3934cbdc634SGreg Lehey.Oo
3944cbdc634SGreg Lehey.Fl b Ar boot1
3954cbdc634SGreg Lehey.Fl s Ar boot2
3964cbdc634SGreg Lehey.Oc
3974cbdc634SGreg Lehey.Ar disk Ar protofile
3984cbdc634SGreg Lehey.Oo Ar disktype Oc
3994cbdc634SGreg Lehey.Pp
400726b61abSRuslan ErmilovThis form corresponds to the
401726b61abSRuslan Ermilov.Dq restore label
402726b61abSRuslan Ermilovcommand described above.
4034cbdc634SGreg LeheyIn addition to restoring the volume label, it also installs the bootstrap.
404726b61abSRuslan ErmilovIf run on a base disk this command will create a
405726b61abSRuslan Ermilov.Dq dangerously-dedicated
406b60884cdSBen Smithurstlabel.  This command is normally run on a slice rather than a base disk.
4074cbdc634SGreg Lehey.Pp
4084cbdc634SGreg LeheyThe bootstrap commands always access the disk directly, so it is not necessary
4094cbdc634SGreg Leheyto specify the
4108fae3551SRodney W. Grimes.Fl r
4113233afaeSJohn W. De Boskeyflag.  If
4123233afaeSJohn W. De Boskey.Fl n
4133233afaeSJohn W. De Boskeyis used, no data will be written to the device, and instead the
4143233afaeSJohn W. De Boskeydisklabel that would have been written will be printed to stdout.
4154cbdc634SGreg Lehey.Pp
4164cbdc634SGreg LeheyThe bootstrap code is comprised of two boot programs.  Specify the name of the
4174cbdc634SGreg Leheyboot programs to be installed in one of these ways:
4184cbdc634SGreg Lehey.Bl -enum
4194cbdc634SGreg Lehey.It
4204cbdc634SGreg LeheySpecify the names explicitly with the
4218fae3551SRodney W. Grimes.Fl b
4228fae3551SRodney W. Grimesand
4238fae3551SRodney W. Grimes.Fl s
4248fae3551SRodney W. Grimesflags.
4258fae3551SRodney W. Grimes.Fl b
4268fae3551SRodney W. Grimesindicates the primary boot program and
4278fae3551SRodney W. Grimes.Fl s
4284cbdc634SGreg Leheythe secondary boot program.  The boot programs are located in
429efba76d7SJordan K. Hubbard.Pa /boot .
4304cbdc634SGreg Lehey.It
4314cbdc634SGreg LeheyIf the
4324cbdc634SGreg Lehey.Fl b
4334cbdc634SGreg Leheyand
4344cbdc634SGreg Lehey.Fl s
4354cbdc634SGreg Leheyflags are not specified, but
4368fae3551SRodney W. Grimes.Ar disktype
4374cbdc634SGreg Leheywas specified, the names of the programs are taken from the
438726b61abSRuslan Ermilov.Dq b0
439726b61abSRuslan Ermilovand
440726b61abSRuslan Ermilov.Dq b1
4414cbdc634SGreg Leheyparameters of the
4424cbdc634SGreg Lehey.Xr disktab 5
4434cbdc634SGreg Leheyentry for the disk if the disktab entry exists and includes those parameters.
4444cbdc634SGreg Lehey.It
4454cbdc634SGreg LeheyOtherwise, the default boot image names are used:
446efba76d7SJordan K. Hubbard.Pa /boot/boot1
4478fae3551SRodney W. Grimesand
448efba76d7SJordan K. Hubbard.Pa /boot/boot2
449efba76d7SJordan K. Hubbardfor the standard stage1 and stage2 boot images (details may vary
450efba76d7SJordan K. Hubbardon architectures like the Alpha, where only a single-stage boot is used).
4514cbdc634SGreg Lehey.El
452ff7d5162SJordan K. Hubbard.Ss Initializing/Formatting a bootable disk from scratch
453ff7d5162SJordan K. Hubbard.Pp
454ff7d5162SJordan K. HubbardTo initialize a disk from scratch the following sequence is recommended.
455ff7d5162SJordan K. HubbardPlease note that this will wipe everything that was previously on the disk,
456b5c508fbSRuslan Ermilovincluding any
457b5c508fbSRuslan Ermilov.No non- Ns Fx
458b5c508fbSRuslan Ermilovslices.
459ff7d5162SJordan K. Hubbard.Bl -enum
460ff7d5162SJordan K. Hubbard.It
461ff7d5162SJordan K. HubbardUse
4622c80d96eSTom Rhodes.Xr fdisk 8
4632c80d96eSTom Rhodesto initialize the hard disk, and create a slice table, referred to
4642c80d96eSTom Rhodesas the partition table in DOS.
4652c80d96eSTom RhodesHere you will define disk slices for your system.
466ff7d5162SJordan K. Hubbard.It
467ff7d5162SJordan K. HubbardUse
4682c80d96eSTom Rhodes.Xr disklabel 8
4692c80d96eSTom Rhodesto define and write partitions and mount points.
4702c80d96eSTom RhodesYou are not required to define the mount points here though,
4712c80d96eSTom Rhodesthey can be defined later using
4722c80d96eSTom Rhodes.Xr mount 8 .
473ff7d5162SJordan K. Hubbard.It
4742c80d96eSTom RhodesFinally use
4752c80d96eSTom Rhodes.Xr newfs 8
4762c80d96eSTom Rhodesto create a filesystem on the new partition.
4772c80d96eSTom RhodesA typical partitioning scheme would be to have an
478726b61abSRuslan Ermilov.Dq a
479726b61abSRuslan Ermilovpartition
480726b61abSRuslan Ermilovof approximately 128MB to hold the root filesystem, a
481726b61abSRuslan Ermilov.Dq b
482726b61abSRuslan Ermilovpartition for
483726b61abSRuslan Ermilovswap, a
484726b61abSRuslan Ermilov.Dq d
485726b61abSRuslan Ermilovpartition for /var (usually 128MB), an
486726b61abSRuslan Ermilov.Dq e
487726b61abSRuslan Ermilovpartition
488726b61abSRuslan Ermilovfor /var/tmp (usually 128MB), an
489726b61abSRuslan Ermilov.Dq f
490726b61abSRuslan Ermilovpartition for /usr (usually around 2G),
491726b61abSRuslan Ermilovand finally a
492726b61abSRuslan Ermilov.Dq g
493b60884cdSBen Smithurstpartition for /home (usually all remaining space).
494ff7d5162SJordan K. HubbardYour mileage may vary.
495ff7d5162SJordan K. Hubbard.El
496ff7d5162SJordan K. Hubbard.Pp
4977c7fb079SRuslan Ermilov.Nm fdisk Fl BI Ar da0
498ff7d5162SJordan K. Hubbard.Pp
4997c7fb079SRuslan Ermilov.Nm
500ff7d5162SJordan K. Hubbard.Fl w
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
516e1205e80SPhilippe CharnierThe
5174cbdc634SGreg Lehey.Nm
518e1205e80SPhilippe Charnierutility
5194cbdc634SGreg Leheyuses an ASCII version of the label when examining, editing or restoring a disk
5204cbdc634SGreg Leheylabel.  The format is:
5214cbdc634SGreg Lehey.Bd -literal -offset 4n
52207b0cf9aSDavid E. O'Brien# /dev/da1c:
5234cbdc634SGreg Leheytype: SCSI
52407b0cf9aSDavid E. O'Briendisk: da0s1
5254cbdc634SGreg Leheylabel:
5264cbdc634SGreg Leheyflags:
5274cbdc634SGreg Leheybytes/sector: 512
5284cbdc634SGreg Leheysectors/track: 51
5294cbdc634SGreg Leheytracks/cylinder: 19
5304cbdc634SGreg Leheysectors/cylinder: 969
5314cbdc634SGreg Leheycylinders: 1211
5324cbdc634SGreg Leheysectors/unit: 1173930
5334cbdc634SGreg Leheyrpm: 3600
5344cbdc634SGreg Leheyinterleave: 1
5354cbdc634SGreg Leheytrackskew: 0
5364cbdc634SGreg Leheycylinderskew: 0
5374cbdc634SGreg Leheyheadswitch: 0           # milliseconds
5384cbdc634SGreg Leheytrack-to-track seek: 0  # milliseconds
5394cbdc634SGreg Leheydrivedata: 0
5404cbdc634SGreg Lehey
5414cbdc634SGreg Lehey8 partitions:
5424cbdc634SGreg Lehey#        size   offset    fstype   [fsize bsize bps/cpg]
5434cbdc634SGreg Lehey  a:    81920        0    4.2BSD     1024  8192    16   # (Cyl.    0 - 84*)
5444cbdc634SGreg Lehey  b:   160000    81920      swap                        # (Cyl.   84* - 218*)
5454cbdc634SGreg Lehey  c:  1173930        0    unused        0     0         # (Cyl.    0 - 1211*)
5464cbdc634SGreg Lehey  h:   962010   211920     vinum                        # (Cyl.  218*- 1211*)
5474cbdc634SGreg Lehey.Ed
5484cbdc634SGreg Lehey.Pp
5494cbdc634SGreg LeheyLines starting with a # mark are comments.  Most of the other specifications are
5504cbdc634SGreg Leheyno longer used.  The ones which must still be set correctly are:
5514cbdc634SGreg Lehey.Pp
5524cbdc634SGreg Lehey.Bl -hang -width 20n
5534cbdc634SGreg Lehey.It Nm label
5544cbdc634SGreg Leheyis an optional label, set by the
5554cbdc634SGreg Lehey.Ar packid
5564cbdc634SGreg Leheyoption when writing a label.
5574cbdc634SGreg Lehey.It Nm flags
5584cbdc634SGreg LeheyFlags may be
5594cbdc634SGreg Lehey.Ar removable ,
5604cbdc634SGreg Lehey.Ar ecc
5614cbdc634SGreg Leheyor
5624cbdc634SGreg Lehey.Ar badsect .
5634cbdc634SGreg Lehey.Ar removable
564b5c508fbSRuslan Ermilovis set for removable media drives, but no current
565b5c508fbSRuslan Ermilov.Fx
566b5c508fbSRuslan Ermilovdriver evaluates this
5674cbdc634SGreg Leheyflag.
5684cbdc634SGreg Lehey.Ar ecc
5694cbdc634SGreg Leheyis no longer supported;
5704cbdc634SGreg Lehey.Ar badsect
5714cbdc634SGreg Leheyspecifies that the drive can perform bad sector remapping.
5724cbdc634SGreg Lehey.It Nm sectors/unit
5734cbdc634SGreg Leheydescribes the total size of the disk.  This value must be correct.
5744cbdc634SGreg Lehey.It Nm the partition table
5757733674eSRuslan ErmilovThis is the
5767733674eSRuslan Ermilov.Ux
5777733674eSRuslan Ermilovpartition table, not the Microsoft partition table described in
5784cbdc634SGreg Lehey.Xr fdisk 8 .
5794cbdc634SGreg Lehey.El
5804cbdc634SGreg Lehey.Pp
5814cbdc634SGreg LeheyThe partition table can have up to 8 entries.  It contains the following
5824cbdc634SGreg Leheyinformation:
5834cbdc634SGreg Lehey.Bl -hang -width 10n
5844cbdc634SGreg Lehey.It identifier
5854cbdc634SGreg LeheyThe partition identifier is a single letter in the range
5867733674eSRuslan Ermilov.Dq a
5874cbdc634SGreg Leheyto
5887733674eSRuslan Ermilov.Dq h .
5894cbdc634SGreg LeheyBy convention, partition
5907733674eSRuslan Ermilov.Dq c
5914cbdc634SGreg Leheyis reserved to describe the entire disk.
5924cbdc634SGreg Lehey.It size
5933233afaeSJohn W. De Boskeyis the size of the partition in sectors,
5947733674eSRuslan Ermilov.Cm K
5953233afaeSJohn W. De Boskey(kilobytes - 1024),
5967733674eSRuslan Ermilov.Cm M
5973233afaeSJohn W. De Boskey(megabytes - 1024*1024),
5987733674eSRuslan Ermilov.Cm G
5993233afaeSJohn W. De Boskey(gigabytes - 1024*1024*1024),
6007733674eSRuslan Ermilov.Cm %
6013233afaeSJohn W. De Boskey(percentage of free space AFTER removing any fixed-size partitions other
6023233afaeSJohn W. De Boskeythan partition
6037733674eSRuslan Ermilov.Dq c) ,
6047733674eSRuslan Ermilovor
6057733674eSRuslan Ermilov.Cm *
6067733674eSRuslan Ermilov(all remaining free space AFTER fixed-size and percentage
6073233afaeSJohn W. De Boskeypartitions).  For partition
6087733674eSRuslan Ermilov.Dq c ,
6097733674eSRuslan Ermilova size of
6107733674eSRuslan Ermilov.Cm *
6117733674eSRuslan Ermilovindicates the entire disk.  Lowercase versions of
6127733674eSRuslan Ermilov.Cm K , M ,
6137733674eSRuslan Ermilovand
6147733674eSRuslan Ermilov.Cm G
6153233afaeSJohn W. De Boskeyare allowed.
6163233afaeSJohn W. De BoskeySize and type should be specifed without any spaces between them.
6173233afaeSJohn W. De Boskey.Pp
6183233afaeSJohn W. De BoskeyExample: 2097152, 1g, 1024m and 1048576k are all the same size
6193233afaeSJohn W. De Boskey(assuming 512-byte sectors).
6204cbdc634SGreg Lehey.It offset
6213233afaeSJohn W. De Boskeyis the offset of the start of the partition from the beginning of the
6227733674eSRuslan Ermilovdrive in sectors, or
6237733674eSRuslan Ermilov.Cm *
6247733674eSRuslan Ermilovto have
6253233afaeSJohn W. De Boskey.Nm
6263233afaeSJohn W. De Boskeycalculate the correct offset to use (the end of the previous partition plus
6273233afaeSJohn W. De Boskeyone, ignoring partition
6287733674eSRuslan Ermilov.Dq c .
6293233afaeSJohn W. De BoskeyFor partition
6307733674eSRuslan Ermilov.Dq c ,
6317733674eSRuslan Ermilov.Cm *
6327733674eSRuslan Ermilovwill be interpreted as an offset of 0.
6334cbdc634SGreg Lehey.It fstype
63470e48365SGreg Leheydescribes the purpose of the partition.  The example shows all currently used
63570e48365SGreg Leheypartition types.
63670e48365SGreg LeheyFor UFS filesystems and ccd partitions, use type
6377733674eSRuslan Ermilov.Cm 4.2BSD .
63870e48365SGreg LeheyFor Vinum drives, use type
63970e48365SGreg Lehey.Cm vinum .
6403233afaeSJohn W. De BoskeyOther common types are
6417733674eSRuslan Ermilov.Cm unused
6423233afaeSJohn W. De Boskeyand
6437733674eSRuslan Ermilov.Cm swap .
6442f1aba69SRuslan ErmilovBy convention, partition
6452f1aba69SRuslan Ermilov.Dq c
6462f1aba69SRuslan Ermilovrepresents the entire slice and should be of type
64770e48365SGreg Lehey.Cm unused ,
64870e48365SGreg Leheythough
64970e48365SGreg Lehey.Nm
65070e48365SGreg Leheydoes not enforce this convention.
651e1205e80SPhilippe CharnierThe
65270e48365SGreg Lehey.Nm
653e1205e80SPhilippe Charnierutility
65470e48365SGreg Leheyalso knows about a number of other partition types, none of which are in current
65570e48365SGreg Leheyuse.
65670e48365SGreg LeheySee the definitions starting with
6572f1aba69SRuslan Ermilov.Dv FS_UNUSED
6582f1aba69SRuslan Ermilovin
6594cbdc634SGreg Lehey.Pa /usr/include/sys/disklabel.h
66070e48365SGreg Leheyfor more details.
6614cbdc634SGreg Lehey.It fsize
6623233afaeSJohn W. De BoskeyFor
6637733674eSRuslan Ermilov.Cm 4.2BSD
664857dcea0SRuslan Ermilovand LFS filesystems only, the fragment size.  Defaults to 1024 for
665857dcea0SRuslan Ermilovpartitions smaller than 1 GB, 4096 for partitions 1GB or larger.
6664cbdc634SGreg Lehey.It bsize
6673233afaeSJohn W. De BoskeyFor
6687733674eSRuslan Ermilov.Cm 4.2BSD
669857dcea0SRuslan Ermilovand LFS filesystems only, the block size.  Defaults to 8192 for
670857dcea0SRuslan Ermilovpartitions smaller than 1 GB, 16384 for partitions 1GB or larger.
6714cbdc634SGreg Lehey.It bps/cpg
6723233afaeSJohn W. De BoskeyFor
6737733674eSRuslan Ermilov.Cm 4.2BSD
6743233afaeSJohn W. De Boskeyfilesystems, the number of cylinders in a cylinder group.  For LFS file
6753233afaeSJohn W. De Boskeysystems, the segment shift value.  Defaults to 16 for
6763233afaeSJohn W. De Boskeypartitions smaller than 1 GB, 64 for partitions 1GB or larger.
6774cbdc634SGreg Lehey.El
678b60884cdSBen Smithurst.Pp
6794cbdc634SGreg LeheyThe remainder of the line is a comment and shows the cylinder allocations based
6804cbdc634SGreg Leheyon the obsolete (but possibly correct) geometry information about the drive.
6814cbdc634SGreg LeheyThe asterisk (*) indicates that the partition does not begin or end exactly on a
6824cbdc634SGreg Leheycylinder boundary.
6838fae3551SRodney W. Grimes.Sh EXAMPLES
6849f9930a2SRobert Nordier.Dl disklabel da0
6858fae3551SRodney W. Grimes.Pp
6864cbdc634SGreg LeheyDisplay the in-core label for
687ff7d5162SJordan K. Hubbard.Pa da0s1
6884cbdc634SGreg Leheyas obtained via
689ff7d5162SJordan K. Hubbard.Pa /dev/da0s1 .
690b5c508fbSRuslan ErmilovWhen reading a label,
691b5c508fbSRuslan Ermilov.Fx
692b5c508fbSRuslan Ermilovwill allow you to specify the base disk name
693ff7d5162SJordan K. Hubbardeven if the label resides on a slice.  However, to be proper you should
694726b61abSRuslan Ermilovspecify the base disk name only if you are using a
695726b61abSRuslan Ermilov.Dq dangerously-dedicated
696ff7d5162SJordan K. Hubbardlabel.  Normally you specify the slice.
6978fae3551SRodney W. Grimes.Pp
698ff7d5162SJordan K. Hubbard.Dl disklabel da0s1 > savedlabel
6994cbdc634SGreg Lehey.Pp
7004cbdc634SGreg LeheySave the in-core label for
701ff7d5162SJordan K. Hubbard.Pa da0s1
7024cbdc634SGreg Leheyinto the file
7034cbdc634SGreg Lehey.Pa savedlabel .
7044cbdc634SGreg LeheyThis file can be used with the
7054cbdc634SGreg Lehey.Fl R
7064cbdc634SGreg Leheyflag to restore the label at a later date.
7074cbdc634SGreg Lehey.Pp
708ff7d5162SJordan K. Hubbard.Dl disklabel -w -r /dev/da0s1 da2212 foo
7098fae3551SRodney W. Grimes.Pp
7104cbdc634SGreg LeheyCreate a label for
711ff7d5162SJordan K. Hubbard.Pa da0s1
7124cbdc634SGreg Leheybased on information for
713726b61abSRuslan Ermilov.Dq da2212
714726b61abSRuslan Ermilovfound in
7158fae3551SRodney W. Grimes.Pa /etc/disktab .
7168fae3551SRodney W. GrimesAny existing bootstrap code will be clobbered.
7178fae3551SRodney W. Grimes.Pp
718ff7d5162SJordan K. Hubbard.Dl disklabel -e -r da0s1
7198fae3551SRodney W. Grimes.Pp
7204cbdc634SGreg LeheyRead the on-disk label for
721ff7d5162SJordan K. Hubbard.Pa da0s1 ,
7224cbdc634SGreg Leheyedit it and reinstall in-core as well as on-disk.  Existing bootstrap code is
7234cbdc634SGreg Leheyunaffected.
7248fae3551SRodney W. Grimes.Pp
7253233afaeSJohn W. De Boskey.Dl disklabel -e -r -n da0s1
7263233afaeSJohn W. De Boskey.Pp
7273233afaeSJohn W. De BoskeyRead the on-disk label for
7283233afaeSJohn W. De Boskey.Pa da0s1 ,
7293233afaeSJohn W. De Boskeyedit it, and display what the new label would be (in sectors).  It does
7303233afaeSJohn W. De BoskeyNOT install the new label either in-core or on-disk.
7313233afaeSJohn W. De Boskey.Pp
732ff7d5162SJordan K. Hubbard.Dl disklabel -r -w da0s1 auto
733425bed3aSJoerg Wunsch.Pp
7344cbdc634SGreg LeheyTry to auto-detect the required information from
735ff7d5162SJordan K. Hubbard.Pa da0s1 ,
7364cbdc634SGreg Leheyand write a new label to the disk.  Use another disklabel -e command to edit the
737425bed3aSJoerg Wunschpartitioning and filesystem information.
738425bed3aSJoerg Wunsch.Pp
739ff7d5162SJordan K. Hubbard.Dl disklabel -R da0s1 savedlabel
7408fae3551SRodney W. Grimes.Pp
7414cbdc634SGreg LeheyRestore the on-disk and in-core label for
742ff7d5162SJordan K. Hubbard.Pa da0s1
7434cbdc634SGreg Leheyfrom information in
7444cbdc634SGreg Lehey.Pa savedlabel .
7458fae3551SRodney W. GrimesExisting bootstrap code is unaffected.
7468fae3551SRodney W. Grimes.Pp
7473233afaeSJohn W. De Boskey.Dl disklabel -R -n da0s1 label_layout
7483233afaeSJohn W. De Boskey.Pp
7493233afaeSJohn W. De BoskeyDisplay what the label would be for
7503233afaeSJohn W. De Boskey.Pa da0s1
7513233afaeSJohn W. De Boskeyusing the partition layout in
7523233afaeSJohn W. De Boskey.Pa label_layout .
7533233afaeSJohn W. De BoskeyThis is useful for determining how much space would be alloted for various
7547733674eSRuslan Ermilovpartitions with a labelling scheme using
7557733674eSRuslan Ermilov.Cm % Ns -based
7567733674eSRuslan Ermilovor
7577733674eSRuslan Ermilov.Cm *
7587733674eSRuslan Ermilovpartition sizes.
7593233afaeSJohn W. De Boskey.Pp
760ff7d5162SJordan K. Hubbard.Dl disklabel -B da0s1
7618fae3551SRodney W. Grimes.Pp
7624cbdc634SGreg LeheyInstall a new bootstrap on
763ff7d5162SJordan K. Hubbard.Pa da0s1 .
7648fae3551SRodney W. GrimesThe boot code comes from
765efba76d7SJordan K. Hubbard.Pa /boot/boot1
7668fae3551SRodney W. Grimesand possibly
767efba76d7SJordan K. Hubbard.Pa /boot/boot2 .
7688fae3551SRodney W. GrimesOn-disk and in-core labels are unchanged.
7698fae3551SRodney W. Grimes.Pp
7702c80d96eSTom Rhodes.Dl disklabel -w -B /dev/da0s1 -b newboot1 -s newboot2 da2212
7718fae3551SRodney W. Grimes.Pp
7728fae3551SRodney W. GrimesInstall a new label and bootstrap.
773726b61abSRuslan ErmilovThe label is derived from disktab information for
774726b61abSRuslan Ermilov.Dq da2212
775726b61abSRuslan Ermilovand installed both in-core and on-disk.
7764cbdc634SGreg LeheyThe bootstrap code comes from the files
7774cbdc634SGreg Lehey.Pa /boot/newboot1
7784cbdc634SGreg Leheyand
7794cbdc634SGreg Lehey.Pa /boot/newboot2 .
780ff7d5162SJordan K. Hubbard.Pp
781ff7d5162SJordan K. Hubbard.Dl dd if=/dev/zero of=/dev/da0 bs=512 count=32
782ff7d5162SJordan K. Hubbard.Dl fdisk -BI da0
783ff7d5162SJordan K. Hubbard.Dl dd if=/dev/zero of=/dev/da0s1 bs=512 count=32
78466866007SRuslan Ermilov.Dl disklabel -w -B da0s1 auto
785ff7d5162SJordan K. Hubbard.Dl disklabel -e da0s1
786ff7d5162SJordan K. Hubbard.Pp
787ff7d5162SJordan K. HubbardCompletely wipe any prior information on the disk, creating a new bootable
788726b61abSRuslan Ermilovdisk with a DOS partition table containing one
789726b61abSRuslan Ermilov.Dq whole-disk
790726b61abSRuslan Ermilovslice.  Then
791ff7d5162SJordan K. Hubbardinitialize the slice, then edit it to your needs.  The
792ff7d5162SJordan K. Hubbard.Pa dd
793ff7d5162SJordan K. Hubbardcommands are optional, but may be necessary for some BIOSes to properly
794ff7d5162SJordan K. Hubbardrecognize the disk.
7953233afaeSJohn W. De Boskey.Pp
7963233afaeSJohn W. De BoskeyThis is an example disklabel that uses some of the new partition size types
7977733674eSRuslan Ermilovsuch as
7987733674eSRuslan Ermilov.Cm % , M , G ,
7997733674eSRuslan Ermilovand
8007733674eSRuslan Ermilov.Cm * ,
8017733674eSRuslan Ermilovwhich could be used as a source file for
8023233afaeSJohn W. De Boskey.Pp
8033233afaeSJohn W. De Boskey.Dl disklabel -R ad0s1c new_label_file
8043233afaeSJohn W. De Boskey.Bd -literal -offset 4n
8053233afaeSJohn W. De Boskey# /dev/ad0s1c:
8063233afaeSJohn W. De Boskeytype: ESDI
8073233afaeSJohn W. De Boskeydisk: ad0s1
8083233afaeSJohn W. De Boskeylabel:
8093233afaeSJohn W. De Boskeyflags:
8103233afaeSJohn W. De Boskeybytes/sector: 512
8113233afaeSJohn W. De Boskeysectors/track: 63
8123233afaeSJohn W. De Boskeytracks/cylinder: 16
8133233afaeSJohn W. De Boskeysectors/cylinder: 1008
8143233afaeSJohn W. De Boskeycylinders: 40633
8153233afaeSJohn W. De Boskeysectors/unit: 40959009
8163233afaeSJohn W. De Boskeyrpm: 3600
8173233afaeSJohn W. De Boskeyinterleave: 1
8183233afaeSJohn W. De Boskeytrackskew: 0
8193233afaeSJohn W. De Boskeycylinderskew: 0
8203233afaeSJohn W. De Boskeyheadswitch: 0		# milliseconds
8213233afaeSJohn W. De Boskeytrack-to-track seek: 0	# milliseconds
8223233afaeSJohn W. De Boskeydrivedata: 0
8233233afaeSJohn W. De Boskey
8243233afaeSJohn W. De Boskey8 partitions:
8253233afaeSJohn W. De Boskey#        size   offset    fstype   [fsize bsize bps/cpg]
8263233afaeSJohn W. De Boskey  a:   400M        0    4.2BSD     4096 16384    75 	# (Cyl.    0 - 812*)
8273233afaeSJohn W. De Boskey  b:     1G        *      swap
8283233afaeSJohn W. De Boskey  c:      *        *    unused
8293233afaeSJohn W. De Boskey  e: 204800        *    4.2BSD
8303233afaeSJohn W. De Boskey  f:     5g        *    4.2BSD
8313233afaeSJohn W. De Boskey  g:      *        *    4.2BSD
8323233afaeSJohn W. De Boskey.Ed
8338fae3551SRodney W. Grimes.Sh SEE ALSO
83470e48365SGreg Lehey.Xr ccd 4 ,
835af202156SWolfram Schneider.Xr disklabel 5 ,
8364cbdc634SGreg Lehey.Xr disktab 5 ,
837aa7c9adaSMike Pritchard.Xr boot0cfg 8 ,
83870e48365SGreg Lehey.Xr fdisk 8 ,
83970e48365SGreg Lehey.Xr vinum 8
8408fae3551SRodney W. Grimes.Sh DIAGNOSTICS
8418fae3551SRodney W. GrimesThe kernel device drivers will not allow the size of a disk partition
8428fae3551SRodney W. Grimesto be decreased or the offset of a partition to be changed while it is open.
8438fae3551SRodney W. GrimesSome device drivers create a label containing only a single large partition
8444cbdc634SGreg Leheyif a disk is unlabeled; thus, the label must be written to the
845726b61abSRuslan Ermilov.Dq a
8464cbdc634SGreg Leheypartition of the disk while it is open.  This sometimes requires the desired
8474cbdc634SGreg Leheylabel to be set in two steps, the first one creating at least one other
8484cbdc634SGreg Leheypartition, and the second setting the label on the new partition while shrinking
8494cbdc634SGreg Leheythe
850726b61abSRuslan Ermilov.Dq a
8514cbdc634SGreg Leheypartition.
8528fae3551SRodney W. Grimes.Pp
8538fae3551SRodney W. GrimesOn some machines the bootstrap code may not fit entirely in the area
8548fae3551SRodney W. Grimesallocated for it by some filesystems.
8558fae3551SRodney W. GrimesAs a result, it may not be possible to have filesystems on some partitions
856726b61abSRuslan Ermilovof a
857726b61abSRuslan Ermilov.Dq bootable
858726b61abSRuslan Ermilovdisk.
8598fae3551SRodney W. GrimesWhen installing bootstrap code,
8606bd343a9SPhilippe Charnier.Nm
8618fae3551SRodney W. Grimeschecks for these cases.
8628fae3551SRodney W. GrimesIf the installed boot code would overlap a partition of type FS_UNUSED
8638fae3551SRodney W. Grimesit is marked as type FS_BOOT.
8648fae3551SRodney W. GrimesThe
8658fae3551SRodney W. Grimes.Xr newfs 8
8668fae3551SRodney W. Grimesutility will disallow creation of filesystems on FS_BOOT partitions.
8678fae3551SRodney W. GrimesConversely, if a partition has a type other than FS_UNUSED or FS_BOOT,
8686bd343a9SPhilippe Charnier.Nm
8698fae3551SRodney W. Grimeswill not install bootstrap code that overlaps it.
8708fae3551SRodney W. Grimes.Sh BUGS
8718fae3551SRodney W. GrimesWhen a disk name is given without a full pathname,
872726b61abSRuslan Ermilovthe constructed device name uses the
873726b61abSRuslan Ermilov.Dq c
874726b61abSRuslan Ermilovpartition.
875d70e4e53SJoerg Wunsch.Pp
876d70e4e53SJoerg WunschFor the i386 architecture, the primary bootstrap sector contains
877d70e4e53SJoerg Wunschan embedded
878d70e4e53SJoerg Wunsch.Em fdisk
879d70e4e53SJoerg Wunschtable.
880e1205e80SPhilippe CharnierThe
881e1205e80SPhilippe Charnier.Nm
882e1205e80SPhilippe Charnierutility takes care to not clobber it when installing a bootstrap only
883d70e4e53SJoerg Wunsch.Pq Fl B ,
884d70e4e53SJoerg Wunschor when editing an existing label
885d70e4e53SJoerg Wunsch.Pq Fl e ,
886d70e4e53SJoerg Wunschbut it unconditionally writes the primary bootstrap program onto
887d70e4e53SJoerg Wunschthe disk for
888d70e4e53SJoerg Wunsch.Fl w
889d70e4e53SJoerg Wunschor
890d70e4e53SJoerg Wunsch.Fl R ,
891d70e4e53SJoerg Wunschthus replacing the
892d70e4e53SJoerg Wunsch.Em fdisk
893d70e4e53SJoerg Wunschtable by the dummy one in the bootstrap program.  This is only of
894753d686dSRuslan Ermilovconcern if the disk is fully dedicated, so that the
895753d686dSRuslan Ermilov.Bx
896753d686dSRuslan Ermilovdisklabel
897d70e4e53SJoerg Wunschstarts at absolute block 0 on the disk.
8984cbdc634SGreg Lehey.Pp
899e1205e80SPhilippe CharnierThe
9004cbdc634SGreg Lehey.Nm
901e1205e80SPhilippe Charnierutility
9023233afaeSJohn W. De Boskeydoes not perform all possible error checking.  Warning *is* given if partitions
9037733674eSRuslan Ermilovoverlap; if an absolute offset does not match the expected offset; if the
9047733674eSRuslan Ermilov.Dq c
9057733674eSRuslan Ermilovpartition does not start at 0 or does not cover the entire slice; if a
9063233afaeSJohn W. De Boskeypartition runs past the end of the device; and a number of other errors; but
9073233afaeSJohn W. De Boskeyno warning is given if space remains unused.
908