NetBSD/sbin/disklabel/disklabel.8

311 lines
8.7 KiB
Groff
Raw Normal View History

.\" $NetBSD: disklabel.8,v 1.48 2003/11/08 09:25:01 dsl Exp $
.\"
.\" Copyright (c) 1987, 1988, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
1993-03-21 12:45:37 +03:00
.\"
.\" This code is derived from software contributed to Berkeley by
.\" Symmetric Computer Systems.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. Neither the name of the University nor the names of its contributors
1993-03-21 12:45:37 +03:00
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94
1993-03-22 11:04:00 +03:00
.\"
.Dd November 8, 2003
1993-08-06 00:49:16 +04:00
.Dt DISKLABEL 8
2001-06-05 15:22:41 +04:00
.Os
1993-08-06 00:49:16 +04:00
.Sh NAME
.Nm disklabel
1993-08-06 00:49:16 +04:00
.Nd read and write disk pack label
.Sh SYNOPSIS
.Nm
.Op Fl rt
1998-01-01 07:51:54 +03:00
.Op Fl C
1993-08-06 00:49:16 +04:00
.Ar disk
.Nm
1993-08-06 00:49:16 +04:00
.Fl w
.Op Fl r
.Op Fl f Ar disktab
.Ar disk Ar disktype
.Oo Ar packid Oc
.Nm
1993-08-06 00:49:16 +04:00
.Fl e
.Op Fl r
.Op Fl I
1998-01-01 07:51:54 +03:00
.Op Fl C
1993-08-06 00:49:16 +04:00
.Ar disk
.Nm
.Fl i
.Op Fl I
.Op Fl r
.Ar disk
.Nm
1993-08-06 00:49:16 +04:00
.Fl R
.Op Fl r
.Ar disk Ar protofile
.Nm
1993-08-06 00:49:16 +04:00
.Op Fl NW
.Ar disk
1993-08-06 00:49:16 +04:00
.Sh DESCRIPTION
.Nm
1993-03-21 12:45:37 +03:00
can be used to install, examine or modify the label on a disk drive or pack.
When writing the label, it can be used
to change the drive identification,
the disk partitions on the drive,
or to replace a damaged label.
.Pp
There are several forms of the command that read (display), install or edit
1993-03-21 12:45:37 +03:00
the label on a disk.
Each form has an additional option,
1993-08-06 00:49:16 +04:00
.Fl r ,
1993-03-21 12:45:37 +03:00
which causes the label to be read from or written to the disk directly,
rather than going through the system's in-core copy of the label.
This option may allow a label to be installed on a disk
without kernel support for a label, such as when labels are first installed
on a system; it must be used when first installing a label on a disk.
Any special effects of the
.Fl r
flag are described with the affected commands.
.Pp
The
.Fl I
option is similar to the
.Fl r
option but provides defaults instead of failing with
an error, if there is no existing disklabel on the disk.
.Pp
The first form of the command (read) is used to examine the label on the named
disk drive (e.g., sd0 or /dev/rsd0c).
1993-03-21 12:45:37 +03:00
It will display all of the parameters associated with the drive
and its partition layout.
Unless the
1993-08-06 00:49:16 +04:00
.Fl r
1993-03-21 12:45:37 +03:00
flag is given,
the kernel's in-core copy of the label is displayed;
if the disk has no label, or the partition types on the disk are incorrect,
the kernel may have constructed or modified the label.
If the
1993-08-06 00:49:16 +04:00
.Fl r
1993-03-21 12:45:37 +03:00
flag is given, the label from the raw disk will be displayed rather
than the in-core label.
If the
.Fl t
flag is given, then the label will be formatted as a
.Xr disktab 5
entry.
1993-08-06 00:49:16 +04:00
.Pp
1993-03-21 12:45:37 +03:00
The second form of the command, with the
1993-08-06 00:49:16 +04:00
.Fl w
1993-03-21 12:45:37 +03:00
flag, is used to write a standard label on the designated drive.
The required arguments to
.Nm
are the drive to be labelled (e.g. sd0), and
1993-03-21 12:45:37 +03:00
the drive type as described in the
1993-08-06 00:49:16 +04:00
.Xr disktab 5
1993-03-21 12:45:37 +03:00
file.
The drive parameters and partitions are taken from that file.
If different disks of the same physical type are to have different
partitions, it will be necessary to have separate disktab entries
describing each, or to edit the label after installation as described below.
The optional argument is a pack identification string,
1993-03-21 12:45:37 +03:00
up to 16 characters long.
The pack id must be quoted if it contains blanks.
If the disk does not already have a label, the
1993-08-06 00:49:16 +04:00
.Fl r
1993-03-21 12:45:37 +03:00
flag must be used.
In either case, the kernel's in-core label is replaced.
1993-08-06 00:49:16 +04:00
.Pp
An alternate
.Xr disktab 5
file may be specified with the
.Fl f Ar disktab
option.
.Pp
1993-03-21 12:45:37 +03:00
An existing disk label may be edited by using the
1993-08-06 00:49:16 +04:00
.Fl e
1993-03-21 12:45:37 +03:00
flag.
The label is formatted and then supplied to an editor for changes.
If no editor is specified in an
.Ev EDITOR
environment variable,
1993-08-06 00:49:16 +04:00
.Xr vi 1
1993-03-21 12:45:37 +03:00
is used.
When the editor terminates, the formatted label is reread
and used to rewrite the disk label.
.Pp
Labels can also created interactively using the
.Fl i
flag.
.Pp
The
.Fl C
flag causes the partition offset and size values to be displayed in
.Aq cylinder/track/sector
format.
Note that, regardless of whether
.Fl C
was specified, this format is always accepted by
.Nm
on input with either the
.Fl e
or
.Fl R
flag.
1993-08-06 00:49:16 +04:00
.Pp
1993-03-21 12:45:37 +03:00
With the
1993-08-06 00:49:16 +04:00
.Fl R
1993-03-21 12:45:37 +03:00
flag,
.Nm
1993-03-21 12:45:37 +03:00
is capable of restoring a disk label that was formatted
in a prior operation and saved in an ascii file.
The prototype file used to create the label should be in the same format
as that produced when reading or editing a label.
Comments are delimited by
.Ar \&#
1993-03-21 12:45:37 +03:00
and newline.
1993-08-06 00:49:16 +04:00
.Pp
The
1993-08-06 00:49:16 +04:00
.Fl NW
flags for
.Nm
explicitly disallow and
allow, respectively, writing of the pack label area on the selected disk.
1993-08-06 00:49:16 +04:00
.Sh FILES
.Bl -tag -width /etc/disktab -compact
.It Pa /etc/disktab
.El
.Sh EXAMPLES
.Dl disklabel sd0
.Pp
Display the in-core label for sd0 as obtained via
.Pa /dev/rsd0c .
.Pp
.Dl disklabel -w -r /dev/rsd0c sd2212 foo
.Pp
Create a label for sd0 based on information for
.Dq sd2212
found in
.Pa /etc/disktab ,
using
.Pa foo
as the disk pack label.
If you do not have an entry for your disk in
.Pa /etc/disktab ,
you can use this style to put
an initial label onto a new disk.
Then dump the label to a file (using
.Em disklabel sd0 \*[Gt]
.Em protofile ) ,
editing the file, and replacing the label with
.Em disklabel -R sd0
.Em protofile .
.Pp
.Dl disklabel -e -r sd0
.Pp
Read the on-disk label for sd0, edit it and reinstall in-core as well
as on-disk.
Existing bootstrap code is unaffected.
.Pp
.Dl disklabel -e -I sd0
.Pp
As previous, but don't fail if there was no label on the disk yet;
provide some default values instead.
.Pp
.Dl disklabel -i -I sd0
.Pp
As previous, only use the built-in interactive editor.
.Pp
.Dl disklabel -R sd0 mylabel
.Pp
Restore the on-disk and in-core label for sd0 from information in
.Pa mylabel .
Existing bootstrap code is unaffected.
.Pp
.Dl disklabel -R -r sd0 \*[Lt]protofile\*[Gt]
.Pp
Install a new label on a disk, from a prototype label file.
This is a good way to install a label on a previously unlabeled
disk for which no entry appears in
.Pa /etc/disktab ,
if you create the
prototype file by dumping some other disk's label to a file and editing
it appropriately (total size, partition offsets, types, etc.)
1993-08-06 00:49:16 +04:00
.Sh DIAGNOSTICS
1993-03-21 12:45:37 +03:00
The kernel device drivers will not allow the size of a disk partition
to be decreased or the offset of a partition to be changed while it is open.
Some device drivers create a label containing only a single large partition
if a disk is unlabeled; thus, the label must be written to the
.Dq a
1993-03-21 12:45:37 +03:00
partition of the disk while it is open.
This sometimes requires the desired label to be set in two steps,
the first one creating at least one other partition,
and the second setting the label on the new partition
while shrinking the
.Dq a
partition.
.Pp
.Sh SEE ALSO
.Xr disklabel 5 ,
.Xr disktab 5 ,
2003-07-13 13:55:34 +04:00
.Xr dkctl 8 ,
.Xr fdisk 8 ,
.Xr installboot 8 ,
.Xr mbrlabel 8
1993-08-06 00:49:16 +04:00
.Sh BUGS
If the disk partition is not specified in the disk name
(i.e.,
.Dq xy0
instead of
.Dq /dev/rxy0c ) ,
.Nm
will construct the full pathname of the disk and use the
.Dq d
partition on i386, hpcmips, or arc, and the
.Dq c
partition on all others.
.Pp
On the sparc, sparc64, sun2, and sun3
.Nx
systems, the size of each partition must be a multiple of the number
of sectors per cylinder (i.e., each partition must be an integer
number of cylinders), or the boot ROMs will declare the label
invalid and fail to boot the system.
.Pp
In addition, the
.Fl r
option should never be used on a sparc, sparc64, sun2 or sun3 system
boot disk - the
.Nx
kernel translates the
.Nx
disk label into a SunOS compatible format (which is required by the
boot PROMs) when it writes the label.
Using the
.Fl r
flag causes
.Nm
to write directly to disk, and bypass the format translation.
This will result in a disk label that the PROMs will not recognize,
and that therefore cannot be booted from.