Annotation of src/sbin/disklabel/disklabel.8, Revision 1.30.2.2
1.30.2.2! jhawk 1: .\" $NetBSD: disklabel.8,v 1.30.2.1 2000/07/13 02:15:36 hubertf Exp $
1.9 cgd 2: .\"
1.7 hpeyerl 3: .\" Copyright (c) 1987, 1988, 1991, 1993
4: .\" The Regents of the University of California. All rights reserved.
1.1 cgd 5: .\"
6: .\" This code is derived from software contributed to Berkeley by
7: .\" Symmetric Computer Systems.
8: .\"
9: .\" Redistribution and use in source and binary forms, with or without
10: .\" modification, are permitted provided that the following conditions
11: .\" are met:
12: .\" 1. Redistributions of source code must retain the above copyright
13: .\" notice, this list of conditions and the following disclaimer.
14: .\" 2. Redistributions in binary form must reproduce the above copyright
15: .\" notice, this list of conditions and the following disclaimer in the
16: .\" documentation and/or other materials provided with the distribution.
17: .\" 3. All advertising materials mentioning features or use of this software
18: .\" must display the following acknowledgement:
19: .\" This product includes software developed by the University of
20: .\" California, Berkeley and its contributors.
21: .\" 4. Neither the name of the University nor the names of its contributors
22: .\" may be used to endorse or promote products derived from this software
23: .\" without specific prior written permission.
24: .\"
25: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28: .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35: .\" SUCH DAMAGE.
36: .\"
1.8 mycroft 37: .\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94
1.2 cgd 38: .\"
1.14 cgd 39: .Dd April 19, 1994
1.5 jtc 40: .Dt DISKLABEL 8
1.7 hpeyerl 41: .Os BSD 4.2
1.5 jtc 42: .Sh NAME
1.7 hpeyerl 43: .Nm disklabel
1.5 jtc 44: .Nd read and write disk pack label
45: .Sh SYNOPSIS
1.25 mycroft 46: .Nm ""
1.12 christos 47: .Op Fl rt
1.22 enami 48: .Op Fl C
1.5 jtc 49: .Ar disk
1.18 enami 50: .Nm ""
1.5 jtc 51: .Fl w
52: .Op Fl r
1.24 abs 53: .Op Fl f Ar disktab
1.7 hpeyerl 54: .Ar disk Ar disktype
55: .Oo Ar packid Oc
1.18 enami 56: .Nm ""
1.5 jtc 57: .Fl e
58: .Op Fl r
1.30.2.1 hubertf 59: .Op Fl I
1.22 enami 60: .Op Fl C
1.5 jtc 61: .Ar disk
1.18 enami 62: .Nm ""
1.30 fvdl 63: .Fl I
64: .Op Fl r
65: .Op Fl C
66: .Ar disk
67: .Nm ""
1.13 christos 68: .Fl i
69: .Op Fl r
70: .Ar disk
1.18 enami 71: .Nm ""
1.5 jtc 72: .Fl R
1.7 hpeyerl 73: .Op Fl r
74: .Ar disk Ar protofile
1.18 enami 75: .Nm ""
1.7 hpeyerl 76: .Op Fl NW
1.5 jtc 77: .Ar disk
1.7 hpeyerl 78: .sp
1.18 enami 79: .Nm ""
1.7 hpeyerl 80: .Fl B
1.24 abs 81: .Op Fl f Ar disktab
1.7 hpeyerl 82: .Oo
83: .Fl b Ar boot1
84: .Op Fl s Ar boot2
85: .Oc
86: .Ar disk
87: .Oo Ar disktype Oc
1.18 enami 88: .Nm ""
1.7 hpeyerl 89: .Fl w
90: .Fl B
1.24 abs 91: .Op Fl f Ar disktab
1.7 hpeyerl 92: .Oo
93: .Fl b Ar boot1
94: .Op Fl s Ar boot2
95: .Oc
96: .Ar disk Ar disktype
97: .Oo Ar packid Oc
1.18 enami 98: .Nm ""
1.7 hpeyerl 99: .Fl R
100: .Fl B
1.24 abs 101: .Op Fl f Ar disktab
1.7 hpeyerl 102: .Oo
103: .Fl b Ar boot1
104: .Op Fl s Ar boot2
105: .Oc
106: .Ar disk Ar protofile
107: .Oo Ar disktype Oc
1.5 jtc 108: .Sh DESCRIPTION
1.16 lukem 109: .Nm
1.1 cgd 110: can be used to install, examine or modify the label on a disk drive or pack.
111: When writing the label, it can be used
112: to change the drive identification,
113: the disk partitions on the drive,
1.7 hpeyerl 114: or to replace a damaged label.
115: On some systems,
1.16 lukem 116: .Nm
1.7 hpeyerl 117: can be used to install bootstrap code as well.
1.19 fair 118: .Pp
1.7 hpeyerl 119: There are several forms of the command that read (display), install or edit
1.1 cgd 120: the label on a disk.
121: Each form has an additional option,
1.5 jtc 122: .Fl r ,
1.1 cgd 123: which causes the label to be read from or written to the disk directly,
124: rather than going through the system's in-core copy of the label.
125: This option may allow a label to be installed on a disk
126: without kernel support for a label, such as when labels are first installed
127: on a system; it must be used when first installing a label on a disk.
1.27 cgd 128: Any special effects of the
1.7 hpeyerl 129: .Fl r
1.27 cgd 130: flag are described with the affected commands.
1.23 fair 131: .Pp
1.7 hpeyerl 132: The read and install forms also support the
133: .Fl B
1.23 fair 134: option to install bootstrap code on some platforms,
135: e.g. hp300, vax, and arm32.
136: The
137: .Fl B
138: option is not supported on all platforms.
1.8 mycroft 139: These variants are described later.
1.5 jtc 140: .Pp
1.7 hpeyerl 141: The first form of the command (read) is used to examine the label on the named
142: disk drive (e.g. sd0 or /dev/rsd0c).
1.1 cgd 143: It will display all of the parameters associated with the drive
144: and its partition layout.
145: Unless the
1.5 jtc 146: .Fl r
1.1 cgd 147: flag is given,
148: the kernel's in-core copy of the label is displayed;
149: if the disk has no label, or the partition types on the disk are incorrect,
150: the kernel may have constructed or modified the label.
151: If the
1.5 jtc 152: .Fl r
1.1 cgd 153: flag is given, the label from the raw disk will be displayed rather
154: than the in-core label.
1.12 christos 155: If the
156: .Fl t
157: flag is given, then the label will be formatted as a
158: .Xr disktab 5
159: entry.
1.5 jtc 160: .Pp
1.1 cgd 161: The second form of the command, with the
1.5 jtc 162: .Fl w
1.1 cgd 163: flag, is used to write a standard label on the designated drive.
164: The required arguments to
1.16 lukem 165: .Nm
1.7 hpeyerl 166: are the drive to be labelled (e.g. sd0), and
1.1 cgd 167: the drive type as described in the
1.5 jtc 168: .Xr disktab 5
1.1 cgd 169: file.
170: The drive parameters and partitions are taken from that file.
171: If different disks of the same physical type are to have different
172: partitions, it will be necessary to have separate disktab entries
173: describing each, or to edit the label after installation as described below.
1.7 hpeyerl 174: The optional argument is a pack identification string,
1.1 cgd 175: up to 16 characters long.
176: The pack id must be quoted if it contains blanks.
177: If the disk does not already have a label, the
1.5 jtc 178: .Fl r
1.1 cgd 179: flag must be used.
180: In either case, the kernel's in-core label is replaced.
1.24 abs 181: .Pp
182: An alternate
183: .Xr disktab 5
184: file may be specified with the
185: .Fl f Ar disktab
186: option.
1.5 jtc 187: .Pp
1.1 cgd 188: An existing disk label may be edited by using the
1.5 jtc 189: .Fl e
1.1 cgd 190: flag.
191: The label is formatted and then supplied to an editor for changes.
1.7 hpeyerl 192: If no editor is specified in an
193: .Ev EDITOR
194: environment variable,
1.5 jtc 195: .Xr vi 1
1.1 cgd 196: is used.
197: When the editor terminates, the formatted label is reread
198: and used to rewrite the disk label.
1.13 christos 199: .Pp
200: Labels can also created interactively using the
1.21 enami 201: .Fl i
1.13 christos 202: flag.
1.21 enami 203: .Pp
1.11 pk 204: The
205: .Fl C
206: flag causes the partition offset and size values to be displayed in
207: .Aq cylinder/track/sector
208: format. Note that, regardless of whether
209: .Fl C
1.15 mikel 210: was specified, this format is always accepted by
1.11 pk 211: .Nm
212: on input with either the
213: .Fl e No or Fl R No flag.
1.5 jtc 214: .Pp
1.1 cgd 215: With the
1.5 jtc 216: .Fl R
1.1 cgd 217: flag,
1.16 lukem 218: .Nm
1.1 cgd 219: is capable of restoring a disk label that was formatted
220: in a prior operation and saved in an ascii file.
221: The prototype file used to create the label should be in the same format
222: as that produced when reading or editing a label.
223: Comments are delimited by
1.7 hpeyerl 224: .Ar \&#
1.1 cgd 225: and newline.
1.5 jtc 226: .Pp
1.7 hpeyerl 227: The
1.5 jtc 228: .Fl NW
1.7 hpeyerl 229: flags for
1.16 lukem 230: .Nm
1.7 hpeyerl 231: explicitly disallow and
232: allow, respectively, writing of the pack label area on the selected disk.
233: .Pp
234: The final three forms of
1.16 lukem 235: .Nm
1.30.2.2! jhawk 236: are used to install bootstrap code on machines where the bootstrap is part
1.7 hpeyerl 237: of the label.
1.29 hubertf 238: The bootstrap code is composed of one or two boot programs depending on
1.7 hpeyerl 239: the machine.
240: The
241: .Fl B
242: option is used to denote that bootstrap code is to be installed.
243: The
244: .Fl r
245: flag is implied by
246: .Fl B
247: and never needs to be specified.
248: The name of the boot program(s) to be installed can be selected in a
249: variety of ways.
250: First, the names can be specified explicitly via the
251: .Fl b
252: and
253: .Fl s
254: flags.
255: On machines with only a single level of boot program,
256: .Fl b
257: is the name of that program.
258: For machines with a two-level bootstrap,
259: .Fl b
260: indicates the primary boot program and
261: .Fl s
262: the secondary boot program.
263: If the names are not explicitly given, standard boot programs will be used.
264: The boot programs are located in
265: .Pa /usr/mdec .
266: The names of the programs are taken from the ``b0'' and ``b1'' parameters
267: of the
268: .Xr disktab 5
269: entry for the disk if
270: .Ar disktype
271: was given and its disktab entry exists and includes those parameters.
272: Otherwise, boot program names are derived from the name of the disk.
273: These names are of the form
274: .Pa basename Ns boot
275: for the primary (or only) bootstrap, and
276: .Pf boot Pa basename
277: for the secondary bootstrap;
278: for example,
279: .Pa /usr/mdec/sdboot
280: and
281: .Pa /usr/mdec/bootsd
282: if the disk device is
283: .Em sd0 .
284: .Pp
285: The first of the three boot-installation forms is used to install
286: bootstrap code without changing the existing label.
287: It is essentially a read command with respect to the disk label
288: itself and all options are related to the specification of the boot
289: program as described previously.
290: The final two forms are analogous to the basic write and restore versions
291: except that they will install bootstrap code in addition to a new label.
1.5 jtc 292: .Sh FILES
1.7 hpeyerl 293: .Bl -tag -width Pa -compact
294: .It Pa /etc/disktab
295: .It Pa /usr/mdec/ Ns Em xx Ns boot
296: .It Pa /usr/mdec/boot Ns Em xx
297: .El
298: .Sh EXAMPLES
299: .Dl disklabel sd0
300: .Pp
301: Display the in-core label for sd0 as obtained via
302: .Pa /dev/rsd0c .
303: .Pp
304: .Dl disklabel -w -r /dev/rsd0c sd2212 foo
305: .Pp
306: Create a label for sd0 based on information for ``sd2212'' found in
1.10 hpeyerl 307: .Pa /etc/disktab ,
308: using
309: .Pa foo
310: as the disk pack label.
311: Any existing bootstrap code will be clobbered. If you do not have an
312: entry for your disk in
313: .Pa /etc/disktab ,
314: you can use this style to put
315: an initial label onto a new disk. Then dump the label to a file (using
1.18 enami 316: .Em disklabel sd0 >
317: .Em protofile ) ,
318: editing the file, and replacing the label with
319: .Em disklabel -R sd0
1.10 hpeyerl 320: .Em protofile .
1.7 hpeyerl 321: .Pp
322: .Dl disklabel -e -r sd0
323: .Pp
324: Read the on-disk label for sd0, edit it and reinstall in-core as well
325: as on-disk.
326: Existing bootstrap code is unaffected.
1.30 fvdl 327: .Pp
328: .Dl disklabel -e -I sd0
329: .Pp
330: As previous, but don't fail if there was no label on the disk yet;
331: provide some default values instead.
1.7 hpeyerl 332: .Pp
333: .Dl disklabel -R sd0 mylabel
334: .Pp
335: Restore the on-disk and in-core label for sd0 from information in
336: .Pa mylabel .
337: Existing bootstrap code is unaffected.
338: .Pp
339: .Dl disklabel -B sd0
340: .Pp
341: Install a new bootstrap on sd0.
342: The boot code comes from
343: .Pa /usr/mdec/sdboot
344: and possibly
345: .Pa /usr/mdec/bootsd .
346: On-disk and in-core labels are unchanged.
347: .Pp
348: .Dl disklabel -w -B /dev/rsd0c -b newboot sd2212
349: .Pp
350: Install a new label and bootstrap.
351: The label is derived from disktab information for ``sd2212'' and
352: installed both in-core and on-disk.
353: The bootstrap code comes from the file
354: .Pa /usr/mdec/newboot .
1.10 hpeyerl 355: .Pp
356: .Dl disklabel -R -r sd0 <protofile>
357: .Pp
358: Install a new label and bootstrap on a disk, from a prototype label
359: file. This is a good way to install a label on a previously unlabeled
360: disk for which no entry appears in
361: .Pa /etc/disktab ,
362: if you create the
363: prototype file by dumping some other disk's label to a file and editing
364: it appropriately (total size, partition offsets, types, etc.)
1.5 jtc 365: .Sh SEE ALSO
366: .Xr disktab 5 ,
1.16 lukem 367: .Xr disklabel 5 ,
368: .Xr installboot 8
1.5 jtc 369: .Sh DIAGNOSTICS
1.1 cgd 370: The kernel device drivers will not allow the size of a disk partition
371: to be decreased or the offset of a partition to be changed while it is open.
372: Some device drivers create a label containing only a single large partition
1.7 hpeyerl 373: if a disk is unlabeled; thus, the label must be written to the ``a''
1.1 cgd 374: partition of the disk while it is open.
375: This sometimes requires the desired label to be set in two steps,
376: the first one creating at least one other partition,
377: and the second setting the label on the new partition
1.7 hpeyerl 378: while shrinking the ``a'' partition.
379: .Pp
380: On some machines the bootstrap code may not fit entirely in the area
381: allocated for it by some filesystems.
382: As a result, it may not be possible to have filesystems on some partitions
383: of a ``bootable'' disk.
384: When installing bootstrap code,
1.16 lukem 385: .Nm
1.7 hpeyerl 386: checks for these cases.
387: If the installed boot code would overlap a partition of type FS_UNUSED
388: it is marked as type FS_BOOT.
389: The
390: .Xr newfs 8
391: utility will disallow creation of filesystems on FS_BOOT partitions.
392: Conversely, if a partition has a type other than FS_UNUSED or FS_BOOT,
1.16 lukem 393: .Nm
1.7 hpeyerl 394: will not install bootstrap code that overlaps it.
1.5 jtc 395: .Sh BUGS
1.12 christos 396: If the disk partition is not specified in the disk name
397: (i.e. ``xy0'' instead of ``/dev/rxy0c''),
1.16 lukem 398: .Nm
1.12 christos 399: will construct the full pathname of the disk and use
400: the ``a'' partition on the tahoe,
1.28 soda 401: the ``d'' partition on i386 or hpcmips or arc, and
402: the ``c'' partition on all others.
1.19 fair 403: .Pp
1.26 kleink 404: On the sparc, sparc64 and sun3
1.19 fair 405: .Nx
406: systems, the size of each partition must be a multiple of the number
407: of sectors per cylinder (i.e. each partition must be an integer
408: number of cylinders), or the boot ROMs will declare the label
409: invalid and fail to boot the system.
1.20 fair 410: .Pp
411: In addition, the
412: .Fl r
1.26 kleink 413: option should never be used on a sparc, sparc64 or sun3 system boot disk - the
1.20 fair 414: .Nx
415: kernel translates the
416: .Nx
417: disk label into a SunOS compatible format (which is required by the
418: boot PROMs) when it writes the label. Using the
419: .Fl r
420: causes
421: .Nm
422: to write directly to disk, and bypass the format translation.
423: This will result in a disk label that the PROMs will not recognize,
424: and that therefore cannot be booted from.
CVSweb <webmaster@jp.NetBSD.org>