2005-06-19 21:24:20 +04:00
|
|
|
.\" $NetBSD: disklabel.8,v 1.57 2005/06/19 17:24:20 wiz Exp $
|
1995-03-18 17:54:19 +03:00
|
|
|
.\"
|
1994-06-24 17:48:17 +04:00
|
|
|
.\" 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.
|
2003-08-07 14:04:11 +04:00
|
|
|
.\" 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.
|
|
|
|
.\"
|
1994-09-23 02:03:52 +04:00
|
|
|
.\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94
|
1993-03-22 11:04:00 +03:00
|
|
|
.\"
|
2005-06-18 01:20:18 +04:00
|
|
|
.Dd June 17, 2005
|
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
|
1994-06-24 17:48:17 +04:00
|
|
|
.Nm disklabel
|
1993-08-06 00:49:16 +04:00
|
|
|
.Nd read and write disk pack label
|
|
|
|
.Sh SYNOPSIS
|
2003-02-25 13:34:36 +03:00
|
|
|
.Nm
|
2004-03-20 21:51:06 +03:00
|
|
|
.Op Fl CFrt
|
1993-08-06 00:49:16 +04:00
|
|
|
.Ar disk
|
2003-02-25 13:34:36 +03:00
|
|
|
.Nm
|
1993-08-06 00:49:16 +04:00
|
|
|
.Fl w
|
2005-06-19 21:24:20 +04:00
|
|
|
.Op Fl \&Fr
|
1999-01-19 09:24:08 +03:00
|
|
|
.Op Fl f Ar disktab
|
1994-06-24 17:48:17 +04:00
|
|
|
.Ar disk Ar disktype
|
|
|
|
.Oo Ar packid Oc
|
2003-02-25 13:34:36 +03:00
|
|
|
.Nm
|
1993-08-06 00:49:16 +04:00
|
|
|
.Fl e
|
2004-03-20 21:51:06 +03:00
|
|
|
.Op Fl CFIr
|
1993-08-06 00:49:16 +04:00
|
|
|
.Ar disk
|
2003-02-25 13:34:36 +03:00
|
|
|
.Nm
|
1997-03-09 02:46:08 +03:00
|
|
|
.Fl i
|
2005-06-18 01:20:18 +04:00
|
|
|
.\" .Op Fl Fr - except Fr is treated as a macro :-(
|
2004-03-20 21:51:06 +03:00
|
|
|
.Op Fl FIr
|
1997-03-09 02:46:08 +03:00
|
|
|
.Ar disk
|
2003-02-25 13:34:36 +03:00
|
|
|
.Nm
|
1993-08-06 00:49:16 +04:00
|
|
|
.Fl R
|
2005-06-19 21:24:20 +04:00
|
|
|
.Op Fl \&Fr
|
1994-06-24 17:48:17 +04:00
|
|
|
.Ar disk Ar protofile
|
2003-02-25 13:34:36 +03:00
|
|
|
.Nm
|
1993-08-06 00:49:16 +04:00
|
|
|
.Op Fl NW
|
1994-06-24 17:48:17 +04:00
|
|
|
.Ar disk
|
1993-08-06 00:49:16 +04:00
|
|
|
.Sh DESCRIPTION
|
1997-09-14 12:50:16 +04:00
|
|
|
.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,
|
1994-06-24 17:48:17 +04:00
|
|
|
or to replace a damaged label.
|
1997-10-14 10:30:13 +04:00
|
|
|
.Pp
|
2004-03-20 21:51:06 +03:00
|
|
|
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.
|
1999-06-03 05:49:58 +04:00
|
|
|
Any special effects of the
|
1994-06-24 17:48:17 +04:00
|
|
|
.Fl r
|
1999-06-03 05:49:58 +04:00
|
|
|
flag are described with the affected commands.
|
1998-04-28 01:03:08 +04:00
|
|
|
.Pp
|
2003-05-02 12:09:35 +04:00
|
|
|
The
|
2004-03-19 21:22:31 +03:00
|
|
|
.Fl F
|
|
|
|
option indicates that
|
|
|
|
.Nm
|
|
|
|
should treat
|
2004-03-20 21:51:06 +03:00
|
|
|
.Ar disk
|
2004-03-19 21:22:31 +03:00
|
|
|
as if it is a regular file, instead of as if it is a block device,
|
|
|
|
for the purposes of reading and writing a disklabel.
|
|
|
|
.Pp
|
|
|
|
The
|
2003-05-02 12:09:35 +04:00
|
|
|
.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
|
1994-06-24 17:48:17 +04:00
|
|
|
The first form of the command (read) is used to examine the label on the named
|
2004-03-20 21:51:06 +03:00
|
|
|
disk drive (e.g.,
|
|
|
|
.Pa sd0
|
|
|
|
or
|
|
|
|
.Pa /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.
|
1996-10-02 17:49:44 +04:00
|
|
|
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
|
1997-09-14 12:50:16 +04:00
|
|
|
.Nm
|
2004-03-20 21:51:06 +03:00
|
|
|
are the drive to be labelled (e.g.,
|
|
|
|
.Pa sd0 ) ,
|
|
|
|
and 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.
|
1994-06-24 17:48:17 +04:00
|
|
|
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
|
1999-01-19 09:24:08 +03:00
|
|
|
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.
|
1994-06-24 17:48:17 +04:00
|
|
|
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.
|
1997-03-09 02:46:08 +03:00
|
|
|
.Pp
|
|
|
|
Labels can also created interactively using the
|
1998-01-01 07:47:05 +03:00
|
|
|
.Fl i
|
1997-03-09 02:46:08 +03:00
|
|
|
flag.
|
1998-01-01 07:47:05 +03:00
|
|
|
.Pp
|
1996-06-29 19:50:18 +04:00
|
|
|
The
|
|
|
|
.Fl C
|
|
|
|
flag causes the partition offset and size values to be displayed in
|
|
|
|
.Aq cylinder/track/sector
|
2002-09-28 04:24:13 +04:00
|
|
|
format.
|
|
|
|
Note that, regardless of whether
|
1996-06-29 19:50:18 +04:00
|
|
|
.Fl C
|
1997-07-02 07:19:09 +04:00
|
|
|
was specified, this format is always accepted by
|
1996-06-29 19:50:18 +04:00
|
|
|
.Nm
|
|
|
|
on input with either the
|
2001-11-16 14:30:09 +03:00
|
|
|
.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,
|
1997-09-14 12:50:16 +04:00
|
|
|
.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
|
1994-06-24 17:48:17 +04:00
|
|
|
.Ar \&#
|
1993-03-21 12:45:37 +03:00
|
|
|
and newline.
|
1993-08-06 00:49:16 +04:00
|
|
|
.Pp
|
1994-06-24 17:48:17 +04:00
|
|
|
The
|
1993-08-06 00:49:16 +04:00
|
|
|
.Fl NW
|
1994-06-24 17:48:17 +04:00
|
|
|
flags for
|
1997-09-14 12:50:16 +04:00
|
|
|
.Nm
|
1994-06-24 17:48:17 +04:00
|
|
|
explicitly disallow and
|
|
|
|
allow, respectively, writing of the pack label area on the selected disk.
|
2003-11-10 12:22:09 +03:00
|
|
|
.Pp
|
2005-06-18 01:20:18 +04:00
|
|
|
Previous versions of
|
2003-11-10 12:22:09 +03:00
|
|
|
.Nm
|
2005-06-18 01:20:18 +04:00
|
|
|
could update the bootstrap code on some architectures.
|
|
|
|
This functionality has been subsumed by
|
|
|
|
.Xr installboot 8 .
|
2004-05-29 00:46:52 +04:00
|
|
|
.Sh EXIT STATUS
|
|
|
|
The exit status of
|
|
|
|
.Nm
|
|
|
|
is set to indicate any errors or warnings.
|
|
|
|
The values used are:
|
|
|
|
.Bl -tag -width indent
|
|
|
|
.It 0
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility has completed successfully.
|
|
|
|
.It 1
|
|
|
|
A fatal error has occurred, such as unknown options passed on the command line,
|
|
|
|
or writing the disklabel failed.
|
|
|
|
.It 4
|
|
|
|
An I/O error of some sort occurred.
|
|
|
|
.It 101..n
|
|
|
|
One or more warnings occured while reading the disklabel.
|
|
|
|
Subtract 100 to get the number of warnings detected.
|
|
|
|
.El
|
1993-08-06 00:49:16 +04:00
|
|
|
.Sh FILES
|
2005-06-18 01:20:18 +04:00
|
|
|
.Bl -tag -width /etc/disktab -compact
|
1994-06-24 17:48:17 +04:00
|
|
|
.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
|
2002-09-28 04:24:13 +04:00
|
|
|
Create a label for sd0 based on information for
|
|
|
|
.Dq sd2212
|
|
|
|
found in
|
1996-01-16 09:41:20 +03:00
|
|
|
.Pa /etc/disktab ,
|
|
|
|
using
|
|
|
|
.Pa foo
|
|
|
|
as the disk pack label.
|
2002-09-28 04:24:13 +04:00
|
|
|
If you do not have an entry for your disk in
|
1996-01-16 09:41:20 +03:00
|
|
|
.Pa /etc/disktab ,
|
|
|
|
you can use this style to put
|
2002-09-28 04:24:13 +04:00
|
|
|
an initial label onto a new disk.
|
|
|
|
Then dump the label to a file (using
|
2002-02-08 04:21:55 +03:00
|
|
|
.Em disklabel sd0 \*[Gt]
|
1997-10-11 06:28:17 +04:00
|
|
|
.Em protofile ) ,
|
|
|
|
editing the file, and replacing the label with
|
|
|
|
.Em disklabel -R sd0
|
1996-01-16 09:41:20 +03:00
|
|
|
.Em protofile .
|
1994-06-24 17:48:17 +04:00
|
|
|
.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.
|
|
|
|
.Pp
|
2000-05-31 18:13:48 +04:00
|
|
|
.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
|
2000-10-09 03:32:50 +04:00
|
|
|
.Dl disklabel -i -I sd0
|
|
|
|
.Pp
|
|
|
|
As previous, only use the built-in interactive editor.
|
|
|
|
.Pp
|
1994-06-24 17:48:17 +04:00
|
|
|
.Dl disklabel -R sd0 mylabel
|
|
|
|
.Pp
|
|
|
|
Restore the on-disk and in-core label for sd0 from information in
|
|
|
|
.Pa mylabel .
|
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
|
2002-09-28 04:24:13 +04:00
|
|
|
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
|
2002-09-28 04:24:13 +04:00
|
|
|
while shrinking the
|
|
|
|
.Dq a
|
|
|
|
partition.
|
2001-11-16 14:30:09 +03:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr disklabel 5 ,
|
|
|
|
.Xr disktab 5 ,
|
2003-07-13 13:55:34 +04:00
|
|
|
.Xr dkctl 8 ,
|
2001-11-16 14:30:09 +03:00
|
|
|
.Xr fdisk 8 ,
|
|
|
|
.Xr installboot 8 ,
|
2004-03-19 00:13:19 +03:00
|
|
|
.Xr mbrlabel 8 ,
|
|
|
|
.Xr mscdlabel 8
|
1993-08-06 00:49:16 +04:00
|
|
|
.Sh BUGS
|
1996-10-02 17:49:44 +04:00
|
|
|
If the disk partition is not specified in the disk name
|
2002-09-28 04:24:13 +04:00
|
|
|
(i.e.,
|
|
|
|
.Dq xy0
|
|
|
|
instead of
|
|
|
|
.Dq /dev/rxy0c ) ,
|
1997-09-14 12:50:16 +04:00
|
|
|
.Nm
|
2002-09-28 04:24:13 +04:00
|
|
|
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.
|
1997-10-14 10:30:13 +04:00
|
|
|
.Pp
|
2002-09-28 04:24:13 +04:00
|
|
|
On the sparc, sparc64, sun2, and sun3
|
1997-10-14 10:30:13 +04:00
|
|
|
.Nx
|
|
|
|
systems, the size of each partition must be a multiple of the number
|
2002-09-28 04:24:13 +04:00
|
|
|
of sectors per cylinder (i.e., each partition must be an integer
|
1997-10-14 10:30:13 +04:00
|
|
|
number of cylinders), or the boot ROMs will declare the label
|
|
|
|
invalid and fail to boot the system.
|
1997-10-19 03:46:44 +04:00
|
|
|
.Pp
|
|
|
|
In addition, the
|
|
|
|
.Fl r
|
2002-09-28 04:24:13 +04:00
|
|
|
option should never be used on a sparc, sparc64, sun2 or sun3 system
|
2001-12-15 02:36:25 +03:00
|
|
|
boot disk - the
|
1997-10-19 03:46:44 +04:00
|
|
|
.Nx
|
|
|
|
kernel translates the
|
|
|
|
.Nx
|
|
|
|
disk label into a SunOS compatible format (which is required by the
|
2002-09-28 04:24:13 +04:00
|
|
|
boot PROMs) when it writes the label.
|
|
|
|
Using the
|
1997-10-19 03:46:44 +04:00
|
|
|
.Fl r
|
2002-09-28 04:24:13 +04:00
|
|
|
flag causes
|
1997-10-19 03:46:44 +04:00
|
|
|
.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.
|