xref: /csrg-svn/sbin/disklabel/disklabel.8 (revision 66985)
161480Sbostic.\" Copyright (c) 1987, 1988, 1991, 1993
261480Sbostic.\"	The Regents of the University of California.  All rights reserved.
331569Skarels.\"
435027Sbostic.\" This code is derived from software contributed to Berkeley by
535027Sbostic.\" Symmetric Computer Systems.
635027Sbostic.\"
755005Scael.\" %sccs.include.redist.roff%
831569Skarels.\"
9*66985Sbostic.\"	@(#)disklabel.8	8.2 (Berkeley) 04/19/94
1033521Sbostic.\"
1158603Smckusick.Dd ""
1255005Scael.Dt DISKLABEL 8
1355005Scael.Os BSD 4.2
1455005Scael.Sh NAME
1555005Scael.Nm disklabel
1655005Scael.Nd read and write disk pack label
1755005Scael.Sh SYNOPSIS
1855005Scael.Nm disklabel
1955005Scael.Op Fl r
2055005Scael.Ar disk
2155005Scael.Nm disklabel
2255005Scael.Fl w
2355005Scael.Op Fl r
2455005Scael.Ar disk Ar disktype
2558603Smckusick.Oo Ar packid Oc
2655005Scael.Nm disklabel
2755005Scael.Fl e
2855005Scael.Op Fl r
2955005Scael.Ar disk
3055005Scael.Nm disklabel
3155005Scael.Fl R
3255005Scael.Op Fl r
3355005Scael.Ar disk Ar protofile
3455005Scael.Nm disklabel
3555005Scael.Op Fl NW
3655005Scael.Ar disk
3758603Smckusick.sp
3858603Smckusick.Nm disklabel
3958603Smckusick.Fl B
4058603Smckusick.Oo
4158603Smckusick.Fl b Ar boot1
4258603Smckusick.Op Fl s Ar boot2
4358603Smckusick.Oc
4458603Smckusick.Ar disk
4558603Smckusick.Oo Ar disktype Oc
4658603Smckusick.Nm disklabel
4758603Smckusick.Fl w
4858603Smckusick.Fl B
4958603Smckusick.Oo
5058603Smckusick.Fl b Ar boot1
5158603Smckusick.Op Fl s Ar boot2
5258603Smckusick.Oc
5358603Smckusick.Ar disk Ar disktype
5458603Smckusick.Oo Ar packid Oc
5558603Smckusick.Nm disklabel
5658603Smckusick.Fl R
5758603Smckusick.Fl B
5858603Smckusick.Oo
5958603Smckusick.Fl b Ar boot1
6058603Smckusick.Op Fl s Ar boot2
6158603Smckusick.Oc
6258603Smckusick.Ar disk Ar protofile
6358603Smckusick.Oo Ar disktype Oc
6455005Scael.Sh DESCRIPTION
6555005Scael.Nm Disklabel
6631569Skarelscan be used to install, examine or modify the label on a disk drive or pack.
6731569SkarelsWhen writing the label, it can be used
6831569Skarelsto change the drive identification,
6931569Skarelsthe disk partitions on the drive,
7058603Smckusickor to replace a damaged label.
7158603SmckusickOn some systems,
7258603Smckusick.Nm disklabel
7358603Smckusickcan be used to install bootstrap code as well.
7458603SmckusickThere are several forms of the command that read (display), install or edit
7531622Skarelsthe label on a disk.
7631622SkarelsEach form has an additional option,
7755005Scael.Fl r ,
7831622Skarelswhich causes the label to be read from or written to the disk directly,
7931622Skarelsrather than going through the system's in-core copy of the label.
8033509SkarelsThis option may allow a label to be installed on a disk
8133509Skarelswithout kernel support for a label, such as when labels are first installed
8234729Skarelson a system; it must be used when first installing a label on a disk.
8358603SmckusickThe specific effect of
8458603Smckusick.Fl r
8558603Smckusickis described under each command.
8658603SmckusickThe read and install forms also support the
8758603Smckusick.Fl B
8858603Smckusickoption to install bootstrap code.
89*66985SbosticThese variants are described later.
9055005Scael.Pp
9158603SmckusickThe first form of the command (read) is used to examine the label on the named
9258603Smckusickdisk drive (e.g. sd0 or /dev/rsd0c).
9331569SkarelsIt will display all of the parameters associated with the drive
9431569Skarelsand its partition layout.
9534729SkarelsUnless the
9655005Scael.Fl r
9734729Skarelsflag is given,
9834729Skarelsthe kernel's in-core copy of the label is displayed;
9931569Skarelsif the disk has no label, or the partition types on the disk are incorrect,
10033509Skarelsthe kernel may have constructed or modified the label.
10131569SkarelsIf the
10255005Scael.Fl r
10331569Skarelsflag is given, the label from the raw disk will be displayed rather
10431569Skarelsthan the in-core label.
10555005Scael.Pp
10631569SkarelsThe second form of the command, with the
10755005Scael.Fl w
10831569Skarelsflag, is used to write a standard label on the designated drive.
10931569SkarelsThe required arguments to
11055005Scael.Nm disklabel
11158603Smckusickare the drive to be labelled (e.g. sd0), and
11231569Skarelsthe drive type as described in the
11355005Scael.Xr disktab 5
11431569Skarelsfile.
11531569SkarelsThe drive parameters and partitions are taken from that file.
11631569SkarelsIf different disks of the same physical type are to have different
11731569Skarelspartitions, it will be necessary to have separate disktab entries
11834729Skarelsdescribing each, or to edit the label after installation as described below.
11958603SmckusickThe optional argument is a pack identification string,
12034729Skarelsup to 16 characters long.
12131569SkarelsThe pack id must be quoted if it contains blanks.
12231569SkarelsIf the
12355005Scael.Fl r
12431569Skarelsflag is given, the disk sectors containing the label and bootstrap
12558603Smckusickwill be written directly.
12658603SmckusickA side-effect of this is that any existing bootstrap code will be overwritten
12758603Smckusickand the disk rendered unbootable.
12858603SmckusickIf
12958603Smckusick.Fl r
13058603Smckusickis not specified,
13158603Smckusickthe existing label will be updated via the in-core copy and any bootstrap
13258603Smckusickcode will be unaffected.
13333509SkarelsIf the disk does not already have a label, the
13455005Scael.Fl r
13533509Skarelsflag must be used.
13631569SkarelsIn either case, the kernel's in-core label is replaced.
13755005Scael.Pp
13831569SkarelsAn existing disk label may be edited by using the
13955005Scael.Fl e
14031569Skarelsflag.
14131569SkarelsThe label is read from the in-core kernel copy,
14231569Skarelsor directly from the disk if the
14355005Scael.Fl r
14431569Skarelsflag is also given.
14531569SkarelsThe label is formatted and then supplied to an editor for changes.
14655005ScaelIf no editor is specified in an
14755005Scael.Ev EDITOR
14855005Scaelenvironment variable,
14955005Scael.Xr vi 1
15031569Skarelsis used.
15131569SkarelsWhen the editor terminates, the formatted label is reread
15231569Skarelsand used to rewrite the disk label.
15358603SmckusickExisting bootstrap code is unchanged regardless of whether
15458603Smckusick.Fl r
15558603Smckusickwas specified.
15655005Scael.Pp
15733521SbosticWith the
15855005Scael.Fl R
15933509Skarelsflag,
16055005Scael.Nm disklabel
16131569Skarelsis capable of restoring a disk label that was formatted
16233509Skarelsin a prior operation and saved in an ascii file.
16334729SkarelsThe prototype file used to create the label should be in the same format
16434729Skarelsas that produced when reading or editing a label.
16534729SkarelsComments are delimited by
16655005Scael.Ar \&#
16734729Skarelsand newline.
16858603SmckusickAs with
16958603Smckusick.Fl w ,
17058603Smckusickany existing bootstrap code will be clobbered if
17155005Scael.Fl r
17258603Smckusickis specified and will be unaffected otherwise.
17355005Scael.Pp
17458603SmckusickThe
17555005Scael.Fl NW
17655005Scaelflags for
17755005Scael.Nm disklabel
17855005Scaelexplicitly disallow and
17933521Sbosticallow, respectively, writing of the pack label area on the selected disk.
18058603Smckusick.Pp
18158603SmckusickThe final three forms of
18258603Smckusick.Nm disklabel
18358603Smckusickare used to install boostrap code on machines where the bootstrap is part
18458603Smckusickof the label.
18558603SmckusickThe bootstrap code is comprised of one or two boot programs depending on
18658603Smckusickthe machine.
18758603SmckusickThe
18858603Smckusick.Fl B
18958603Smckusickoption is used to denote that bootstrap code is to be installed.
19058603SmckusickThe
19158603Smckusick.Fl r
19258603Smckusickflag is implied by
19358603Smckusick.Fl B
19458603Smckusickand never needs to be specified.
19558603SmckusickThe name of the boot program(s) to be installed can be selected in a
19658603Smckusickvariety of ways.
19758603SmckusickFirst, the names can be specified explicitly via the
19858603Smckusick.Fl b
19958603Smckusickand
20058603Smckusick.Fl s
20158603Smckusickflags.
20258603SmckusickOn machines with only a single level of boot program,
20358603Smckusick.Fl b
20458603Smckusickis the name of that program.
20558603SmckusickFor machines with a two-level bootstrap,
20658603Smckusick.Fl b
20758603Smckusickindicates the primary boot program and
20858603Smckusick.Fl s
20958603Smckusickthe secondary boot program.
21058603SmckusickIf the names are not explicitly given, standard boot programs will be used.
21158603SmckusickThe boot programs are located in
21258603Smckusick.Pa /usr/mdec .
21358603SmckusickThe names of the programs are taken from the ``b0'' and ``b1'' parameters
21458603Smckusickof the
21558603Smckusick.Xr disktab 5
21658603Smckusickentry for the disk if
21758603Smckusick.Ar disktype
21858603Smckusickwas given and its disktab entry exists and includes those parameters.
21958603SmckusickOtherwise, boot program names are derived from the name of the disk.
22058603SmckusickThese names are of the form
22158603Smckusick.Pa basename Ns boot
22258603Smckusickfor the primary (or only) bootstrap, and
22358603Smckusick.Pf boot Pa basename
22458603Smckusickfor the secondary bootstrap;
22558603Smckusickfor example,
22658603Smckusick.Pa /usr/mdec/sdboot
22758603Smckusickand
22858603Smckusick.Pa /usr/mdec/bootsd
22958603Smckusickif the disk device is
23058603Smckusick.Em sd0 .
23158603Smckusick.Pp
23258603SmckusickThe first of the three boot-installation forms is used to install
23358603Smckusickbootstrap code without changing the existing label.
23458603SmckusickIt is essentially a read command with respect to the disk label
23558603Smckusickitself and all options are related to the specification of the boot
23658603Smckusickprogram as described previously.
23758603SmckusickThe final two forms are analogous to the basic write and restore versions
23858603Smckusickexcept that they will install bootstrap code in addition to a new label.
23955005Scael.Sh FILES
24055005Scael.Bl -tag -width Pa -compact
24155005Scael.It Pa /etc/disktab
24255005Scael.It Pa /usr/mdec/ Ns Em xx Ns boot
24355005Scael.It Pa /usr/mdec/boot Ns Em xx
24455005Scael.El
24558603Smckusick.Sh EXAMPLES
24658603Smckusick.Dl disklabel sd0
24758603Smckusick.Pp
24858603SmckusickDisplay the in-core label for sd0 as obtained via
24958603Smckusick.Pa /dev/rsd0c .
25058603Smckusick.Pp
25158603Smckusick.Dl disklabel -w -r /dev/rsd0c sd2212 foo
25258603Smckusick.Pp
25358603SmckusickCreate a label for sd0 based on information for ``sd2212'' found in
25458603Smckusick.Pa /etc/disktab .
25558603SmckusickAny existing bootstrap code will be clobbered.
25658603Smckusick.Pp
25758603Smckusick.Dl disklabel -e -r sd0
25858603Smckusick.Pp
25958603SmckusickRead the on-disk label for sd0, edit it and reinstall in-core as well
26058603Smckusickas on-disk.
26158603SmckusickExisting bootstrap code is unaffected.
26258603Smckusick.Pp
26358603Smckusick.Dl disklabel -R sd0 mylabel
26458603Smckusick.Pp
26558603SmckusickRestore the on-disk and in-core label for sd0 from information in
26658603Smckusick.Pa mylabel .
26758603SmckusickExisting bootstrap code is unaffected.
26858603Smckusick.Pp
26958603Smckusick.Dl disklabel -B sd0
27058603Smckusick.Pp
27158603SmckusickInstall a new bootstrap on sd0.
27258603SmckusickThe boot code comes from
27358603Smckusick.Pa /usr/mdec/sdboot
27458603Smckusickand possibly
27558603Smckusick.Pa /usr/mdec/bootsd .
27658603SmckusickOn-disk and in-core labels are unchanged.
27758603Smckusick.Pp
27858603Smckusick.Dl disklabel -w -B /dev/rsd0c -b newboot sd2212
27958603Smckusick.Pp
28058603SmckusickInstall a new label and bootstrap.
28158603SmckusickThe label is derived from disktab information for ``sd2212'' and
28258603Smckusickinstalled both in-core and on-disk.
28358603SmckusickThe bootstrap code comes from the file
28458603Smckusick.Pa /usr/mdec/newboot .
28555005Scael.Sh SEE ALSO
28655005Scael.Xr disktab 5 ,
28755005Scael.Xr disklabel 5
28855005Scael.Sh DIAGNOSTICS
28934729SkarelsThe kernel device drivers will not allow the size of a disk partition
29034729Skarelsto be decreased or the offset of a partition to be changed while it is open.
29134729SkarelsSome device drivers create a label containing only a single large partition
29234729Skarelsif a disk is unlabeled; thus, the label must be written to the ``a''
29334729Skarelspartition of the disk while it is open.
29434729SkarelsThis sometimes requires the desired label to be set in two steps,
29534729Skarelsthe first one creating at least one other partition,
29634729Skarelsand the second setting the label on the new partition
29734729Skarelswhile shrinking the ``a'' partition.
29858603Smckusick.Pp
29958603SmckusickOn some machines the bootstrap code may not fit entirely in the area
30058603Smckusickallocated for it by some filesystems.
30158603SmckusickAs a result, it may not be possible to have filesystems on some partitions
30258603Smckusickof a ``bootable'' disk.
30358603SmckusickWhen installing bootstrap code,
30458603Smckusick.Nm disklabel
30558603Smckusickchecks for these cases.
30658603SmckusickIf the installed boot code would overlap a partition of type FS_UNUSED
30758603Smckusickit is marked as type FS_BOOT.
30858603SmckusickThe
30958603Smckusick.Xr newfs 8
31058603Smckusickutility will disallow creation of filesystems on FS_BOOT partitions.
31158603SmckusickConversely, if a partition has a type other than FS_UNUSED or FS_BOOT,
31258603Smckusick.Nm disklabel
31358603Smckusickwill not install bootstrap code that overlaps it.
31455005Scael.Sh BUGS
31534729SkarelsWhen a disk name is given without a full pathname,
31658603Smckusickthe constructed device name uses the ``a'' partition on the tahoe,
31758603Smckusickthe ``c'' partition on all others.
318