xref: /freebsd/sbin/bsdlabel/bsdlabel.8 (revision 7c7fb079b997666ef8dc3a60352aa3d2052cb3de)
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
404cbdc634SGreg Lehey.Os FreeBSD
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
51ff7d5162SJordan K. Hubbard.Ar disk Ar disktype/auto
528fae3551SRodney W. Grimes.Oo Ar packid Oc
537c7fb079SRuslan Ermilov.Nm
548fae3551SRodney W. Grimes.Fl e
558fae3551SRodney W. Grimes.Op Fl r
568fae3551SRodney W. Grimes.Ar disk
577c7fb079SRuslan Ermilov.Nm
588fae3551SRodney W. Grimes.Fl R
598fae3551SRodney W. Grimes.Op Fl r
608fae3551SRodney W. Grimes.Ar disk Ar protofile
617c7fb079SRuslan Ermilov.Nm
628fae3551SRodney W. Grimes.Op Fl NW
638fae3551SRodney W. Grimes.Ar disk
64726b61abSRuslan Ermilov.Pp
657c7fb079SRuslan Ermilov.Nm
668fae3551SRodney W. Grimes.Fl B
678fae3551SRodney W. Grimes.Oo
688fae3551SRodney W. Grimes.Fl b Ar boot1
694cbdc634SGreg Lehey.Fl s Ar boot2
708fae3551SRodney W. Grimes.Oc
718fae3551SRodney W. Grimes.Ar disk
72ff7d5162SJordan K. Hubbard.Oo Ar disktype/auto Oc
737c7fb079SRuslan Ermilov.Nm
748fae3551SRodney W. Grimes.Fl w
758fae3551SRodney W. Grimes.Fl B
768fae3551SRodney W. Grimes.Oo
778fae3551SRodney W. Grimes.Fl b Ar boot1
784cbdc634SGreg Lehey.Fl s Ar boot2
798fae3551SRodney W. Grimes.Oc
80ff7d5162SJordan K. Hubbard.Ar disk Ar disktype/auto
818fae3551SRodney W. Grimes.Oo Ar packid Oc
827c7fb079SRuslan Ermilov.Nm
838fae3551SRodney W. Grimes.Fl R
848fae3551SRodney W. Grimes.Fl B
858fae3551SRodney W. Grimes.Oo
868fae3551SRodney W. Grimes.Fl b Ar boot1
874cbdc634SGreg Lehey.Fl s Ar boot2
888fae3551SRodney W. Grimes.Oc
898fae3551SRodney W. Grimes.Ar disk Ar protofile
90ff7d5162SJordan K. Hubbard.Oo Ar disktype/auto Oc
918fae3551SRodney W. Grimes.Sh DESCRIPTION
928fae3551SRodney W. Grimes.Nm Disklabel
934cbdc634SGreg Leheyinstalls, examines or modifes the label on a disk drive or pack.  When writing
944cbdc634SGreg Leheythe label, it can be used to change the drive identification, the disk
954cbdc634SGreg Leheypartitions on the drive, or to replace a damaged label.  There are several forms
964cbdc634SGreg Leheyof the command that read (display), install or edit the label on a disk.  In
974cbdc634SGreg Leheyaddition,
986bd343a9SPhilippe Charnier.Nm
994cbdc634SGreg Leheycan install bootstrap code.
1004cbdc634SGreg Lehey.Ss Raw or in-core label
1014cbdc634SGreg Lehey.Pp
1024cbdc634SGreg LeheyThe disk label is resident close to or at the beginning of each disk partition.
1034cbdc634SGreg LeheyFor faster access, the kernel maintains a copy in core at all times.  By
1044cbdc634SGreg Leheydefault, most
1054cbdc634SGreg Lehey.Nm
1064cbdc634SGreg Leheyaccess the in-core copy of the label.  To access the raw (on-disk) copy, use the
1074cbdc634SGreg Lehey.Fl r
1084cbdc634SGreg Leheyoption.  This option allows a label to be installed on a disk without kernel
1094cbdc634SGreg Leheysupport for a label, such as when labels are first installed on a system; it
1104cbdc634SGreg Leheymust be used when first installing a label on a disk.  The specific effect of
1118fae3551SRodney W. Grimes.Fl r
1128fae3551SRodney W. Grimesis described under each command.
1138fae3551SRodney W. Grimes.Pp
1144cbdc634SGreg Lehey.Ss Disk device name
1154cbdc634SGreg Lehey.Pp
1164cbdc634SGreg LeheyAll
1177c7fb079SRuslan Ermilov.Nm
1184cbdc634SGreg Leheyforms require a disk device name, which should always be the raw
119ff7d5162SJordan K. Hubbarddevice name representing the disk or slice.  For example
120ff7d5162SJordan K. Hubbard.Pa da0
121ff7d5162SJordan K. Hubbardrepresents the entire disk irregardless of any DOS partitioning,
122ff7d5162SJordan K. Hubbardand
123ff7d5162SJordan K. Hubbard.Pa da0s1
124ff7d5162SJordan K. Hubbardrepresents a slice.  Some devices, most notably
125ff7d5162SJordan K. Hubbard.Ar ccd ,
126ff7d5162SJordan K. Hubbardrequire that the
127726b61abSRuslan Ermilov.Dq whole-disk
128726b61abSRuslan Ermilov(or
129726b61abSRuslan Ermilov.Dq c )
130ff7d5162SJordan K. Hubbardpartition be specified.  For example
131ff7d5162SJordan K. Hubbard.Pa ccd0c .
132ff7d5162SJordan K. HubbardYou do not have to include the
133ff7d5162SJordan K. Hubbard.Pa /dev/
134ff7d5162SJordan K. Hubbardpath prefix when specifying the device.
1354cbdc634SGreg Lehey.Nm
136ff7d5162SJordan K. Hubbardwill automatically prepend it.
1374cbdc634SGreg Lehey.Ss Reading the disk label
1384cbdc634SGreg Lehey.Pp
1394cbdc634SGreg LeheyTo examine or save the label on a disk drive, use
1404cbdc634SGreg Lehey.Nm
1414cbdc634SGreg Leheywithout options:
1424cbdc634SGreg Lehey.Pp
1437c7fb079SRuslan Ermilov.Nm
1444cbdc634SGreg Lehey.Op Fl r
1454cbdc634SGreg Lehey.Ar disk
1464cbdc634SGreg Lehey.Pp
1474cbdc634SGreg Lehey.Ar disk
1484cbdc634SGreg Leheyrepresents the raw disk in question, and may be in the form
1494cbdc634SGreg Lehey.Pa da0
1504cbdc634SGreg Leheyor
15107b0cf9aSDavid E. O'Brien.Pa /dev/da0c .
1524cbdc634SGreg LeheyIt will display all of the parameters associated with the drive and its
1534cbdc634SGreg Leheypartition layout.  Unless the
1548fae3551SRodney W. Grimes.Fl r
1558fae3551SRodney W. Grimesflag is given,
1568fae3551SRodney W. Grimesthe kernel's in-core copy of the label is displayed;
1578fae3551SRodney W. Grimesif the disk has no label, or the partition types on the disk are incorrect,
1588fae3551SRodney W. Grimesthe kernel may have constructed or modified the label.
1598fae3551SRodney W. GrimesIf the
1608fae3551SRodney W. Grimes.Fl r
1614cbdc634SGreg Leheyflag is given,
1624cbdc634SGreg Lehey.Nm
163ff7d5162SJordan K. Hubbardreads the label from the raw disk and displays it.  Both versions are usually
164ff7d5162SJordan K. Hubbardidentical except in the case where a label has not yet been initialized or
165ff7d5162SJordan K. Hubbardis corrupt.
1664cbdc634SGreg Lehey.Ss Writing a standard label
1678fae3551SRodney W. Grimes.Pp
1684cbdc634SGreg LeheyTo write a standard label, use the form
1694cbdc634SGreg Lehey.Pp
1707c7fb079SRuslan Ermilov.Nm
1718fae3551SRodney W. Grimes.Fl w
1724cbdc634SGreg Lehey.Op Fl r
173ff7d5162SJordan K. Hubbard.Ar disk Ar disktype/auto
1744cbdc634SGreg Lehey.Oo Ar packid Oc
1754cbdc634SGreg Lehey.Pp
1767c7fb079SRuslan Ermilov.Nm
177ff7d5162SJordan K. Hubbard.Fl w
178ff7d5162SJordan K. Hubbard.Op Fl r
179ff7d5162SJordan K. Hubbard.Ar disk
180ff7d5162SJordan K. Hubbardauto
181ff7d5162SJordan K. Hubbard.Pp
1828fae3551SRodney W. GrimesThe required arguments to
1836bd343a9SPhilippe Charnier.Nm
1844cbdc634SGreg Leheyare the drive to be labeled and the drive type as described in the
1854cbdc634SGreg Lehey.Pa disktab(5)
1864cbdc634SGreg Leheyfile.  The drive parameters and partitions are taken from that file.  If
1874cbdc634SGreg Leheydifferent disks of the same physical type are to have different partitions, it
1884cbdc634SGreg Leheywill be necessary to have separate disktab entries describing each, or to edit
1894cbdc634SGreg Leheythe label after installation as described below.  The optional argument is a
1904cbdc634SGreg Leheypack identification string, up to 16 characters long.  The pack id must be
1914cbdc634SGreg Leheyquoted if it contains blanks.  If the
1928fae3551SRodney W. Grimes.Fl r
1938fae3551SRodney W. Grimesflag is given, the disk sectors containing the label and bootstrap
1948fae3551SRodney W. Grimeswill be written directly.
1958fae3551SRodney W. GrimesA side-effect of this is that any existing bootstrap code will be overwritten
1964cbdc634SGreg Leheyand the disk rendered unbootable.  See the boot options below for a method of
1974cbdc634SGreg Leheywriting the label and the bootstrap at the same time.
1988fae3551SRodney W. GrimesIf
1998fae3551SRodney W. Grimes.Fl r
2008fae3551SRodney W. Grimesis not specified,
2018fae3551SRodney W. Grimesthe existing label will be updated via the in-core copy and any bootstrap
2028fae3551SRodney W. Grimescode will be unaffected.
2038fae3551SRodney W. GrimesIf the disk does not already have a label, the
2048fae3551SRodney W. Grimes.Fl r
2058fae3551SRodney W. Grimesflag must be used.
2068fae3551SRodney W. GrimesIn either case, the kernel's in-core label is replaced.
2078fae3551SRodney W. Grimes.Pp
208425bed3aSJoerg WunschFor a virgin disk that is not known to
209425bed3aSJoerg Wunsch.Xr disktab 5 ,
210425bed3aSJoerg Wunsch.Ar disktype
211425bed3aSJoerg Wunschcan be specified as
212425bed3aSJoerg Wunsch.Dq auto .
213425bed3aSJoerg WunschIn this case, the driver is requested to produce a virgin label for the
214425bed3aSJoerg Wunschdisk.  This might or might not be successful, depending on whether the
215425bed3aSJoerg Wunschdriver for the disk is able to get the required data without reading
216425bed3aSJoerg Wunschanything from the disk at all.  It will likely succeed for all SCSI
217425bed3aSJoerg Wunschdisks, most IDE disks, and vnode devices.  Writing a label to the
218425bed3aSJoerg Wunschdisk is the only supported operation, and the
219425bed3aSJoerg Wunsch.Ar disk
220425bed3aSJoerg Wunschitself must be provided as the canonical name, i.e. not as a full
221425bed3aSJoerg Wunschpath name.
222ff7d5162SJordan K. Hubbard.Pp
223ff7d5162SJordan K. HubbardPC-based systems have special requirements in order for the BIOS to properly
224b5c508fbSRuslan Ermilovrecognize a
225b5c508fbSRuslan Ermilov.Fx
226b5c508fbSRuslan Ermilovdisklabel.  Older systems may require what is known as a
227726b61abSRuslan Ermilov.Dq dangerously dedicated
228ff7d5162SJordan K. Hubbarddisklabel, which creates a fake DOS partition to work around problems older
229ff7d5162SJordan K. HubbardBIOSes have with modern disk geometries.  On newer systems you generally want
230ff7d5162SJordan K. Hubbardto create a normal DOS slice using
231ff7d5162SJordan K. Hubbard.Ar fdisk
232b5c508fbSRuslan Ermilovand then create a
233b5c508fbSRuslan Ermilov.Fx
234b5c508fbSRuslan Ermilovdisklabel within that slice.  This is described
235ff7d5162SJordan K. Hubbardlater on in this page.
236ff7d5162SJordan K. Hubbard.Pp
237ff7d5162SJordan K. HubbardInstalling a new disklabel does not in of itself allow your system to boot
238ff7d5162SJordan K. Hubbarda kernel using that label.  You must also install boot blocks, which is
239ff7d5162SJordan K. Hubbarddescribed later on in this manual page.
2404cbdc634SGreg Lehey.Ss Editing an existing disk label
241425bed3aSJoerg Wunsch.Pp
2424cbdc634SGreg LeheyTo edit an existing disk label, use the form
2434cbdc634SGreg Lehey.Pp
2447c7fb079SRuslan Ermilov.Nm
2458fae3551SRodney W. Grimes.Fl e
2464cbdc634SGreg Lehey.Op Fl r
2474cbdc634SGreg Lehey.Ar disk
2484cbdc634SGreg Lehey.Pp
2494cbdc634SGreg LeheyThis command reads the label from the in-core kernel copy, or directly from the
2504cbdc634SGreg Leheydisk if the
2518fae3551SRodney W. Grimes.Fl r
2524cbdc634SGreg Leheyflag is also specified.  The label is written to a file in ASCII and then
2534cbdc634SGreg Leheysupplied to an editor for changes.  If no editor is specified in an
2548fae3551SRodney W. Grimes.Ev EDITOR
2558fae3551SRodney W. Grimesenvironment variable,
2568fae3551SRodney W. Grimes.Xr vi 1
2574cbdc634SGreg Leheyis used.  When the editor terminates, the label file is used to rewrite the disk
2584cbdc634SGreg Leheylabel.  Existing bootstrap code is unchanged regardless of whether
2598fae3551SRodney W. Grimes.Fl r
2608fae3551SRodney W. Grimeswas specified.
2614cbdc634SGreg Lehey.Ss Restoring a disk label from a file
2628fae3551SRodney W. Grimes.Pp
2634cbdc634SGreg LeheyTo restore a disk label from a file, use the form
2644cbdc634SGreg Lehey.Pp
2657c7fb079SRuslan Ermilov.Nm
2668fae3551SRodney W. Grimes.Fl R
2674cbdc634SGreg Lehey.Op Fl r
2684cbdc634SGreg Lehey.Ar disk Ar protofile
2698fae3551SRodney W. Grimes.Pp
2706bd343a9SPhilippe Charnier.Nm
2715ef18a82SGreg Leheyis capable of restoring a disk label that was previously saved in a file in ASCII format.
2724cbdc634SGreg LeheyThe prototype file used to create the label should be in the same format as that
2734cbdc634SGreg Leheyproduced when reading or editing a label.  Comments are delimited by
2744cbdc634SGreg Lehey.Ar \&#
2754cbdc634SGreg Leheyand newline.  As when writing a new label, any existing bootstrap code will be
2764cbdc634SGreg Leheyclobbered if
2774cbdc634SGreg Lehey.Fl r
2784cbdc634SGreg Leheyis specified and will be unaffected otherwise.  See the boot options below for a
2794cbdc634SGreg Leheymethod of restoring the label and writing the bootstrap at the same time.
2804cbdc634SGreg Lehey.Ss Enabling and disabling writing to the disk label area
2814cbdc634SGreg Lehey.Pp
2824cbdc634SGreg LeheyBy default, it is not possible to write to the disk label area at the beginning
2834cbdc634SGreg Leheyof a disk.  The disk driver silently ignores any attempt to do so.  If you need
2844cbdc634SGreg Leheyto write to this area (for example, to obliterate the label), use the form
2854cbdc634SGreg Lehey.Pp
2867c7fb079SRuslan Ermilov.Nm
2874cbdc634SGreg Lehey.Op Fl W
2884cbdc634SGreg Lehey.Ar disk
2894cbdc634SGreg Lehey.Pp
2904cbdc634SGreg LeheyTo disallow writing to the label area after previously allowing it, use the
2914cbdc634SGreg Leheycommand
2924cbdc634SGreg Lehey.Pp
2937c7fb079SRuslan Ermilov.Nm
2944cbdc634SGreg Lehey.Op Fl N
2954cbdc634SGreg Lehey.Ar disk
2964cbdc634SGreg Lehey.Ss Installing bootstraps
2978fae3551SRodney W. Grimes.Pp
2988fae3551SRodney W. GrimesThe final three forms of
2996bd343a9SPhilippe Charnier.Nm
300ff7d5162SJordan K. Hubbardare used to install bootstrap code.  If you are creating a
301726b61abSRuslan Ermilov.Dq dangerously-dedicated
302726b61abSRuslan Ermilovpartition for compatibility with older PC systems,
303ff7d5162SJordan K. Hubbardyou generally want to specify the raw disk name such as
304ff7d5162SJordan K. Hubbard.Pa da0.
305ff7d5162SJordan K. HubbardIf you are creating a label within an existing DOS slice, you should specify
306ff7d5162SJordan K. Hubbardthe slice name such as
307ff7d5162SJordan K. Hubbard.Pa da0s1 .
308ff7d5162SJordan K. HubbardMaking a partition bootable can be tricky.  If you are using a normal DOS
309ff7d5162SJordan K. Hubbardslice you typically install (or leave) a standard MBR on the base disk and
310b5c508fbSRuslan Ermilovthen install the
311b5c508fbSRuslan Ermilov.Fx
312b5c508fbSRuslan Ermilovbootblocks in the slice.
3134cbdc634SGreg Lehey.Pp
3147c7fb079SRuslan Ermilov.Nm
3158fae3551SRodney W. Grimes.Fl B
3164cbdc634SGreg Lehey.Oo
3174cbdc634SGreg Lehey.Fl b Ar boot1
3184cbdc634SGreg Lehey.Fl s Ar boot2
3194cbdc634SGreg Lehey.Oc
3204cbdc634SGreg Lehey.Ar disk
3214cbdc634SGreg Lehey.Oo Ar disktype Oc
3224cbdc634SGreg Lehey.Pp
3234cbdc634SGreg LeheyThis form installs the bootstrap only.  It does not change the disk label.
324726b61abSRuslan ErmilovYou should never use this command on a base disk unless you intend to create a
325726b61abSRuslan Ermilov.Dq dangerously-dedicated
326726b61abSRuslan Ermilovdisk, such as
327ff7d5162SJordan K. Hubbard.Ar da0 .
328ff7d5162SJordan K. HubbardThis command is typically run on a slice such as
329ff7d5162SJordan K. Hubbard.Ar da0s1 .
3304cbdc634SGreg Lehey.Pp
3317c7fb079SRuslan Ermilov.Nm
3324cbdc634SGreg Lehey.Fl w
3334cbdc634SGreg Lehey.Fl B
3344cbdc634SGreg Lehey.Oo
3354cbdc634SGreg Lehey.Fl b Ar boot1
3364cbdc634SGreg Lehey.Fl s Ar boot2
3374cbdc634SGreg Lehey.Oc
3384cbdc634SGreg Lehey.Ar disk Ar disktype
3394cbdc634SGreg Lehey.Oo Ar packid Oc
3404cbdc634SGreg Lehey.Pp
341726b61abSRuslan ErmilovThis form corresponds to the
342726b61abSRuslan Ermilov.Dq write label
343726b61abSRuslan Ermilovcommand described above.
3444cbdc634SGreg LeheyIn addition to writing a new volume label, it also installs the bootstrap.
345726b61abSRuslan ErmilovIf run on a base disk this command will create a
346726b61abSRuslan Ermilov.Dq dangerously-dedicated
347ff7d5162SJordan K. Hubbardlabel.  This command is normally run on a slice rather then a base disk.
3484cbdc634SGreg Lehey.Pp
3497c7fb079SRuslan Ermilov.Nm
3504cbdc634SGreg Lehey.Fl R
3514cbdc634SGreg Lehey.Fl B
3524cbdc634SGreg Lehey.Oo
3534cbdc634SGreg Lehey.Fl b Ar boot1
3544cbdc634SGreg Lehey.Fl s Ar boot2
3554cbdc634SGreg Lehey.Oc
3564cbdc634SGreg Lehey.Ar disk Ar protofile
3574cbdc634SGreg Lehey.Oo Ar disktype Oc
3584cbdc634SGreg Lehey.Pp
359726b61abSRuslan ErmilovThis form corresponds to the
360726b61abSRuslan Ermilov.Dq restore label
361726b61abSRuslan Ermilovcommand described above.
3624cbdc634SGreg LeheyIn addition to restoring the volume label, it also installs the bootstrap.
363726b61abSRuslan ErmilovIf run on a base disk this command will create a
364726b61abSRuslan Ermilov.Dq dangerously-dedicated
365ff7d5162SJordan K. Hubbardlabel.  This command is normally run on a slice rather then a base disk.
3664cbdc634SGreg Lehey.Pp
3674cbdc634SGreg LeheyThe bootstrap commands always access the disk directly, so it is not necessary
3684cbdc634SGreg Leheyto specify the
3698fae3551SRodney W. Grimes.Fl r
3704cbdc634SGreg Leheyflag.
3714cbdc634SGreg Lehey.Pp
3724cbdc634SGreg LeheyThe bootstrap code is comprised of two boot programs.  Specify the name of the
3734cbdc634SGreg Leheyboot programs to be installed in one of these ways:
3744cbdc634SGreg Lehey.Bl -enum
3754cbdc634SGreg Lehey.It
3764cbdc634SGreg LeheySpecify the names explicitly with the
3778fae3551SRodney W. Grimes.Fl b
3788fae3551SRodney W. Grimesand
3798fae3551SRodney W. Grimes.Fl s
3808fae3551SRodney W. Grimesflags.
3818fae3551SRodney W. Grimes.Fl b
3828fae3551SRodney W. Grimesindicates the primary boot program and
3838fae3551SRodney W. Grimes.Fl s
3844cbdc634SGreg Leheythe secondary boot program.  The boot programs are located in
385efba76d7SJordan K. Hubbard.Pa /boot .
3864cbdc634SGreg Lehey.It
3874cbdc634SGreg LeheyIf the
3884cbdc634SGreg Lehey.Fl b
3894cbdc634SGreg Leheyand
3904cbdc634SGreg Lehey.Fl s
3914cbdc634SGreg Leheyflags are not specified, but
3928fae3551SRodney W. Grimes.Ar disktype
3934cbdc634SGreg Leheywas specified, the names of the programs are taken from the
394726b61abSRuslan Ermilov.Dq b0
395726b61abSRuslan Ermilovand
396726b61abSRuslan Ermilov.Dq b1
3974cbdc634SGreg Leheyparameters of the
3984cbdc634SGreg Lehey.Xr disktab 5
3994cbdc634SGreg Leheyentry for the disk if the disktab entry exists and includes those parameters.
4004cbdc634SGreg Lehey.It
4014cbdc634SGreg LeheyOtherwise, the default boot image names are used:
402efba76d7SJordan K. Hubbard.Pa /boot/boot1
4038fae3551SRodney W. Grimesand
404efba76d7SJordan K. Hubbard.Pa /boot/boot2
405efba76d7SJordan K. Hubbardfor the standard stage1 and stage2 boot images (details may vary
406efba76d7SJordan K. Hubbardon architectures like the Alpha, where only a single-stage boot is used).
4074cbdc634SGreg Lehey.El
408ff7d5162SJordan K. Hubbard.Ss Initializing/Formatting a bootable disk from scratch
409ff7d5162SJordan K. Hubbard.Pp
410ff7d5162SJordan K. HubbardTo initialize a disk from scratch the following sequence is recommended.
411ff7d5162SJordan K. HubbardPlease note that this will wipe everything that was previously on the disk,
412b5c508fbSRuslan Ermilovincluding any
413b5c508fbSRuslan Ermilov.No non- Ns Fx
414b5c508fbSRuslan Ermilovslices.
415ff7d5162SJordan K. Hubbard.Bl -enum
416ff7d5162SJordan K. Hubbard.It
417ff7d5162SJordan K. HubbardUse
418ff7d5162SJordan K. Hubbard.Ar fdisk
419ff7d5162SJordan K. Hubbardto initialize the DOS partition table, creating a real whole-disk slice to
420b5c508fbSRuslan Ermilovhold the
421b5c508fbSRuslan Ermilov.Fx
422b5c508fbSRuslan Ermilovdisklabel, and installing a master boot record.
423ff7d5162SJordan K. Hubbard.It
424ff7d5162SJordan K. HubbardUse
425ff7d5162SJordan K. Hubbard.Ar disklabel
426b5c508fbSRuslan Ermilovto initialize a virgin
427b5c508fbSRuslan Ermilov.Fx
428b5c508fbSRuslan Ermilovdisklabel and install
429b5c508fbSRuslan Ermilov.Fx
430b5c508fbSRuslan Ermilovboot blocks.
431ff7d5162SJordan K. Hubbard.It
432ff7d5162SJordan K. HubbardUse
433ff7d5162SJordan K. Hubbard.Ar disklabel
434ff7d5162SJordan K. Hubbardto edit your newly created label, addiing appropriate partitions.
435ff7d5162SJordan K. Hubbard.It
436ff7d5162SJordan K. HubbardFinally newfs the filesystem partitions you created in the label.  A typical
437726b61abSRuslan Ermilovdisklabel partiioning scheme would be to have an
438726b61abSRuslan Ermilov.Dq a
439726b61abSRuslan Ermilovpartition
440726b61abSRuslan Ermilovof approximately 128MB to hold the root filesystem, a
441726b61abSRuslan Ermilov.Dq b
442726b61abSRuslan Ermilovpartition for
443726b61abSRuslan Ermilovswap, a
444726b61abSRuslan Ermilov.Dq d
445726b61abSRuslan Ermilovpartition for /var (usually 128MB), an
446726b61abSRuslan Ermilov.Dq e
447726b61abSRuslan Ermilovpartition
448726b61abSRuslan Ermilovfor /var/tmp (usually 128MB), an
449726b61abSRuslan Ermilov.Dq f
450726b61abSRuslan Ermilovpartition for /usr (usually around 2G),
451726b61abSRuslan Ermilovand finally a
452726b61abSRuslan Ermilov.Dq g
453726b61abSRuslan Ermilovpartition for /home (usally all remaining space).
454ff7d5162SJordan K. HubbardYour mileage may vary.
455ff7d5162SJordan K. Hubbard.El
456ff7d5162SJordan K. Hubbard.Pp
4577c7fb079SRuslan Ermilov.Nm fdisk Fl BI Ar da0
458ff7d5162SJordan K. Hubbard.Pp
4597c7fb079SRuslan Ermilov.Nm
460ff7d5162SJordan K. Hubbard.Fl w
461ff7d5162SJordan K. Hubbard.Fl r
462ff7d5162SJordan K. Hubbard.Fl B
463ff7d5162SJordan K. Hubbard.Ar da0s1
464ff7d5162SJordan K. Hubbardauto
465ff7d5162SJordan K. Hubbard.Pp
466ff7d5162SJordan K. Hubbard.Pp
4677c7fb079SRuslan Ermilov.Nm
468ff7d5162SJordan K. Hubbard.Fl e
469ff7d5162SJordan K. Hubbard.Ar da0s1
470ff7d5162SJordan K. Hubbard.Pp
4718fae3551SRodney W. Grimes.Sh FILES
4728fae3551SRodney W. Grimes.Bl -tag -width Pa -compact
4738fae3551SRodney W. Grimes.It Pa /etc/disktab
474efba76d7SJordan K. Hubbard.It Pa /boot/
475efba76d7SJordan K. Hubbard.It Pa /boot/boot<n>
4768fae3551SRodney W. Grimes.El
4774cbdc634SGreg Lehey.Sh SAVED FILE FORMAT
4784cbdc634SGreg Lehey.Nm
4794cbdc634SGreg Leheyuses an ASCII version of the label when examining, editing or restoring a disk
4804cbdc634SGreg Leheylabel.  The format is:
4814cbdc634SGreg Lehey.Bd -literal -offset 4n
48207b0cf9aSDavid E. O'Brien# /dev/da1c:
4834cbdc634SGreg Leheytype: SCSI
48407b0cf9aSDavid E. O'Briendisk: da0s1
4854cbdc634SGreg Leheylabel:
4864cbdc634SGreg Leheyflags:
4874cbdc634SGreg Leheybytes/sector: 512
4884cbdc634SGreg Leheysectors/track: 51
4894cbdc634SGreg Leheytracks/cylinder: 19
4904cbdc634SGreg Leheysectors/cylinder: 969
4914cbdc634SGreg Leheycylinders: 1211
4924cbdc634SGreg Leheysectors/unit: 1173930
4934cbdc634SGreg Leheyrpm: 3600
4944cbdc634SGreg Leheyinterleave: 1
4954cbdc634SGreg Leheytrackskew: 0
4964cbdc634SGreg Leheycylinderskew: 0
4974cbdc634SGreg Leheyheadswitch: 0           # milliseconds
4984cbdc634SGreg Leheytrack-to-track seek: 0  # milliseconds
4994cbdc634SGreg Leheydrivedata: 0
5004cbdc634SGreg Lehey
5014cbdc634SGreg Lehey8 partitions:
5024cbdc634SGreg Lehey#        size   offset    fstype   [fsize bsize bps/cpg]
5034cbdc634SGreg Lehey  a:    81920        0    4.2BSD     1024  8192    16   # (Cyl.    0 - 84*)
5044cbdc634SGreg Lehey  b:   160000    81920      swap                        # (Cyl.   84* - 218*)
5054cbdc634SGreg Lehey  c:  1173930        0    unused        0     0         # (Cyl.    0 - 1211*)
5064cbdc634SGreg Lehey  h:   962010   211920     vinum                        # (Cyl.  218*- 1211*)
5074cbdc634SGreg Lehey.Ed
5084cbdc634SGreg Lehey.Pp
5094cbdc634SGreg LeheyLines starting with a # mark are comments.  Most of the other specifications are
5104cbdc634SGreg Leheyno longer used.  The ones which must still be set correctly are:
5114cbdc634SGreg Lehey.Pp
5124cbdc634SGreg Lehey.Bl -hang -width 20n
5134cbdc634SGreg Lehey.It Nm label
5144cbdc634SGreg Leheyis an optional label, set by the
5154cbdc634SGreg Lehey.Ar packid
5164cbdc634SGreg Leheyoption when writing a label.
5174cbdc634SGreg Lehey.It Nm flags
5184cbdc634SGreg LeheyFlags may be
5194cbdc634SGreg Lehey.Ar removable ,
5204cbdc634SGreg Lehey.Ar ecc
5214cbdc634SGreg Leheyor
5224cbdc634SGreg Lehey.Ar badsect .
5234cbdc634SGreg Lehey.Ar removable
524b5c508fbSRuslan Ermilovis set for removable media drives, but no current
525b5c508fbSRuslan Ermilov.Fx
526b5c508fbSRuslan Ermilovdriver evaluates this
5274cbdc634SGreg Leheyflag.
5284cbdc634SGreg Lehey.Ar ecc
5294cbdc634SGreg Leheyis no longer supported;
5304cbdc634SGreg Lehey.Ar badsect
5314cbdc634SGreg Leheyspecifies that the drive can perform bad sector remapping.
5324cbdc634SGreg Lehey.It Nm sectors/unit
5334cbdc634SGreg Leheydescribes the total size of the disk.  This value must be correct.
5344cbdc634SGreg Lehey.It Nm the partition table
5354cbdc634SGreg LeheyThis is the UNIX partition table, not the Microsoft partition table described in
5364cbdc634SGreg Lehey.Xr fdisk 8 .
5374cbdc634SGreg Lehey.El
5384cbdc634SGreg Lehey.Pp
5394cbdc634SGreg LeheyThe partition table can have up to 8 entries.  It contains the following
5404cbdc634SGreg Leheyinformation:
5414cbdc634SGreg Lehey.Bl -hang -width 10n
5424cbdc634SGreg Lehey.It identifier
5434cbdc634SGreg LeheyThe partition identifier is a single letter in the range
5444cbdc634SGreg Lehey.Nm a
5454cbdc634SGreg Leheyto
5464cbdc634SGreg Lehey.Nm h .
5474cbdc634SGreg LeheyBy convention, partition
5484cbdc634SGreg Lehey.Nm c
5494cbdc634SGreg Leheyis reserved to describe the entire disk.
5504cbdc634SGreg Lehey.It size
5514cbdc634SGreg Leheyis the size of the partition in sectors.
5524cbdc634SGreg Lehey.It offset
5534cbdc634SGreg Leheyis the offset of the start of the partition from the beginning of the drive.
5544cbdc634SGreg Lehey.It fstype
5554cbdc634SGreg Leheydescribes the purpose of the partition.  The example shows most normal usages.
5564cbdc634SGreg LeheyFor UFS file systems, use type 4.2BSD.  See
5574cbdc634SGreg Lehey.Pa /usr/include/sys/disklabel.h
5584cbdc634SGreg Leheyfor a complete list.
5594cbdc634SGreg Lehey.It fsize
5604cbdc634SGreg LeheyFor file systems only, the fragment size.
5614cbdc634SGreg Lehey.It bsize
5624cbdc634SGreg LeheyFor file systems only, the block size.
5634cbdc634SGreg Lehey.It bps/cpg
5644cbdc634SGreg LeheyFor UFS file systems, the number of cylinders in a cylinder group.  For LFS file
5654cbdc634SGreg Leheysystems, the segment shift value.
5664cbdc634SGreg Lehey.El
5674cbdc634SGreg LeheyThe remainder of the line is a comment and shows the cylinder allocations based
5684cbdc634SGreg Leheyon the obsolete (but possibly correct) geometry information about the drive.
5694cbdc634SGreg LeheyThe asterisk (*) indicates that the partition does not begin or end exactly on a
5704cbdc634SGreg Leheycylinder boundary.
5718fae3551SRodney W. Grimes.Sh EXAMPLES
5729f9930a2SRobert Nordier.Dl disklabel da0
5738fae3551SRodney W. Grimes.Pp
5744cbdc634SGreg LeheyDisplay the in-core label for
575ff7d5162SJordan K. Hubbard.Pa da0s1
5764cbdc634SGreg Leheyas obtained via
577ff7d5162SJordan K. Hubbard.Pa /dev/da0s1 .
578b5c508fbSRuslan ErmilovWhen reading a label,
579b5c508fbSRuslan Ermilov.Fx
580b5c508fbSRuslan Ermilovwill allow you to specify the base disk name
581ff7d5162SJordan K. Hubbardeven if the label resides on a slice.  However, to be proper you should
582726b61abSRuslan Ermilovspecify the base disk name only if you are using a
583726b61abSRuslan Ermilov.Dq dangerously-dedicated
584ff7d5162SJordan K. Hubbardlabel.  Normally you specify the slice.
5858fae3551SRodney W. Grimes.Pp
586ff7d5162SJordan K. Hubbard.Dl disklabel da0s1 > savedlabel
5874cbdc634SGreg Lehey.Pp
5884cbdc634SGreg LeheySave the in-core label for
589ff7d5162SJordan K. Hubbard.Pa da0s1
5904cbdc634SGreg Leheyinto the file
5914cbdc634SGreg Lehey.Pa savedlabel .
5924cbdc634SGreg LeheyThis file can be used with the
5934cbdc634SGreg Lehey.Fl R
5944cbdc634SGreg Leheyflag to restore the label at a later date.
5954cbdc634SGreg Lehey.Pp
596ff7d5162SJordan K. Hubbard.Dl disklabel -w -r /dev/da0s1 da2212 foo
5978fae3551SRodney W. Grimes.Pp
5984cbdc634SGreg LeheyCreate a label for
599ff7d5162SJordan K. Hubbard.Pa da0s1
6004cbdc634SGreg Leheybased on information for
601726b61abSRuslan Ermilov.Dq da2212
602726b61abSRuslan Ermilovfound in
6038fae3551SRodney W. Grimes.Pa /etc/disktab .
6048fae3551SRodney W. GrimesAny existing bootstrap code will be clobbered.
6058fae3551SRodney W. Grimes.Pp
606ff7d5162SJordan K. Hubbard.Dl disklabel -e -r da0s1
6078fae3551SRodney W. Grimes.Pp
6084cbdc634SGreg LeheyRead the on-disk label for
609ff7d5162SJordan K. Hubbard.Pa da0s1 ,
6104cbdc634SGreg Leheyedit it and reinstall in-core as well as on-disk.  Existing bootstrap code is
6114cbdc634SGreg Leheyunaffected.
6128fae3551SRodney W. Grimes.Pp
613ff7d5162SJordan K. Hubbard.Dl disklabel -r -w da0s1 auto
614425bed3aSJoerg Wunsch.Pp
6154cbdc634SGreg LeheyTry to auto-detect the required information from
616ff7d5162SJordan K. Hubbard.Pa da0s1 ,
6174cbdc634SGreg Leheyand write a new label to the disk.  Use another disklabel -e command to edit the
618425bed3aSJoerg Wunschpartitioning and file system information.
619425bed3aSJoerg Wunsch.Pp
620ff7d5162SJordan K. Hubbard.Dl disklabel -R da0s1 savedlabel
6218fae3551SRodney W. Grimes.Pp
6224cbdc634SGreg LeheyRestore the on-disk and in-core label for
623ff7d5162SJordan K. Hubbard.Pa da0s1
6244cbdc634SGreg Leheyfrom information in
6254cbdc634SGreg Lehey.Pa savedlabel .
6268fae3551SRodney W. GrimesExisting bootstrap code is unaffected.
6278fae3551SRodney W. Grimes.Pp
628ff7d5162SJordan K. Hubbard.Dl disklabel -B da0s1
6298fae3551SRodney W. Grimes.Pp
6304cbdc634SGreg LeheyInstall a new bootstrap on
631ff7d5162SJordan K. Hubbard.Pa da0s1 .
6328fae3551SRodney W. GrimesThe boot code comes from
633efba76d7SJordan K. Hubbard.Pa /boot/boot1
6348fae3551SRodney W. Grimesand possibly
635efba76d7SJordan K. Hubbard.Pa /boot/boot2 .
6368fae3551SRodney W. GrimesOn-disk and in-core labels are unchanged.
6378fae3551SRodney W. Grimes.Pp
638ff7d5162SJordan K. Hubbard.Dl disklabel -w -B /dev/da0s1 -b newboot1 -s newboot da2212
6398fae3551SRodney W. Grimes.Pp
6408fae3551SRodney W. GrimesInstall a new label and bootstrap.
641726b61abSRuslan ErmilovThe label is derived from disktab information for
642726b61abSRuslan Ermilov.Dq da2212
643726b61abSRuslan Ermilovand installed both in-core and on-disk.
6444cbdc634SGreg LeheyThe bootstrap code comes from the files
6454cbdc634SGreg Lehey.Pa /boot/newboot1
6464cbdc634SGreg Leheyand
6474cbdc634SGreg Lehey.Pa /boot/newboot2 .
648ff7d5162SJordan K. Hubbard.Pp
649ff7d5162SJordan K. Hubbard.Dl dd if=/dev/zero of=/dev/da0 bs=512 count=32
650ff7d5162SJordan K. Hubbard.Dl fdisk -BI da0
651ff7d5162SJordan K. Hubbard.Dl dd if=/dev/zero of=/dev/da0s1 bs=512 count=32
652ff7d5162SJordan K. Hubbard.Dl disklabel -w -r -B da0s1 auto
653ff7d5162SJordan K. Hubbard.Dl disklabel -e da0s1
654ff7d5162SJordan K. Hubbard.Pp
655ff7d5162SJordan K. HubbardCompletely wipe any prior information on the disk, creating a new bootable
656726b61abSRuslan Ermilovdisk with a DOS partition table containing one
657726b61abSRuslan Ermilov.Dq whole-disk
658726b61abSRuslan Ermilovslice.  Then
659ff7d5162SJordan K. Hubbardinitialize the slice, then edit it to your needs.  The
660ff7d5162SJordan K. Hubbard.Pa dd
661ff7d5162SJordan K. Hubbardcommands are optional, but may be necessary for some BIOSes to properly
662ff7d5162SJordan K. Hubbardrecognize the disk.
6638fae3551SRodney W. Grimes.Sh SEE ALSO
664af202156SWolfram Schneider.Xr disklabel 5 ,
6654cbdc634SGreg Lehey.Xr disktab 5 ,
666aa7c9adaSMike Pritchard.Xr boot0cfg 8 ,
66770846e5cSMike Pritchard.Xr fdisk 8
6688fae3551SRodney W. Grimes.Sh DIAGNOSTICS
6698fae3551SRodney W. GrimesThe kernel device drivers will not allow the size of a disk partition
6708fae3551SRodney W. Grimesto be decreased or the offset of a partition to be changed while it is open.
6718fae3551SRodney W. GrimesSome device drivers create a label containing only a single large partition
6724cbdc634SGreg Leheyif a disk is unlabeled; thus, the label must be written to the
673726b61abSRuslan Ermilov.Dq a
6744cbdc634SGreg Leheypartition of the disk while it is open.  This sometimes requires the desired
6754cbdc634SGreg Leheylabel to be set in two steps, the first one creating at least one other
6764cbdc634SGreg Leheypartition, and the second setting the label on the new partition while shrinking
6774cbdc634SGreg Leheythe
678726b61abSRuslan Ermilov.Dq a
6794cbdc634SGreg Leheypartition.
6808fae3551SRodney W. Grimes.Pp
6818fae3551SRodney W. GrimesOn some machines the bootstrap code may not fit entirely in the area
6828fae3551SRodney W. Grimesallocated for it by some filesystems.
6838fae3551SRodney W. GrimesAs a result, it may not be possible to have filesystems on some partitions
684726b61abSRuslan Ermilovof a
685726b61abSRuslan Ermilov.Dq bootable
686726b61abSRuslan Ermilovdisk.
6878fae3551SRodney W. GrimesWhen installing bootstrap code,
6886bd343a9SPhilippe Charnier.Nm
6898fae3551SRodney W. Grimeschecks for these cases.
6908fae3551SRodney W. GrimesIf the installed boot code would overlap a partition of type FS_UNUSED
6918fae3551SRodney W. Grimesit is marked as type FS_BOOT.
6928fae3551SRodney W. GrimesThe
6938fae3551SRodney W. Grimes.Xr newfs 8
6948fae3551SRodney W. Grimesutility will disallow creation of filesystems on FS_BOOT partitions.
6958fae3551SRodney W. GrimesConversely, if a partition has a type other than FS_UNUSED or FS_BOOT,
6966bd343a9SPhilippe Charnier.Nm
6978fae3551SRodney W. Grimeswill not install bootstrap code that overlaps it.
6988fae3551SRodney W. Grimes.Sh BUGS
6998fae3551SRodney W. GrimesWhen a disk name is given without a full pathname,
700726b61abSRuslan Ermilovthe constructed device name uses the
701726b61abSRuslan Ermilov.Dq c
702726b61abSRuslan Ermilovpartition.
703d70e4e53SJoerg Wunsch.Pp
704d70e4e53SJoerg WunschFor the i386 architecture, the primary bootstrap sector contains
705d70e4e53SJoerg Wunschan embedded
706d70e4e53SJoerg Wunsch.Em fdisk
707d70e4e53SJoerg Wunschtable.
708d70e4e53SJoerg Wunsch.Nm Disklabel
709d70e4e53SJoerg Wunschtakes care to not clobber it when installing a bootstrap only
710d70e4e53SJoerg Wunsch.Pq Fl B ,
711d70e4e53SJoerg Wunschor when editing an existing label
712d70e4e53SJoerg Wunsch.Pq Fl e ,
713d70e4e53SJoerg Wunschbut it unconditionally writes the primary bootstrap program onto
714d70e4e53SJoerg Wunschthe disk for
715d70e4e53SJoerg Wunsch.Fl w
716d70e4e53SJoerg Wunschor
717d70e4e53SJoerg Wunsch.Fl R ,
718d70e4e53SJoerg Wunschthus replacing the
719d70e4e53SJoerg Wunsch.Em fdisk
720d70e4e53SJoerg Wunschtable by the dummy one in the bootstrap program.  This is only of
721d70e4e53SJoerg Wunschconcern if the disk is fully dedicated, so that the BSD disklabel
722d70e4e53SJoerg Wunschstarts at absolute block 0 on the disk.
7234cbdc634SGreg Lehey.Pp
7244cbdc634SGreg Lehey.Nm
7254cbdc634SGreg Leheydoes not perform adequate error checking.  No warning is given if partitions
7264cbdc634SGreg Leheyoverlap, nor if space remains unused.
727