xref: /freebsd/sbin/bsdlabel/bsdlabel.8 (revision bc33ea1acc76c96c94f8a9a97cd48c8d34a8e020)
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.\"
389a9f19b1SRuslan Ermilov.Dd March 15, 2003
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
509a9f19b1SRuslan Ermilov.Op Fl nr
51bc33ea1aSRuslan Ermilov.Op Fl m Ar machine
52bc33ea1aSRuslan Ermilov.Ar disk type
539a9f19b1SRuslan Ermilov.Op Ar packid
547c7fb079SRuslan Ermilov.Nm
558fae3551SRodney W. Grimes.Fl e
569a9f19b1SRuslan Ermilov.Op Fl nr
57bc33ea1aSRuslan Ermilov.Op Fl m Ar machine
588fae3551SRodney W. Grimes.Ar disk
597c7fb079SRuslan Ermilov.Nm
608fae3551SRodney W. Grimes.Fl R
619a9f19b1SRuslan Ermilov.Op Fl nr
62bc33ea1aSRuslan Ermilov.Op Fl m Ar machine
639a9f19b1SRuslan Ermilov.Ar disk protofile
64726b61abSRuslan Ermilov.Pp
657c7fb079SRuslan Ermilov.Nm
668fae3551SRodney W. Grimes.Fl B
679a9f19b1SRuslan Ermilov.Op Fl b Ar boot
68bc33ea1aSRuslan Ermilov.Op Fl m Ar machine
698fae3551SRodney W. Grimes.Ar disk
707c7fb079SRuslan Ermilov.Nm
719a9f19b1SRuslan Ermilov.Fl w B
723233afaeSJohn W. De Boskey.Op Fl n
739a9f19b1SRuslan Ermilov.Op Fl b Ar boot
74bc33ea1aSRuslan Ermilov.Op Fl m Ar machine
75bc33ea1aSRuslan Ermilov.Ar disk type
769a9f19b1SRuslan Ermilov.Op Ar packid
777c7fb079SRuslan Ermilov.Nm
789a9f19b1SRuslan Ermilov.Fl R B
793233afaeSJohn W. De Boskey.Op Fl n
809a9f19b1SRuslan Ermilov.Op Fl b Ar boot
81bc33ea1aSRuslan Ermilov.Op Fl m Ar machine
829a9f19b1SRuslan Ermilov.Ar disk protofile
838fae3551SRodney W. Grimes.Sh DESCRIPTION
84e1205e80SPhilippe CharnierThe
85e1205e80SPhilippe Charnier.Nm
86e1205e80SPhilippe Charnierutility
879a9f19b1SRuslan Ermilovinstalls, examines or modifies the label on a disk drive or pack.
889a9f19b1SRuslan ErmilovWhen writing
894cbdc634SGreg Leheythe label, it can be used to change the drive identification, the disk
909a9f19b1SRuslan Ermilovpartitions on the drive, or to replace a damaged label.
919a9f19b1SRuslan ErmilovThere are several forms
929a9f19b1SRuslan Ermilovof the command that read (display), install, or edit the label on a disk.
939a9f19b1SRuslan ErmilovIn addition,
946bd343a9SPhilippe Charnier.Nm
954cbdc634SGreg Leheycan install bootstrap code.
969a9f19b1SRuslan Ermilov.Ss Raw or In-Core Label
972c80d96eSTom RhodesThe disk label resides close to or at the beginning of each disk slice.
989a9f19b1SRuslan ErmilovFor faster access, the kernel maintains a copy in core at all times.
999a9f19b1SRuslan ErmilovBy default, most
1004cbdc634SGreg Lehey.Nm
1019a9f19b1SRuslan Ermilovaccess the in-core copy of the label.
1029a9f19b1SRuslan ErmilovTo access the raw (on-disk) copy, use the
1034cbdc634SGreg Lehey.Fl r
1049a9f19b1SRuslan Ermilovoption.
1059a9f19b1SRuslan ErmilovThis option allows a label to be installed on a disk without kernel
1064cbdc634SGreg Leheysupport for a label, such as when labels are first installed on a system; it
1079a9f19b1SRuslan Ermilovmust be used when first installing a label on a disk.
1089a9f19b1SRuslan ErmilovThe specific effect of
1098fae3551SRodney W. Grimes.Fl r
1108fae3551SRodney W. Grimesis described under each command.
1119a9f19b1SRuslan Ermilov.Ss Disk Device Name
1124cbdc634SGreg LeheyAll
1137c7fb079SRuslan Ermilov.Nm
1144cbdc634SGreg Leheyforms require a disk device name, which should always be the raw
1159a9f19b1SRuslan Ermilovdevice name representing the disk or slice.
1169a9f19b1SRuslan ErmilovFor example,
117ff7d5162SJordan K. Hubbard.Pa da0
1189a9f19b1SRuslan Ermilovrepresents the entire disk regardless of any
1199a9f19b1SRuslan Ermilov.Tn DOS
1209a9f19b1SRuslan Ermilovpartitioning,
121ff7d5162SJordan K. Hubbardand
122ff7d5162SJordan K. Hubbard.Pa da0s1
1239a9f19b1SRuslan Ermilovrepresents a slice.
1249a9f19b1SRuslan ErmilovSome devices, most notably
1259a9f19b1SRuslan Ermilov.Xr ccd 4 ,
126ff7d5162SJordan K. Hubbardrequire that the
127726b61abSRuslan Ermilov.Dq whole-disk
128726b61abSRuslan Ermilov(or
1299a9f19b1SRuslan Ermilov.Ql c )
1309a9f19b1SRuslan Ermilovpartition be specified.
1319a9f19b1SRuslan ErmilovFor example,
132ff7d5162SJordan K. Hubbard.Pa ccd0c .
1339a9f19b1SRuslan ErmilovWhen specifying the device,
1349a9f19b1SRuslan Ermilovthe
135ff7d5162SJordan K. Hubbard.Pa /dev/
1369a9f19b1SRuslan Ermilovpath prefix may be omitted;
1379a9f19b1SRuslan Ermilovthe
1384cbdc634SGreg Lehey.Nm
139e1205e80SPhilippe Charnierutility will automatically prepend it.
1409a9f19b1SRuslan Ermilov.Ss Reading the Disk Label
141e40fcc98SDima DorfmanTo examine the label on a disk drive, use
1424cbdc634SGreg Lehey.Nm
1434cbdc634SGreg Leheywithout options:
1444cbdc634SGreg Lehey.Pp
1457c7fb079SRuslan Ermilov.Nm
1464cbdc634SGreg Lehey.Op Fl r
1474cbdc634SGreg Lehey.Ar disk
1484cbdc634SGreg Lehey.Pp
1494cbdc634SGreg Lehey.Ar disk
1504cbdc634SGreg Leheyrepresents the raw disk in question, and may be in the form
1514cbdc634SGreg Lehey.Pa da0
1524cbdc634SGreg Leheyor
15307b0cf9aSDavid E. O'Brien.Pa /dev/da0c .
1544cbdc634SGreg LeheyIt will display all of the parameters associated with the drive and its
1559a9f19b1SRuslan Ermilovpartition layout.
1569a9f19b1SRuslan ErmilovUnless the
1578fae3551SRodney W. Grimes.Fl r
1589a9f19b1SRuslan Ermilovoption is given,
1598fae3551SRodney W. Grimesthe kernel's in-core copy of the label is displayed;
1608fae3551SRodney W. Grimesif the disk has no label, or the partition types on the disk are incorrect,
1618fae3551SRodney W. Grimesthe kernel may have constructed or modified the label.
1628fae3551SRodney W. GrimesIf the
1638fae3551SRodney W. Grimes.Fl r
1649a9f19b1SRuslan Ermilovoption is given,
1654cbdc634SGreg Lehey.Nm
1669a9f19b1SRuslan Ermilovreads the label from the raw disk and displays it.
1679a9f19b1SRuslan ErmilovBoth versions are usually
168ff7d5162SJordan K. Hubbardidentical except in the case where a label has not yet been initialized or
169ff7d5162SJordan K. Hubbardis corrupt.
1709a9f19b1SRuslan Ermilov.Ss Writing a Standard Label
1714cbdc634SGreg LeheyTo write a standard label, use the form
1724cbdc634SGreg Lehey.Pp
1737c7fb079SRuslan Ermilov.Nm
1748fae3551SRodney W. Grimes.Fl w
1759a9f19b1SRuslan Ermilov.Op Fl nr
176bc33ea1aSRuslan Ermilov.Op Fl m Ar machine
177bc33ea1aSRuslan Ermilov.Ar disk type
1789a9f19b1SRuslan Ermilov.Op Ar packid
179ff7d5162SJordan K. Hubbard.Pp
1808fae3551SRodney W. GrimesThe required arguments to
1816bd343a9SPhilippe Charnier.Nm
1829a9f19b1SRuslan Ermilovare the drive to be labeled, and the drive type as described in the
183d0353b83SRuslan Ermilov.Xr disktab 5
1849a9f19b1SRuslan Ermilovfile.
1859a9f19b1SRuslan ErmilovThe drive parameters and partitions are taken from that file.
1869a9f19b1SRuslan ErmilovIf different disks of the same physical type are to have different partitions,
1879a9f19b1SRuslan Ermilovit will be necessary to have separate
1889a9f19b1SRuslan Ermilov.Xr disktab 5
1899a9f19b1SRuslan Ermiloventries describing each, or to edit
1909a9f19b1SRuslan Ermilovthe label after installation as described below.
1919a9f19b1SRuslan ErmilovThe optional argument is a
1929a9f19b1SRuslan Ermilovpack identification string, up to 16 characters long.
1939a9f19b1SRuslan ErmilovThe
1949a9f19b1SRuslan Ermilov.Ar packid
1959a9f19b1SRuslan Ermilovmust be quoted if it contains blanks.
1963233afaeSJohn W. De Boskey.Pp
197bc33ea1aSRuslan ErmilovIf the
198bc33ea1aSRuslan Ermilov.Fl m
199bc33ea1aSRuslan Ermilovoption is given, then label will be written so that
200bc33ea1aSRuslan Ermilovit is understood by the target
201bc33ea1aSRuslan Ermilov.Ar machine ;
202bc33ea1aSRuslan Ermilovdefaults to the current hardware architecture.
203bc33ea1aSRuslan Ermilov.Pp
2049a9f19b1SRuslan ErmilovIf
2053233afaeSJohn W. De Boskey.Fl n
2069a9f19b1SRuslan Ermilovis used, no data will be written to the device, and instead the
2079a9f19b1SRuslan Ermilovdisk label that would have been written will be printed to standard output.
2083233afaeSJohn W. De Boskey.Pp
2093233afaeSJohn W. De BoskeyIf the
2108fae3551SRodney W. Grimes.Fl r
2119a9f19b1SRuslan Ermilovoption is given, the disk sectors containing the label and bootstrap
2128fae3551SRodney W. Grimeswill be written directly.
2138fae3551SRodney W. GrimesA side-effect of this is that any existing bootstrap code will be overwritten
2149a9f19b1SRuslan Ermilovand the disk rendered unbootable.
2159a9f19b1SRuslan ErmilovSee the boot options below for a method of
216bc33ea1aSRuslan Ermilovwriting the and the bootstrap at the same time.
2178fae3551SRodney W. GrimesIf
2188fae3551SRodney W. Grimes.Fl r
2198fae3551SRodney W. Grimesis not specified,
2209a9f19b1SRuslan Ermilovthe existing label will be updated via the in-core copy, and any bootstrap
2218fae3551SRodney W. Grimescode will be unaffected.
2228fae3551SRodney W. GrimesIf the disk does not already have a label, the
2238fae3551SRodney W. Grimes.Fl r
2249a9f19b1SRuslan Ermilovoption must be used.
2258fae3551SRodney W. GrimesIn either case, the kernel's in-core label is replaced.
2268fae3551SRodney W. Grimes.Pp
227425bed3aSJoerg WunschFor a virgin disk that is not known to
228425bed3aSJoerg Wunsch.Xr disktab 5 ,
229bc33ea1aSRuslan Ermilov.Ar type
230425bed3aSJoerg Wunschcan be specified as
2319503d41cSRuslan Ermilov.Cm auto .
232425bed3aSJoerg WunschIn this case, the driver is requested to produce a virgin label for the
2339a9f19b1SRuslan Ermilovdisk.
2349a9f19b1SRuslan ErmilovThis might or might not be successful, depending on whether the
235425bed3aSJoerg Wunschdriver for the disk is able to get the required data without reading
2369a9f19b1SRuslan Ermilovanything from the disk at all.
2379a9f19b1SRuslan ErmilovIt will likely succeed for all
2389a9f19b1SRuslan Ermilov.Tn SCSI
2399a9f19b1SRuslan Ermilovdisks, most
2409a9f19b1SRuslan Ermilov.Tn IDE
2419a9f19b1SRuslan Ermilovdisks, and
2429a9f19b1SRuslan Ermilov.Cm vnode
2439a9f19b1SRuslan Ermilovtype memory disks
2449a9f19b1SRuslan Ermilov.Pq Xr md 4 .
2459a9f19b1SRuslan ErmilovWriting a label to the
246425bed3aSJoerg Wunschdisk is the only supported operation, and the
247425bed3aSJoerg Wunsch.Ar disk
2489a9f19b1SRuslan Ermilovitself must be provided as the canonical name, i.e., not as a full
249425bed3aSJoerg Wunschpath name.
250ff7d5162SJordan K. Hubbard.Pp
2513233afaeSJohn W. De BoskeyFor most harddisks, a label based on percentages for most partitions (and
2527733674eSRuslan Ermilovone partition with a size of
2537733674eSRuslan Ermilov.Ql * )
2547733674eSRuslan Ermilovwill produce a reasonable configuration.
2553233afaeSJohn W. De Boskey.Pp
2569a9f19b1SRuslan ErmilovPC-based systems have special requirements in order for the
2579a9f19b1SRuslan Ermilov.Tn BIOS
2589a9f19b1SRuslan Ermilovto properly recognize a
259b5c508fbSRuslan Ermilov.Fx
2609a9f19b1SRuslan Ermilovdisk label.
2619a9f19b1SRuslan ErmilovOlder systems may require what is known as a
2629a9f19b1SRuslan Ermilov.Dq dangerously-dedicated
2639a9f19b1SRuslan Ermilovdisk label, which creates a fake
2649a9f19b1SRuslan Ermilov.Tn DOS
2659a9f19b1SRuslan Ermilovpartition to work around problems older
2669a9f19b1SRuslan Ermilov.Tn BIOS Ns es
2679a9f19b1SRuslan Ermilovhave with modern disk geometries.
2689a9f19b1SRuslan ErmilovOn newer systems, a normal
2699a9f19b1SRuslan Ermilov.Tn DOS
2709a9f19b1SRuslan Ermilovpartition should generally be created using
2719a9f19b1SRuslan Ermilov.Xr fdisk 8 ,
2729a9f19b1SRuslan Ermilovand then a
273b5c508fbSRuslan Ermilov.Fx
2749a9f19b1SRuslan Ermilovdisk label within that slice.
2759a9f19b1SRuslan ErmilovThis is described later on in this page.
276ff7d5162SJordan K. Hubbard.Pp
2779a9f19b1SRuslan ErmilovInstalling a new disk label does not in of itself allow the system to boot
2789a9f19b1SRuslan Ermilova kernel using that label.
2799a9f19b1SRuslan ErmilovBoot blocks must also be installed, which is
280ff7d5162SJordan K. Hubbarddescribed later on in this manual page.
2819a9f19b1SRuslan Ermilov.Ss Editing an Existing Disk Label
2824cbdc634SGreg LeheyTo edit an existing disk label, use the form
2834cbdc634SGreg Lehey.Pp
2847c7fb079SRuslan Ermilov.Nm
2858fae3551SRodney W. Grimes.Fl e
2869a9f19b1SRuslan Ermilov.Op Fl nr
287bc33ea1aSRuslan Ermilov.Op Fl m Ar machine
2884cbdc634SGreg Lehey.Ar disk
2894cbdc634SGreg Lehey.Pp
2904cbdc634SGreg LeheyThis command reads the label from the in-core kernel copy, or directly from the
2914cbdc634SGreg Leheydisk if the
2928fae3551SRodney W. Grimes.Fl r
2939a9f19b1SRuslan Ermilovoption is also specified.
2949a9f19b1SRuslan ErmilovThe label is written to a file in
2959a9f19b1SRuslan Ermilov.Tn ASCII
2969a9f19b1SRuslan Ermilovformat, and then supplied to an editor for changes.
2979a9f19b1SRuslan ErmilovIf no editor is specified in the
2988fae3551SRodney W. Grimes.Ev EDITOR
2998fae3551SRodney W. Grimesenvironment variable,
3008fae3551SRodney W. Grimes.Xr vi 1
3019a9f19b1SRuslan Ermilovis used.
3029a9f19b1SRuslan ErmilovWhen the editor terminates, the label file is used to rewrite the disk label.
3039a9f19b1SRuslan ErmilovExisting bootstrap code is unchanged regardless of whether
3048fae3551SRodney W. Grimes.Fl r
3059a9f19b1SRuslan Ermilovwas specified.
306bc33ea1aSRuslan Ermilov.Pp
307bc33ea1aSRuslan ErmilovIf the
308bc33ea1aSRuslan Ermilov.Fl m
309bc33ea1aSRuslan Ermilovoption is given, then the label will be written so that
310bc33ea1aSRuslan Ermilovit is understood by the target
311bc33ea1aSRuslan Ermilov.Ar machine ;
312bc33ea1aSRuslan Ermilovdefaults to the current hardware architecture.
313bc33ea1aSRuslan Ermilov.Pp
3149a9f19b1SRuslan ErmilovIf
3153233afaeSJohn W. De Boskey.Fl n
3169a9f19b1SRuslan Ermilovis used, no data will be written to the device, and instead the
3179a9f19b1SRuslan Ermilovdisk label that would have been written will be printed to standard output.
3189a9f19b1SRuslan ErmilovThis is
3193233afaeSJohn W. De Boskeyuseful to see how a partitioning scheme will work out for a specific disk.
3209a9f19b1SRuslan Ermilov.Ss Restoring a Disk Label From a File
3214cbdc634SGreg LeheyTo restore a disk label from a file, use the form
3224cbdc634SGreg Lehey.Pp
3237c7fb079SRuslan Ermilov.Nm
3248fae3551SRodney W. Grimes.Fl R
3259a9f19b1SRuslan Ermilov.Op Fl nr
326bc33ea1aSRuslan Ermilov.Op Fl m Ar machine
3279a9f19b1SRuslan Ermilov.Ar disk protofile
3288fae3551SRodney W. Grimes.Pp
3296bd343a9SPhilippe Charnier.Nm
3309a9f19b1SRuslan Ermilovis capable of restoring a disk label that was previously saved in a file in
3319a9f19b1SRuslan Ermilov.Tn ASCII
3329a9f19b1SRuslan Ermilovformat.
3334cbdc634SGreg LeheyThe prototype file used to create the label should be in the same format as that
3349a9f19b1SRuslan Ermilovproduced when reading or editing a label.
3359a9f19b1SRuslan ErmilovComments are delimited by
3369a9f19b1SRuslan Ermilov.Ql #
3379a9f19b1SRuslan Ermilovand newline.
3389a9f19b1SRuslan ErmilovAs when writing a new label, any existing bootstrap code will be
3394cbdc634SGreg Leheyclobbered if
3404cbdc634SGreg Lehey.Fl r
3419a9f19b1SRuslan Ermilovis specified, and will be unaffected otherwise.
3429a9f19b1SRuslan ErmilovSee the boot options below for a
3434cbdc634SGreg Leheymethod of restoring the label and writing the bootstrap at the same time.
344bc33ea1aSRuslan Ermilov.Pp
345bc33ea1aSRuslan ErmilovIf the
346bc33ea1aSRuslan Ermilov.Fl m
347bc33ea1aSRuslan Ermilovoption is given, then the label will be written so that
348bc33ea1aSRuslan Ermilovit is understood by the target
349bc33ea1aSRuslan Ermilov.Ar machine ;
350bc33ea1aSRuslan Ermilovdefaults to the current hardware architecture.
351bc33ea1aSRuslan Ermilov.Pp
3523233afaeSJohn W. De BoskeyIf
3533233afaeSJohn W. De Boskey.Fl n
3543233afaeSJohn W. De Boskeyis used, no data will be written to the device, and instead the
3559a9f19b1SRuslan Ermilovdisk label that would have been written will be printed to standard output.
3569a9f19b1SRuslan ErmilovThis is
3573233afaeSJohn W. De Boskeyuseful to see how a partitioning scheme will work out for a specific disk.
3589a9f19b1SRuslan Ermilov.Ss Installing Bootstraps
3598fae3551SRodney W. GrimesThe final three forms of
3606bd343a9SPhilippe Charnier.Nm
3619a9f19b1SRuslan Ermilovare used to install bootstrap code.
3629a9f19b1SRuslan ErmilovIf a
363726b61abSRuslan Ermilov.Dq dangerously-dedicated
3649a9f19b1SRuslan Ermilovdisk is created for compatibility with older PC systems,
3659a9f19b1SRuslan Ermilovthe raw disk name such as
3669a9f19b1SRuslan Ermilov.Pa da0
3679a9f19b1SRuslan Ermilovshould be specified.
3689a9f19b1SRuslan ErmilovIf an existing slice should be labeled,
3699a9f19b1SRuslan Ermilovthe slice name such as
3709a9f19b1SRuslan Ermilov.Pa da0s1
3719a9f19b1SRuslan Ermilovshould be specified,
3729a9f19b1SRuslan Ermilovand to make it bootable,
3739a9f19b1SRuslan Ermilov.Tn MBR
3749a9f19b1SRuslan Ermilovon the base disk should probably be updated; see
3759a9f19b1SRuslan Ermilov.Xr fdisk 8 .
3764cbdc634SGreg Lehey.Pp
3777c7fb079SRuslan Ermilov.Nm
3788fae3551SRodney W. Grimes.Fl B
3799a9f19b1SRuslan Ermilov.Op Fl b Ar boot
380bc33ea1aSRuslan Ermilov.Op Fl m Ar machine
3814cbdc634SGreg Lehey.Ar disk
3824cbdc634SGreg Lehey.Pp
3839a9f19b1SRuslan ErmilovThis form installs the bootstrap only.
3849a9f19b1SRuslan ErmilovIt does not change the disk label.
3859a9f19b1SRuslan ErmilovNever use this command on a base disk, such as
3869a9f19b1SRuslan Ermilov.Pa da0 ,
3879a9f19b1SRuslan Ermilovunless the intent is to create a
388726b61abSRuslan Ermilov.Dq dangerously-dedicated
3899a9f19b1SRuslan Ermilovdisk.
390ff7d5162SJordan K. HubbardThis command is typically run on a slice such as
3919a9f19b1SRuslan Ermilov.Pa da0s1 .
3924cbdc634SGreg Lehey.Pp
393bc33ea1aSRuslan ErmilovThe
394bc33ea1aSRuslan Ermilov.Fl m
395bc33ea1aSRuslan Ermilovoption should be specified if the label was
396bc33ea1aSRuslan Ermilovcreated for a different hardware architecture,
397bc33ea1aSRuslan Ermilov.Ar machine .
398bc33ea1aSRuslan Ermilov.Pp
3997c7fb079SRuslan Ermilov.Nm
4009a9f19b1SRuslan Ermilov.Fl w B
4013233afaeSJohn W. De Boskey.Op Fl n
4029a9f19b1SRuslan Ermilov.Op Fl b Ar boot
403bc33ea1aSRuslan Ermilov.Op Fl m Ar machine
404bc33ea1aSRuslan Ermilov.Ar disk type
4059a9f19b1SRuslan Ermilov.Op Ar packid
4064cbdc634SGreg Lehey.Pp
407726b61abSRuslan ErmilovThis form corresponds to the
4089a9f19b1SRuslan Ermilov.Dq "write label"
409726b61abSRuslan Ermilovcommand described above.
4104cbdc634SGreg LeheyIn addition to writing a new volume label, it also installs the bootstrap.
4119a9f19b1SRuslan ErmilovIf run on a base disk, this command will create a
412726b61abSRuslan Ermilov.Dq dangerously-dedicated
4139a9f19b1SRuslan Ermilovlabel.
4149a9f19b1SRuslan ErmilovThis command is normally run on a slice rather than a base disk.
415bc33ea1aSRuslan Ermilov.Pp
416bc33ea1aSRuslan ErmilovIf the
417bc33ea1aSRuslan Ermilov.Fl m
418bc33ea1aSRuslan Ermilovoption is given, then the label and bootstrap will be written so that
419bc33ea1aSRuslan Ermilovthey are understood by the target
420bc33ea1aSRuslan Ermilov.Ar machine ;
421bc33ea1aSRuslan Ermilovdefaults to the current hardware architecture.
422bc33ea1aSRuslan Ermilov.Pp
4233233afaeSJohn W. De BoskeyIf
4243233afaeSJohn W. De Boskey.Fl n
4253233afaeSJohn W. De Boskeyis used, no data will be written to the device, and instead the
4269a9f19b1SRuslan Ermilovdisk label that would have been written will be printed to standard output.
4274cbdc634SGreg Lehey.Pp
4287c7fb079SRuslan Ermilov.Nm
4299a9f19b1SRuslan Ermilov.Fl R B
4303233afaeSJohn W. De Boskey.Op Fl n
4319a9f19b1SRuslan Ermilov.Op Fl b Ar boot
432bc33ea1aSRuslan Ermilov.Op Fl m Ar machine
4339a9f19b1SRuslan Ermilov.Ar disk protofile
4344cbdc634SGreg Lehey.Pp
435726b61abSRuslan ErmilovThis form corresponds to the
4369a9f19b1SRuslan Ermilov.Dq "restore label"
437726b61abSRuslan Ermilovcommand described above.
4384cbdc634SGreg LeheyIn addition to restoring the volume label, it also installs the bootstrap.
4399a9f19b1SRuslan ErmilovIf run on a base disk, this command will create a
440726b61abSRuslan Ermilov.Dq dangerously-dedicated
4419a9f19b1SRuslan Ermilovlabel.
4429a9f19b1SRuslan ErmilovThis command is normally run on a slice rather than a base disk.
4434cbdc634SGreg Lehey.Pp
4444cbdc634SGreg LeheyThe bootstrap commands always access the disk directly, so it is not necessary
4454cbdc634SGreg Leheyto specify the
4468fae3551SRodney W. Grimes.Fl r
4479a9f19b1SRuslan Ermilovoption.
448bc33ea1aSRuslan Ermilov.Pp
449bc33ea1aSRuslan ErmilovIf the
450bc33ea1aSRuslan Ermilov.Fl m
451bc33ea1aSRuslan Ermilovoption is given, then the label and bootstrap will be written so that
452bc33ea1aSRuslan Ermilovthey are understood by the target
453bc33ea1aSRuslan Ermilov.Ar machine ;
454bc33ea1aSRuslan Ermilovdefaults to the current hardware architecture.
455bc33ea1aSRuslan Ermilov.Pp
4569a9f19b1SRuslan ErmilovIf
4573233afaeSJohn W. De Boskey.Fl n
4583233afaeSJohn W. De Boskeyis used, no data will be written to the device, and instead the
4599a9f19b1SRuslan Ermilovdisk label that would have been written will be printed to standard output.
4604cbdc634SGreg Lehey.Pp
4619a9f19b1SRuslan ErmilovThe bootstrap code is comprised of two boot programs compiled into a single
462ef9ab0b3SRuslan Ermilov.Pa /boot/boot
463ef9ab0b3SRuslan Ermilovimage.
464ef9ab0b3SRuslan ErmilovAn alternative boot image may be specified with the
4658fae3551SRodney W. Grimes.Fl b
466ef9ab0b3SRuslan Ermilovoption.
4679a9f19b1SRuslan Ermilov.Ss Initializing/Formatting a Bootable Disk From Scratch
4689a9f19b1SRuslan ErmilovTo initialize a disk from scratch, the following sequence is recommended.
469ff7d5162SJordan K. HubbardPlease note that this will wipe everything that was previously on the disk,
470b5c508fbSRuslan Ermilovincluding any
471b5c508fbSRuslan Ermilov.No non- Ns Fx
472b5c508fbSRuslan Ermilovslices.
473ff7d5162SJordan K. Hubbard.Bl -enum
474ff7d5162SJordan K. Hubbard.It
475ff7d5162SJordan K. HubbardUse
4762c80d96eSTom Rhodes.Xr fdisk 8
4772c80d96eSTom Rhodesto initialize the hard disk, and create a slice table, referred to
4789a9f19b1SRuslan Ermilovas the
4799a9f19b1SRuslan Ermilov.Dq "partition table"
4809a9f19b1SRuslan Ermilovin
4819a9f19b1SRuslan ErmilovTn DOS .
482ff7d5162SJordan K. Hubbard.It
483ff7d5162SJordan K. HubbardUse
484facc6767SRuslan Ermilov.Nm
4859a9f19b1SRuslan Ermilovto define partitions on
4869a9f19b1SRuslan Ermilov.Fx
4879a9f19b1SRuslan Ermilovslices created in the previous step.
488ff7d5162SJordan K. Hubbard.It
4892c80d96eSTom RhodesFinally use
4902c80d96eSTom Rhodes.Xr newfs 8
4919a9f19b1SRuslan Ermilovto create file systems on new partitions.
492ff7d5162SJordan K. Hubbard.El
493ff7d5162SJordan K. Hubbard.Pp
4949a9f19b1SRuslan ErmilovA typical partitioning scheme would be to have an
4959a9f19b1SRuslan Ermilov.Ql a
4969a9f19b1SRuslan Ermilovpartition
4979a9f19b1SRuslan Ermilovof approximately 128MB to hold the root file system, a
4989a9f19b1SRuslan Ermilov.Ql b
4999a9f19b1SRuslan Ermilovpartition for
5009a9f19b1SRuslan Ermilovswap, a
5019a9f19b1SRuslan Ermilov.Ql d
5029a9f19b1SRuslan Ermilovpartition for
5039a9f19b1SRuslan Ermilov.Pa /var
5049a9f19b1SRuslan Ermilov(usually 128MB), an
5059a9f19b1SRuslan Ermilov.Ql e
5069a9f19b1SRuslan Ermilovpartition
5079a9f19b1SRuslan Ermilovfor
5089a9f19b1SRuslan Ermilov.Pa /var/tmp
5099a9f19b1SRuslan Ermilov(usually 128MB), an
5109a9f19b1SRuslan Ermilov.Ql f
5119a9f19b1SRuslan Ermilovpartition for
5129a9f19b1SRuslan Ermilov.Pa /usr
5139a9f19b1SRuslan Ermilov(usually around 2GB),
5149a9f19b1SRuslan Ermilovand finally a
5159a9f19b1SRuslan Ermilov.Ql g
5169a9f19b1SRuslan Ermilovpartition for
5179a9f19b1SRuslan Ermilov.Pa /home
5189a9f19b1SRuslan Ermilov(usually all remaining space).
5199a9f19b1SRuslan ErmilovYour mileage may vary.
5209a9f19b1SRuslan Ermilov.Pp
5219a9f19b1SRuslan Ermilov.Nm fdisk Fl BI Pa da0
522ff7d5162SJordan K. Hubbard.Pp
5237c7fb079SRuslan Ermilov.Nm
5249a9f19b1SRuslan Ermilov.Fl w B
5259a9f19b1SRuslan Ermilov.Pa da0s1
5269503d41cSRuslan Ermilov.Cm auto
527ff7d5162SJordan K. Hubbard.Pp
5287c7fb079SRuslan Ermilov.Nm
529ff7d5162SJordan K. Hubbard.Fl e
5309a9f19b1SRuslan Ermilov.Pa da0s1
5318fae3551SRodney W. Grimes.Sh FILES
532ef9ab0b3SRuslan Ermilov.Bl -tag -width ".Pa /etc/disktab" -compact
533ef9ab0b3SRuslan Ermilov.It Pa /boot/boot
534ef9ab0b3SRuslan ErmilovDefault boot image.
5358fae3551SRodney W. Grimes.It Pa /etc/disktab
536ef9ab0b3SRuslan ErmilovDisk description file.
5378fae3551SRodney W. Grimes.El
5384cbdc634SGreg Lehey.Sh SAVED FILE FORMAT
539e1205e80SPhilippe CharnierThe
5404cbdc634SGreg Lehey.Nm
541e1205e80SPhilippe Charnierutility
5429a9f19b1SRuslan Ermilovuses an
5439a9f19b1SRuslan Ermilov.Tn ASCII
5449a9f19b1SRuslan Ermilovversion of the label when examining, editing, or restoring a disk
5459a9f19b1SRuslan Ermilovlabel.
5469a9f19b1SRuslan ErmilovThe format is:
5474cbdc634SGreg Lehey.Bd -literal -offset 4n
54807b0cf9aSDavid E. O'Brien# /dev/da1c:
5494cbdc634SGreg Leheytype: SCSI
55007b0cf9aSDavid E. O'Briendisk: da0s1
5514cbdc634SGreg Leheylabel:
5524cbdc634SGreg Leheyflags:
5534cbdc634SGreg Leheybytes/sector: 512
5544cbdc634SGreg Leheysectors/track: 51
5554cbdc634SGreg Leheytracks/cylinder: 19
5564cbdc634SGreg Leheysectors/cylinder: 969
5574cbdc634SGreg Leheycylinders: 1211
5584cbdc634SGreg Leheysectors/unit: 1173930
5594cbdc634SGreg Leheyrpm: 3600
5604cbdc634SGreg Leheyinterleave: 1
5614cbdc634SGreg Leheytrackskew: 0
5624cbdc634SGreg Leheycylinderskew: 0
5634cbdc634SGreg Leheyheadswitch: 0           # milliseconds
5644cbdc634SGreg Leheytrack-to-track seek: 0  # milliseconds
5654cbdc634SGreg Leheydrivedata: 0
5664cbdc634SGreg Lehey
5674cbdc634SGreg Lehey8 partitions:
5684cbdc634SGreg Lehey#        size   offset    fstype   [fsize bsize bps/cpg]
5694cbdc634SGreg Lehey  a:    81920        0    4.2BSD     1024  8192    16   # (Cyl.    0 - 84*)
5704cbdc634SGreg Lehey  b:   160000    81920      swap                        # (Cyl.   84* - 218*)
5714cbdc634SGreg Lehey  c:  1173930        0    unused        0     0         # (Cyl.    0 - 1211*)
5724cbdc634SGreg Lehey  h:   962010   211920     vinum                        # (Cyl.  218*- 1211*)
5734cbdc634SGreg Lehey.Ed
5744cbdc634SGreg Lehey.Pp
5759a9f19b1SRuslan ErmilovLines starting with a
5769a9f19b1SRuslan Ermilov.Ql #
5779a9f19b1SRuslan Ermilovmark are comments.
5789a9f19b1SRuslan ErmilovMost of the other specifications are no longer used.
5799a9f19b1SRuslan ErmilovThe ones which must still be set correctly are:
5804cbdc634SGreg Lehey.Pp
5819a9f19b1SRuslan Ermilov.Bl -inset
5829a9f19b1SRuslan Ermilov.It Ar label
5834cbdc634SGreg Leheyis an optional label, set by the
5844cbdc634SGreg Lehey.Ar packid
5854cbdc634SGreg Leheyoption when writing a label.
5869a9f19b1SRuslan Ermilov.It Ar flags
5879a9f19b1SRuslan Ermilovmay be
5889a9f19b1SRuslan Ermilov.Cm removable , ecc
5894cbdc634SGreg Leheyor
5909a9f19b1SRuslan Ermilov.Cm badsect .
5919a9f19b1SRuslan Ermilov.Cm removable
592b5c508fbSRuslan Ermilovis set for removable media drives, but no current
593b5c508fbSRuslan Ermilov.Fx
594b5c508fbSRuslan Ermilovdriver evaluates this
5954cbdc634SGreg Leheyflag.
5969a9f19b1SRuslan Ermilov.Cm ecc
5974cbdc634SGreg Leheyis no longer supported;
5989a9f19b1SRuslan Ermilov.Cm badsect
5994cbdc634SGreg Leheyspecifies that the drive can perform bad sector remapping.
6009a9f19b1SRuslan Ermilov.It Ar sectors/unit
6019a9f19b1SRuslan Ermilovdescribes the total size of the disk.
6029a9f19b1SRuslan ErmilovThis value must be correct.
6039a9f19b1SRuslan Ermilov.It Ar "the partition table"
6049a9f19b1SRuslan Ermilovis the
6057733674eSRuslan Ermilov.Ux
6069a9f19b1SRuslan Ermilovpartition table, not the
6079a9f19b1SRuslan Ermilov.Tn DOS
6089a9f19b1SRuslan Ermilovpartition table described in
6094cbdc634SGreg Lehey.Xr fdisk 8 .
6104cbdc634SGreg Lehey.El
6114cbdc634SGreg Lehey.Pp
6129a9f19b1SRuslan ErmilovThe partition table can have up to 8 entries.
6139a9f19b1SRuslan ErmilovIt contains the following information:
6149a9f19b1SRuslan Ermilov.Bl -tag -width indent
6159a9f19b1SRuslan Ermilov.It Ar #
6164cbdc634SGreg LeheyThe partition identifier is a single letter in the range
6179a9f19b1SRuslan Ermilov.Ql a
6184cbdc634SGreg Leheyto
6199a9f19b1SRuslan Ermilov.Ql h .
6204cbdc634SGreg LeheyBy convention, partition
6219a9f19b1SRuslan Ermilov.Ql c
6224cbdc634SGreg Leheyis reserved to describe the entire disk.
6239a9f19b1SRuslan Ermilov.It Ar size
6249a9f19b1SRuslan ErmilovThe size of the partition in sectors,
6257733674eSRuslan Ermilov.Cm K
6263233afaeSJohn W. De Boskey(kilobytes - 1024),
6277733674eSRuslan Ermilov.Cm M
6283233afaeSJohn W. De Boskey(megabytes - 1024*1024),
6297733674eSRuslan Ermilov.Cm G
6303233afaeSJohn W. De Boskey(gigabytes - 1024*1024*1024),
6317733674eSRuslan Ermilov.Cm %
6329a9f19b1SRuslan Ermilov(percentage of free space
6339a9f19b1SRuslan Ermilov.Em after
6349a9f19b1SRuslan Ermilovremoving any fixed-size partitions other than partition
6359a9f19b1SRuslan Ermilov.Ql c ) ,
6367733674eSRuslan Ermilovor
6377733674eSRuslan Ermilov.Cm *
6389a9f19b1SRuslan Ermilov(all remaining free space
6399a9f19b1SRuslan Ermilov.Em after
6409a9f19b1SRuslan Ermilovfixed-size and percentage partitions).
6419a9f19b1SRuslan ErmilovFor partition
6429a9f19b1SRuslan Ermilov.Ql c ,
6437733674eSRuslan Ermilova size of
6447733674eSRuslan Ermilov.Cm *
6459a9f19b1SRuslan Ermilovindicates the entire disk.
6469a9f19b1SRuslan ErmilovLowercase versions of
6477733674eSRuslan Ermilov.Cm K , M ,
6487733674eSRuslan Ermilovand
6497733674eSRuslan Ermilov.Cm G
6503233afaeSJohn W. De Boskeyare allowed.
6513233afaeSJohn W. De BoskeySize and type should be specifed without any spaces between them.
6523233afaeSJohn W. De Boskey.Pp
6539a9f19b1SRuslan ErmilovExample: 2097152, 1G, 1024M and 1048576K are all the same size
6543233afaeSJohn W. De Boskey(assuming 512-byte sectors).
6559a9f19b1SRuslan Ermilov.It Ar offset
6569a9f19b1SRuslan ErmilovThe offset of the start of the partition from the beginning of the
6577733674eSRuslan Ermilovdrive in sectors, or
6587733674eSRuslan Ermilov.Cm *
6597733674eSRuslan Ermilovto have
6603233afaeSJohn W. De Boskey.Nm
6613233afaeSJohn W. De Boskeycalculate the correct offset to use (the end of the previous partition plus
6623233afaeSJohn W. De Boskeyone, ignoring partition
6639a9f19b1SRuslan Ermilov.Ql c .
6643233afaeSJohn W. De BoskeyFor partition
6659a9f19b1SRuslan Ermilov.Ql c ,
6667733674eSRuslan Ermilov.Cm *
6677733674eSRuslan Ermilovwill be interpreted as an offset of 0.
6689a9f19b1SRuslan Ermilov.It Ar fstype
6699a9f19b1SRuslan ErmilovDescribes the purpose of the partition.
6709a9f19b1SRuslan ErmilovThe example shows all currently used partition types.
6719a9f19b1SRuslan ErmilovFor
6729a9f19b1SRuslan Ermilov.Tn UFS
6739a9f19b1SRuslan Ermilovfile systems and
6749a9f19b1SRuslan Ermilov.Xr ccd 4
6759a9f19b1SRuslan Ermilovpartitions, use type
6767733674eSRuslan Ermilov.Cm 4.2BSD .
67770e48365SGreg LeheyFor Vinum drives, use type
67870e48365SGreg Lehey.Cm vinum .
6793233afaeSJohn W. De BoskeyOther common types are
6809a9f19b1SRuslan Ermilov.Cm swap
6813233afaeSJohn W. De Boskeyand
6829a9f19b1SRuslan Ermilov.Cm unused .
6832f1aba69SRuslan ErmilovBy convention, partition
6849a9f19b1SRuslan Ermilov.Ql c
6852f1aba69SRuslan Ermilovrepresents the entire slice and should be of type
68670e48365SGreg Lehey.Cm unused ,
68770e48365SGreg Leheythough
68870e48365SGreg Lehey.Nm
68970e48365SGreg Leheydoes not enforce this convention.
690e1205e80SPhilippe CharnierThe
69170e48365SGreg Lehey.Nm
692e1205e80SPhilippe Charnierutility
6939a9f19b1SRuslan Ermilovalso knows about a number of other partition types,
6949a9f19b1SRuslan Ermilovnone of which are in current use.
6959a9f19b1SRuslan Ermilov(See the definitions starting with
6962f1aba69SRuslan Ermilov.Dv FS_UNUSED
6972f1aba69SRuslan Ermilovin
6989a9f19b1SRuslan Ermilov.Aq Pa sys/disklabel.h
6999a9f19b1SRuslan Ermilovfor more details.)
7009a9f19b1SRuslan Ermilov.It Ar fsize
7013233afaeSJohn W. De BoskeyFor
7027733674eSRuslan Ermilov.Cm 4.2BSD
7039a9f19b1SRuslan Ermilovand
7049a9f19b1SRuslan Ermilov.Tn LFS
7059a9f19b1SRuslan Ermilovfile systems only, the fragment size.
7069a9f19b1SRuslan ErmilovDefaults to 1024 for partitions smaller than 1GB,
7079a9f19b1SRuslan Ermilov4096 for partitions 1GB or larger.
7089a9f19b1SRuslan Ermilov.It Ar bsize
7093233afaeSJohn W. De BoskeyFor
7107733674eSRuslan Ermilov.Cm 4.2BSD
7119a9f19b1SRuslan Ermilovand
7129a9f19b1SRuslan Ermilov.Tn LFS
7139a9f19b1SRuslan Ermilovfile systems only, the block size.
7149a9f19b1SRuslan ErmilovDefaults to 8192 for partitions smaller than 1GB,
7159a9f19b1SRuslan Ermilov16384 for partitions 1GB or larger.
7169a9f19b1SRuslan Ermilov.It Ar bps/cpg
7173233afaeSJohn W. De BoskeyFor
7187733674eSRuslan Ermilov.Cm 4.2BSD
7199a9f19b1SRuslan Ermilovfile systems, the number of cylinders in a cylinder group.
7209a9f19b1SRuslan ErmilovFor
7219a9f19b1SRuslan Ermilov.Tn LFS
7229a9f19b1SRuslan Ermilovfile systems, the segment shift value.
7239a9f19b1SRuslan ErmilovDefaults to 16 for partitions smaller than 1GB,
7249a9f19b1SRuslan Ermilov64 for partitions 1GB or larger.
7254cbdc634SGreg Lehey.El
726b60884cdSBen Smithurst.Pp
7274cbdc634SGreg LeheyThe remainder of the line is a comment and shows the cylinder allocations based
7284cbdc634SGreg Leheyon the obsolete (but possibly correct) geometry information about the drive.
7299a9f19b1SRuslan ErmilovThe asterisk
7309a9f19b1SRuslan Ermilov.Pq Ql *
7319a9f19b1SRuslan Ermilovindicates that the partition does not begin or end exactly on a
7324cbdc634SGreg Leheycylinder boundary.
7338fae3551SRodney W. Grimes.Sh EXAMPLES
7349a9f19b1SRuslan Ermilov.Dl "disklabel da0s1"
7358fae3551SRodney W. Grimes.Pp
7369a9f19b1SRuslan ErmilovDisplay the in-core label for the first slice of the
7379a9f19b1SRuslan Ermilov.Pa da0
7389a9f19b1SRuslan Ermilovdisk, as obtained via
739ff7d5162SJordan K. Hubbard.Pa /dev/da0s1 .
7409a9f19b1SRuslan Ermilov(If the disk is
7419a9f19b1SRuslan Ermilov.Dq dangerously-dedicated ,
7429a9f19b1SRuslan Ermilovthe base disk name should be specified, such as
7439a9f19b1SRuslan Ermilov.Pa da0 . )
7448fae3551SRodney W. Grimes.Pp
7459a9f19b1SRuslan Ermilov.Dl "disklabel da0s1 > savedlabel"
7464cbdc634SGreg Lehey.Pp
7474cbdc634SGreg LeheySave the in-core label for
748ff7d5162SJordan K. Hubbard.Pa da0s1
7494cbdc634SGreg Leheyinto the file
7504cbdc634SGreg Lehey.Pa savedlabel .
7514cbdc634SGreg LeheyThis file can be used with the
7524cbdc634SGreg Lehey.Fl R
7539a9f19b1SRuslan Ermilovoption to restore the label at a later date.
7544cbdc634SGreg Lehey.Pp
7559a9f19b1SRuslan Ermilov.Dl "disklabel -w -r /dev/da0s1 da2212 foo"
7568fae3551SRodney W. Grimes.Pp
7574cbdc634SGreg LeheyCreate a label for
758ff7d5162SJordan K. Hubbard.Pa da0s1
7594cbdc634SGreg Leheybased on information for
760726b61abSRuslan Ermilov.Dq da2212
761726b61abSRuslan Ermilovfound in
7628fae3551SRodney W. Grimes.Pa /etc/disktab .
7639a9f19b1SRuslan ErmilovAny existing bootstrap code will be clobbered
7649a9f19b1SRuslan Ermilovand the disk rendered unbootable.
7658fae3551SRodney W. Grimes.Pp
7669a9f19b1SRuslan Ermilov.Dl "disklabel -e -r da0s1"
7678fae3551SRodney W. Grimes.Pp
7684cbdc634SGreg LeheyRead the on-disk label for
769ff7d5162SJordan K. Hubbard.Pa da0s1 ,
7709a9f19b1SRuslan Ermilovedit it, and reinstall in-core as well as on-disk.
7719a9f19b1SRuslan ErmilovExisting bootstrap code is unaffected.
7728fae3551SRodney W. Grimes.Pp
7739a9f19b1SRuslan Ermilov.Dl "disklabel -e -r -n da0s1"
7743233afaeSJohn W. De Boskey.Pp
7753233afaeSJohn W. De BoskeyRead the on-disk label for
7763233afaeSJohn W. De Boskey.Pa da0s1 ,
7779a9f19b1SRuslan Ermilovedit it, and display what the new label would be (in sectors).
7789a9f19b1SRuslan ErmilovIt does
7799a9f19b1SRuslan Ermilov.Em not
7809a9f19b1SRuslan Ermilovinstall the new label either in-core or on-disk.
7813233afaeSJohn W. De Boskey.Pp
7829a9f19b1SRuslan Ermilov.Dl "disklabel -r -w da0s1 auto"
783425bed3aSJoerg Wunsch.Pp
7844cbdc634SGreg LeheyTry to auto-detect the required information from
785ff7d5162SJordan K. Hubbard.Pa da0s1 ,
7869a9f19b1SRuslan Ermilovand write a new label to the disk.
7879a9f19b1SRuslan ErmilovUse another
7889a9f19b1SRuslan Ermilov.Nm Fl e
7899a9f19b1SRuslan Ermilovcommand to edit the
790425bed3aSJoerg Wunschpartitioning and file system information.
791425bed3aSJoerg Wunsch.Pp
7929a9f19b1SRuslan Ermilov.Dl "disklabel -R da0s1 savedlabel"
7938fae3551SRodney W. Grimes.Pp
7944cbdc634SGreg LeheyRestore the on-disk and in-core label for
795ff7d5162SJordan K. Hubbard.Pa da0s1
7964cbdc634SGreg Leheyfrom information in
7974cbdc634SGreg Lehey.Pa savedlabel .
7988fae3551SRodney W. GrimesExisting bootstrap code is unaffected.
7998fae3551SRodney W. Grimes.Pp
8009a9f19b1SRuslan Ermilov.Dl "disklabel -R -n da0s1 label_layout"
8013233afaeSJohn W. De Boskey.Pp
8023233afaeSJohn W. De BoskeyDisplay what the label would be for
8033233afaeSJohn W. De Boskey.Pa da0s1
8043233afaeSJohn W. De Boskeyusing the partition layout in
8053233afaeSJohn W. De Boskey.Pa label_layout .
8063233afaeSJohn W. De BoskeyThis is useful for determining how much space would be alloted for various
8077733674eSRuslan Ermilovpartitions with a labelling scheme using
8087733674eSRuslan Ermilov.Cm % Ns -based
8097733674eSRuslan Ermilovor
8107733674eSRuslan Ermilov.Cm *
8117733674eSRuslan Ermilovpartition sizes.
8123233afaeSJohn W. De Boskey.Pp
8139a9f19b1SRuslan Ermilov.Dl "disklabel -B da0s1"
8148fae3551SRodney W. Grimes.Pp
8154cbdc634SGreg LeheyInstall a new bootstrap on
816ff7d5162SJordan K. Hubbard.Pa da0s1 .
8178fae3551SRodney W. GrimesThe boot code comes from
8188d48318bSPoul-Henning Kamp.Pa /boot/boot .
8198fae3551SRodney W. GrimesOn-disk and in-core labels are unchanged.
8208fae3551SRodney W. Grimes.Pp
8219a9f19b1SRuslan Ermilov.Dl "disklabel -w -B /dev/da0s1 -b newboot da2212"
8228fae3551SRodney W. Grimes.Pp
8238fae3551SRodney W. GrimesInstall a new label and bootstrap.
8249a9f19b1SRuslan ErmilovThe label is derived from
8259a9f19b1SRuslan Ermilov.Xr disktab 5
8269a9f19b1SRuslan Ermilovinformation for
8279a9f19b1SRuslan Ermilov.Dq da2212 ,
828726b61abSRuslan Ermilovand installed both in-core and on-disk.
8299a9f19b1SRuslan ErmilovThe bootstrap code comes from the file
8309a9f19b1SRuslan Ermilov.Pa newboot
8319a9f19b1SRuslan Ermilovin the current working directory.
8329a9f19b1SRuslan Ermilov.Bd -literal -offset indent
8339a9f19b1SRuslan Ermilovdd if=/dev/zero of=/dev/da0 bs=512 count=32
8349a9f19b1SRuslan Ermilovfdisk -BI da0
8359a9f19b1SRuslan Ermilovdd if=/dev/zero of=/dev/da0s1 bs=512 count=32
8369a9f19b1SRuslan Ermilovdisklabel -w -B da0s1 auto
8379a9f19b1SRuslan Ermilovdisklabel -e da0s1
8389a9f19b1SRuslan Ermilov.Ed
839ff7d5162SJordan K. Hubbard.Pp
840ff7d5162SJordan K. HubbardCompletely wipe any prior information on the disk, creating a new bootable
8419a9f19b1SRuslan Ermilovdisk with a
8429a9f19b1SRuslan Ermilov.Tn DOS
8439a9f19b1SRuslan Ermilovpartition table containing one slice, covering the whole disk.
8449a9f19b1SRuslan ErmilovInitialize the label on this slice,
8459a9f19b1SRuslan Ermilovthen edit it.
8469a9f19b1SRuslan ErmilovThe
8479a9f19b1SRuslan Ermilov.Xr dd 1
8489a9f19b1SRuslan Ermilovcommands are optional, but may be necessary for some
8499a9f19b1SRuslan Ermilov.Tn BIOS Ns es
8509a9f19b1SRuslan Ermilovto properly
851ff7d5162SJordan K. Hubbardrecognize the disk.
8523233afaeSJohn W. De Boskey.Pp
8533233afaeSJohn W. De BoskeyThis is an example disk label that uses some of the new partition size types
8547733674eSRuslan Ermilovsuch as
8557733674eSRuslan Ermilov.Cm % , M , G ,
8567733674eSRuslan Ermilovand
8577733674eSRuslan Ermilov.Cm * ,
8587733674eSRuslan Ermilovwhich could be used as a source file for
8599a9f19b1SRuslan Ermilov.Dq Li "disklabel -R ad0s1c new_label_file" :
8603233afaeSJohn W. De Boskey.Bd -literal -offset 4n
8613233afaeSJohn W. De Boskey# /dev/ad0s1c:
8623233afaeSJohn W. De Boskeytype: ESDI
8633233afaeSJohn W. De Boskeydisk: ad0s1
8643233afaeSJohn W. De Boskeylabel:
8653233afaeSJohn W. De Boskeyflags:
8663233afaeSJohn W. De Boskeybytes/sector: 512
8673233afaeSJohn W. De Boskeysectors/track: 63
8683233afaeSJohn W. De Boskeytracks/cylinder: 16
8693233afaeSJohn W. De Boskeysectors/cylinder: 1008
8703233afaeSJohn W. De Boskeycylinders: 40633
8713233afaeSJohn W. De Boskeysectors/unit: 40959009
8723233afaeSJohn W. De Boskeyrpm: 3600
8733233afaeSJohn W. De Boskeyinterleave: 1
8743233afaeSJohn W. De Boskeytrackskew: 0
8753233afaeSJohn W. De Boskeycylinderskew: 0
8763233afaeSJohn W. De Boskeyheadswitch: 0		# milliseconds
8773233afaeSJohn W. De Boskeytrack-to-track seek: 0	# milliseconds
8783233afaeSJohn W. De Boskeydrivedata: 0
8793233afaeSJohn W. De Boskey
8803233afaeSJohn W. De Boskey8 partitions:
8813233afaeSJohn W. De Boskey#        size   offset    fstype   [fsize bsize bps/cpg]
8823233afaeSJohn W. De Boskey  a:   400M        0    4.2BSD     4096 16384    75 	# (Cyl.    0 - 812*)
8833233afaeSJohn W. De Boskey  b:     1G        *      swap
8843233afaeSJohn W. De Boskey  c:      *        *    unused
8853233afaeSJohn W. De Boskey  e: 204800        *    4.2BSD
8863233afaeSJohn W. De Boskey  f:     5g        *    4.2BSD
8873233afaeSJohn W. De Boskey  g:      *        *    4.2BSD
8883233afaeSJohn W. De Boskey.Ed
8898fae3551SRodney W. Grimes.Sh SEE ALSO
89070e48365SGreg Lehey.Xr ccd 4 ,
8919a9f19b1SRuslan Ermilov.Xr md 4 ,
892af202156SWolfram Schneider.Xr disklabel 5 ,
8934cbdc634SGreg Lehey.Xr disktab 5 ,
894aa7c9adaSMike Pritchard.Xr boot0cfg 8 ,
89570e48365SGreg Lehey.Xr fdisk 8 ,
89670e48365SGreg Lehey.Xr vinum 8
8978fae3551SRodney W. Grimes.Sh DIAGNOSTICS
8988fae3551SRodney W. GrimesThe kernel device drivers will not allow the size of a disk partition
8998fae3551SRodney W. Grimesto be decreased or the offset of a partition to be changed while it is open.
9008fae3551SRodney W. GrimesSome device drivers create a label containing only a single large partition
9014cbdc634SGreg Leheyif a disk is unlabeled; thus, the label must be written to the
9029a9f19b1SRuslan Ermilov.Ql a
9039a9f19b1SRuslan Ermilovpartition of the disk while it is open.
9049a9f19b1SRuslan ErmilovThis sometimes requires the desired label to be set in two steps,
9059a9f19b1SRuslan Ermilovthe first one creating at least one other partition,
9069a9f19b1SRuslan Ermilovand the second one setting the label on the new partition
9079a9f19b1SRuslan Ermilovwhile shrinking the
9089a9f19b1SRuslan Ermilov.Ql a
9094cbdc634SGreg Leheypartition.
9108fae3551SRodney W. Grimes.Pp
9119a9f19b1SRuslan ErmilovOn some machines, the bootstrap code may not fit entirely in the area
9128fae3551SRodney W. Grimesallocated for it by some file systems.
9139a9f19b1SRuslan ErmilovAs a result,
9149a9f19b1SRuslan Ermilovit may not be possible to have file systems on some partitions of a
915726b61abSRuslan Ermilov.Dq bootable
916726b61abSRuslan Ermilovdisk.
9178fae3551SRodney W. GrimesWhen installing bootstrap code,
9186bd343a9SPhilippe Charnier.Nm
9198fae3551SRodney W. Grimeschecks for these cases.
9209a9f19b1SRuslan ErmilovIf the installed boot code would overlap a partition of type
9219a9f19b1SRuslan Ermilov.Dv FS_UNUSED ,
9229a9f19b1SRuslan Ermilovit is marked as type
9239a9f19b1SRuslan Ermilov.Dv FS_BOOT .
9248fae3551SRodney W. GrimesThe
9258fae3551SRodney W. Grimes.Xr newfs 8
9269a9f19b1SRuslan Ermilovutility will disallow creation of file systems on
9279a9f19b1SRuslan Ermilov.Dv FS_BOOT
9289a9f19b1SRuslan Ermilovpartitions.
9299a9f19b1SRuslan ErmilovConversely, if a partition has a type other than
9309a9f19b1SRuslan Ermilov.Dv FS_UNUSED
9319a9f19b1SRuslan Ermilovor
9329a9f19b1SRuslan Ermilov.Dv FS_BOOT ,
9336bd343a9SPhilippe Charnier.Nm
9348fae3551SRodney W. Grimeswill not install bootstrap code that overlaps it.
9358fae3551SRodney W. Grimes.Sh BUGS
9368fae3551SRodney W. GrimesWhen a disk name is given without a full pathname,
937726b61abSRuslan Ermilovthe constructed device name uses the
9389a9f19b1SRuslan Ermilov.Ql c
939726b61abSRuslan Ermilovpartition.
940d70e4e53SJoerg Wunsch.Pp
941d70e4e53SJoerg WunschFor the i386 architecture, the primary bootstrap sector contains
942d70e4e53SJoerg Wunschan embedded
943d70e4e53SJoerg Wunsch.Em fdisk
944d70e4e53SJoerg Wunschtable.
945e1205e80SPhilippe CharnierThe
946e1205e80SPhilippe Charnier.Nm
947e1205e80SPhilippe Charnierutility takes care to not clobber it when installing a bootstrap only
948d70e4e53SJoerg Wunsch.Pq Fl B ,
949d70e4e53SJoerg Wunschor when editing an existing label
950d70e4e53SJoerg Wunsch.Pq Fl e ,
951d70e4e53SJoerg Wunschbut it unconditionally writes the primary bootstrap program onto
952d70e4e53SJoerg Wunschthe disk for
953d70e4e53SJoerg Wunsch.Fl w
954d70e4e53SJoerg Wunschor
955d70e4e53SJoerg Wunsch.Fl R ,
956d70e4e53SJoerg Wunschthus replacing the
957d70e4e53SJoerg Wunsch.Em fdisk
9589a9f19b1SRuslan Ermilovtable by the dummy one in the bootstrap program.
9599a9f19b1SRuslan ErmilovThis is only of
960753d686dSRuslan Ermilovconcern if the disk is fully dedicated, so that the
9619a9f19b1SRuslan Ermilov.Fx
962753d686dSRuslan Ermilovdisk label
963d70e4e53SJoerg Wunschstarts at absolute block 0 on the disk.
9644cbdc634SGreg Lehey.Pp
965e1205e80SPhilippe CharnierThe
9664cbdc634SGreg Lehey.Nm
967e1205e80SPhilippe Charnierutility
9689a9f19b1SRuslan Ermilovdoes not perform all possible error checking.
9699a9f19b1SRuslan ErmilovWarning is given if partitions overlap,
9709a9f19b1SRuslan Ermilovif an absolute offset does not match the expected offset,
9719a9f19b1SRuslan Ermilovif the
9729a9f19b1SRuslan Ermilov.Ql c
9739a9f19b1SRuslan Ermilovpartition does not start at 0 or does not cover the entire slice,
9749a9f19b1SRuslan Ermilovif a partition runs past the end of the device,
9759a9f19b1SRuslan Ermilovand a number of other errors,
9769a9f19b1SRuslan Ermilovbut no warning is given if space remains unused.
977