More axe-work:
Hide all the historical fields of the label, unless people ask for them with -A, set them to intelligently chosen defaults otherwise. Distill the manual page to remove inaccuracies, misundertandings and obsolete information. It can probably still be done better but now at least it is not misinforming people.
This commit is contained in:
parent
5916c8dcad
commit
a3b8d0b40b
@ -43,93 +43,37 @@
|
||||
.Nd read and write disk pack label
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl r
|
||||
.Op Fl A
|
||||
.Ar disk
|
||||
.Nm
|
||||
.Fl w
|
||||
.Op Fl nr
|
||||
.Op Fl nA
|
||||
.Op Fl B Op Fl b Ar boot
|
||||
.Op Fl m Ar machine
|
||||
.Ar disk type
|
||||
.Op Ar packid
|
||||
.Ar disk
|
||||
.Op Ar type
|
||||
.Nm
|
||||
.Fl e
|
||||
.Op Fl nr
|
||||
.Op Fl nA
|
||||
.Op Fl B Op Fl b Ar boot
|
||||
.Op Fl m Ar machine
|
||||
.Ar disk
|
||||
.Nm
|
||||
.Fl R
|
||||
.Op Fl nr
|
||||
.Op Fl nA
|
||||
.Op Fl B Op Fl b Ar boot
|
||||
.Op Fl m Ar machine
|
||||
.Ar disk protofile
|
||||
.Pp
|
||||
.Nm
|
||||
.Fl B
|
||||
.Op Fl b Ar boot
|
||||
.Op Fl m Ar machine
|
||||
.Ar disk
|
||||
.Nm
|
||||
.Fl w B
|
||||
.Op Fl n
|
||||
.Op Fl b Ar boot
|
||||
.Op Fl m Ar machine
|
||||
.Ar disk type
|
||||
.Op Ar packid
|
||||
.Nm
|
||||
.Fl R B
|
||||
.Op Fl n
|
||||
.Op Fl b Ar boot
|
||||
.Op Fl m Ar machine
|
||||
.Ar disk protofile
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility
|
||||
installs, examines or modifies 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.
|
||||
There are several forms
|
||||
of the command that read (display), install, or edit the label on a disk.
|
||||
installs, examines or modifies the BSD label on a disk partition.
|
||||
In addition,
|
||||
.Nm
|
||||
can install bootstrap code.
|
||||
.Ss Raw or In-Core Label
|
||||
The disk label resides close to or at the beginning of each disk slice.
|
||||
For faster access, the kernel maintains a copy in core at all times.
|
||||
By default, most
|
||||
.Nm
|
||||
access the in-core copy of the label.
|
||||
To access the raw (on-disk) copy, use the
|
||||
.Fl r
|
||||
option.
|
||||
This option allows 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.
|
||||
The specific effect of
|
||||
.Fl r
|
||||
is described under each command.
|
||||
.Ss Disk Device Name
|
||||
All
|
||||
.Nm
|
||||
forms require a disk device name, which should always be the raw
|
||||
device name representing the disk or slice.
|
||||
For example,
|
||||
.Pa da0
|
||||
represents the entire disk regardless of any
|
||||
.Tn DOS
|
||||
partitioning,
|
||||
and
|
||||
.Pa da0s1
|
||||
represents a slice.
|
||||
Some devices, most notably
|
||||
.Xr ccd 4 ,
|
||||
require that the
|
||||
.Dq whole-disk
|
||||
(or
|
||||
.Ql c )
|
||||
partition be specified.
|
||||
For example,
|
||||
.Pa ccd0c .
|
||||
When specifying the device,
|
||||
the
|
||||
.Pa /dev/
|
||||
@ -137,192 +81,70 @@ path prefix may be omitted;
|
||||
the
|
||||
.Nm
|
||||
utility will automatically prepend it.
|
||||
.Ss General options
|
||||
The
|
||||
.Fl A
|
||||
option enables processing of the historical parts of the BSD label.
|
||||
If the option is not given, suitable values are set for these fields.
|
||||
.Pp
|
||||
The
|
||||
.Fl n
|
||||
stops the
|
||||
.Nm
|
||||
program right before the disk would have been modified, and displays
|
||||
the result instead of writing it.
|
||||
.Pp
|
||||
The
|
||||
.Fl m Ar machine
|
||||
argument instructs
|
||||
.Nm
|
||||
to use the layout suitable for the specified machine.
|
||||
.Ss Reading the Disk Label
|
||||
To examine the label on a disk drive, use
|
||||
.Nm
|
||||
without options:
|
||||
.Pp
|
||||
.Nm
|
||||
.Op Fl r
|
||||
.Op Fl A
|
||||
.Op Fl m Ar machine
|
||||
.Ar disk
|
||||
.Pp
|
||||
.Ar disk
|
||||
represents the raw disk in question, and may be in the form
|
||||
represents the disk in question, and may be in the form
|
||||
.Pa da0
|
||||
or
|
||||
.Pa /dev/da0c .
|
||||
It will display all of the parameters associated with the drive and its
|
||||
partition layout.
|
||||
Unless the
|
||||
.Fl r
|
||||
option 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
|
||||
.Fl r
|
||||
option is given,
|
||||
.Nm
|
||||
reads the label from the raw disk and displays it.
|
||||
Both versions are usually
|
||||
identical except in the case where a label has not yet been initialized or
|
||||
is corrupt.
|
||||
.Pa /dev/da0 .
|
||||
It will display the partition layout.
|
||||
.Ss Writing a Standard Label
|
||||
To write a standard label, use the form
|
||||
.Pp
|
||||
.Nm
|
||||
.Fl w
|
||||
.Op Fl nr
|
||||
.Op Fl nA
|
||||
.Op Fl m Ar machine
|
||||
.Ar disk type
|
||||
.Op Ar packid
|
||||
.Pp
|
||||
The required arguments to
|
||||
.Nm
|
||||
are the drive to be labeled, and the drive type as described in the
|
||||
.Xr disktab 5
|
||||
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
|
||||
.Xr disktab 5
|
||||
entries describing each, or to edit
|
||||
the label after installation as described below.
|
||||
The optional argument is a
|
||||
pack identification string, up to 16 characters long.
|
||||
The
|
||||
.Ar packid
|
||||
must be quoted if it contains blanks.
|
||||
.Pp
|
||||
If the
|
||||
.Fl m
|
||||
option is given, then label will be written so that
|
||||
it is understood by the target
|
||||
.Ar machine ;
|
||||
defaults to the current hardware architecture.
|
||||
.Pp
|
||||
If
|
||||
.Fl n
|
||||
is used, no data will be written to the device, and instead the
|
||||
disk label that would have been written will be printed to standard output.
|
||||
.Pp
|
||||
If the
|
||||
.Fl r
|
||||
option is given, the disk sectors containing the label and bootstrap
|
||||
will be written directly.
|
||||
A side-effect of this is that any existing bootstrap code will be overwritten
|
||||
and the disk rendered unbootable.
|
||||
See the boot options below for a method of
|
||||
writing the and the bootstrap at the same time.
|
||||
If
|
||||
.Fl r
|
||||
is not specified,
|
||||
the existing label will be updated via the in-core copy, and any bootstrap
|
||||
code will be unaffected.
|
||||
If the disk does not already have a label, the
|
||||
.Fl r
|
||||
option must be used.
|
||||
In either case, the kernel's in-core label is replaced.
|
||||
.Pp
|
||||
For a virgin disk that is not known to
|
||||
.Xr disktab 5 ,
|
||||
.Ar type
|
||||
can be specified as
|
||||
.Cm auto .
|
||||
In this case, the driver is requested to produce a virgin label for the
|
||||
disk.
|
||||
This might or might not be successful, depending on whether the
|
||||
driver for the disk is able to get the required data without reading
|
||||
anything from the disk at all.
|
||||
It will likely succeed for all
|
||||
.Tn SCSI
|
||||
disks, most
|
||||
.Tn IDE
|
||||
disks, and
|
||||
.Cm vnode
|
||||
type memory disks
|
||||
.Pq Xr md 4 .
|
||||
Writing a label to the
|
||||
disk is the only supported operation, and the
|
||||
.Ar disk
|
||||
itself must be provided as the canonical name, i.e., not as a full
|
||||
path name.
|
||||
.Op Ar type
|
||||
.Pp
|
||||
For most harddisks, a label based on percentages for most partitions (and
|
||||
one partition with a size of
|
||||
.Ql * )
|
||||
will produce a reasonable configuration.
|
||||
.Pp
|
||||
PC-based systems have special requirements in order for the
|
||||
.Tn BIOS
|
||||
to properly recognize a
|
||||
.Fx
|
||||
disk label.
|
||||
Older systems may require what is known as a
|
||||
.Dq dangerously-dedicated
|
||||
disk label, which creates a fake
|
||||
.Tn DOS
|
||||
partition to work around problems older
|
||||
.Tn BIOS Ns es
|
||||
have with modern disk geometries.
|
||||
On newer systems, a normal
|
||||
.Tn DOS
|
||||
partition should generally be created using
|
||||
.Xr fdisk 8 ,
|
||||
and then a
|
||||
.Fx
|
||||
disk label within that slice.
|
||||
This is described later on in this page.
|
||||
.Pp
|
||||
Installing a new disk label does not in of itself allow the system to boot
|
||||
a kernel using that label.
|
||||
Boot blocks must also be installed, which is
|
||||
described later on in this manual page.
|
||||
If the drive type if specified the entry of that name in the
|
||||
.Xr disktab 5
|
||||
file is used, otherwise a default layout is used.
|
||||
.Ss Editing an Existing Disk Label
|
||||
To edit an existing disk label, use the form
|
||||
.Pp
|
||||
.Nm
|
||||
.Fl e
|
||||
.Op Fl nr
|
||||
.Op Fl nA
|
||||
.Op Fl m Ar machine
|
||||
.Ar disk
|
||||
.Pp
|
||||
This command reads the label from the in-core kernel copy, or directly from the
|
||||
disk if the
|
||||
.Fl r
|
||||
option is also specified.
|
||||
The label is written to a file in
|
||||
.Tn ASCII
|
||||
format, and then supplied to an editor for changes.
|
||||
If no editor is specified in the
|
||||
.Ev EDITOR
|
||||
environment variable,
|
||||
.Xr vi 1
|
||||
is used.
|
||||
When the editor terminates, the label file is used to rewrite the disk label.
|
||||
Existing bootstrap code is unchanged regardless of whether
|
||||
.Fl r
|
||||
was specified.
|
||||
.Pp
|
||||
If the
|
||||
.Fl m
|
||||
option is given, then the label will be written so that
|
||||
it is understood by the target
|
||||
.Ar machine ;
|
||||
defaults to the current hardware architecture.
|
||||
.Pp
|
||||
If
|
||||
.Fl n
|
||||
is used, no data will be written to the device, and instead the
|
||||
disk label that would have been written will be printed to standard output.
|
||||
This is
|
||||
useful to see how a partitioning scheme will work out for a specific disk.
|
||||
This command opens the disklabel in the default editor and when the editor
|
||||
exits the label is validated and if OK written to disk.
|
||||
.Ss Restoring a Disk Label From a File
|
||||
To restore a disk label from a file, use the form
|
||||
.Pp
|
||||
.Nm
|
||||
.Fl R
|
||||
.Op Fl nr
|
||||
.Op Fl nA
|
||||
.Op Fl m Ar machine
|
||||
.Ar disk protofile
|
||||
.Pp
|
||||
@ -335,199 +157,15 @@ produced when reading or editing a label.
|
||||
Comments are delimited by
|
||||
.Ql #
|
||||
and newline.
|
||||
As when writing a new label, any existing bootstrap code will be
|
||||
clobbered if
|
||||
.Fl r
|
||||
is specified, and will be unaffected otherwise.
|
||||
See the boot options below for a
|
||||
method of restoring the label and writing the bootstrap at the same time.
|
||||
.Pp
|
||||
If the
|
||||
.Fl m
|
||||
option is given, then the label will be written so that
|
||||
it is understood by the target
|
||||
.Ar machine ;
|
||||
defaults to the current hardware architecture.
|
||||
.Pp
|
||||
If
|
||||
.Fl n
|
||||
is used, no data will be written to the device, and instead the
|
||||
disk label that would have been written will be printed to standard output.
|
||||
This is
|
||||
useful to see how a partitioning scheme will work out for a specific disk.
|
||||
.Ss Installing Bootstraps
|
||||
The final three forms of
|
||||
.Nm
|
||||
are used to install bootstrap code.
|
||||
If a
|
||||
.Dq dangerously-dedicated
|
||||
disk is created for compatibility with older PC systems,
|
||||
the raw disk name such as
|
||||
.Pa da0
|
||||
should be specified.
|
||||
If an existing slice should be labeled,
|
||||
the slice name such as
|
||||
.Pa da0s1
|
||||
should be specified,
|
||||
and to make it bootable,
|
||||
.Tn MBR
|
||||
on the base disk should probably be updated; see
|
||||
.Xr fdisk 8 .
|
||||
.Pp
|
||||
.Nm
|
||||
If the
|
||||
.Fl B
|
||||
.Op Fl b Ar boot
|
||||
.Op Fl m Ar machine
|
||||
.Ar disk
|
||||
.Pp
|
||||
This form installs the bootstrap only.
|
||||
It does not change the disk label.
|
||||
Never use this command on a base disk, such as
|
||||
.Pa da0 ,
|
||||
unless the intent is to create a
|
||||
.Dq dangerously-dedicated
|
||||
disk.
|
||||
This command is typically run on a slice such as
|
||||
.Pa da0s1 .
|
||||
.Pp
|
||||
The
|
||||
.Fl m
|
||||
option should be specified if the label was
|
||||
created for a different hardware architecture,
|
||||
.Ar machine .
|
||||
.Pp
|
||||
.Nm
|
||||
.Fl w B
|
||||
.Op Fl n
|
||||
.Op Fl b Ar boot
|
||||
.Op Fl m Ar machine
|
||||
.Ar disk type
|
||||
.Op Ar packid
|
||||
.Pp
|
||||
This form corresponds to the
|
||||
.Dq "write label"
|
||||
command described above.
|
||||
In addition to writing a new volume label, it also installs the bootstrap.
|
||||
If run on a base disk, this command will create a
|
||||
.Dq dangerously-dedicated
|
||||
label.
|
||||
This command is normally run on a slice rather than a base disk.
|
||||
.Pp
|
||||
If the
|
||||
.Fl m
|
||||
option is given, then the label and bootstrap will be written so that
|
||||
they are understood by the target
|
||||
.Ar machine ;
|
||||
defaults to the current hardware architecture.
|
||||
.Pp
|
||||
If
|
||||
.Fl n
|
||||
is used, no data will be written to the device, and instead the
|
||||
disk label that would have been written will be printed to standard output.
|
||||
.Pp
|
||||
.Nm
|
||||
.Fl R B
|
||||
.Op Fl n
|
||||
.Op Fl b Ar boot
|
||||
.Op Fl m Ar machine
|
||||
.Ar disk protofile
|
||||
.Pp
|
||||
This form corresponds to the
|
||||
.Dq "restore label"
|
||||
command described above.
|
||||
In addition to restoring the volume label, it also installs the bootstrap.
|
||||
If run on a base disk, this command will create a
|
||||
.Dq dangerously-dedicated
|
||||
label.
|
||||
This command is normally run on a slice rather than a base disk.
|
||||
.Pp
|
||||
The bootstrap commands always access the disk directly, so it is not necessary
|
||||
to specify the
|
||||
.Fl r
|
||||
option.
|
||||
.Pp
|
||||
If the
|
||||
.Fl m
|
||||
option is given, then the label and bootstrap will be written so that
|
||||
they are understood by the target
|
||||
.Ar machine ;
|
||||
defaults to the current hardware architecture.
|
||||
.Pp
|
||||
If
|
||||
.Fl n
|
||||
is used, no data will be written to the device, and instead the
|
||||
disk label that would have been written will be printed to standard output.
|
||||
.Pp
|
||||
The bootstrap code is comprised of two boot programs compiled into a single
|
||||
argument is specified, bootstrap code will be read from the file
|
||||
.Pa /boot/boot
|
||||
image.
|
||||
An alternative boot image may be specified with the
|
||||
.Fl b
|
||||
option.
|
||||
.Ss Initializing/Formatting a Bootable Disk From Scratch
|
||||
To initialize a disk from scratch, the following sequence is recommended.
|
||||
Please note that this will wipe everything that was previously on the disk,
|
||||
including any
|
||||
.No non- Ns Fx
|
||||
slices.
|
||||
.Bl -enum
|
||||
.It
|
||||
Use
|
||||
.Xr fdisk 8
|
||||
to initialize the hard disk, and create a slice table, referred to
|
||||
as the
|
||||
.Dq "partition table"
|
||||
in
|
||||
.Tn DOS .
|
||||
.It
|
||||
Use
|
||||
.Nm
|
||||
to define partitions on
|
||||
.Fx
|
||||
slices created in the previous step.
|
||||
.It
|
||||
Finally use
|
||||
.Xr newfs 8
|
||||
to create file systems on new partitions.
|
||||
.El
|
||||
.Pp
|
||||
A typical partitioning scheme would be to have an
|
||||
.Ql a
|
||||
partition
|
||||
of approximately 128MB to hold the root file system, a
|
||||
.Ql b
|
||||
partition for
|
||||
swap, a
|
||||
.Ql d
|
||||
partition for
|
||||
.Pa /var
|
||||
(usually 128MB), an
|
||||
.Ql e
|
||||
partition
|
||||
for
|
||||
.Pa /var/tmp
|
||||
(usually 128MB), an
|
||||
.Ql f
|
||||
partition for
|
||||
.Pa /usr
|
||||
(usually around 2GB),
|
||||
and finally a
|
||||
.Ql g
|
||||
partition for
|
||||
.Pa /home
|
||||
(usually all remaining space).
|
||||
Your mileage may vary.
|
||||
.Pp
|
||||
.Nm fdisk Fl BI Pa da0
|
||||
.Pp
|
||||
.Nm
|
||||
.Fl w B
|
||||
.Pa da0s1
|
||||
.Cm auto
|
||||
.Pp
|
||||
.Nm
|
||||
.Fl e
|
||||
.Pa da0s1
|
||||
and written to the disk.
|
||||
The
|
||||
.Fl b Ar boot
|
||||
argument allows a different file to be used.
|
||||
.Sh FILES
|
||||
.Bl -tag -width ".Pa /etc/disktab" -compact
|
||||
.It Pa /boot/boot
|
||||
@ -545,6 +183,18 @@ version of the label when examining, editing, or restoring a disk
|
||||
label.
|
||||
The format is:
|
||||
.Bd -literal -offset 4n
|
||||
|
||||
8 partitions:
|
||||
# size offset fstype [fsize bsize bps/cpg]
|
||||
a: 81920 0 4.2BSD 1024 8192 16
|
||||
b: 160000 81920 swap
|
||||
c: 1173930 0 unused 0 0 # "raw" part, don't edit
|
||||
.Ed
|
||||
.Pp
|
||||
If the
|
||||
.Fl A
|
||||
option is specified, the format is:
|
||||
.Bd -literal -offset 4n
|
||||
# /dev/da1c:
|
||||
type: SCSI
|
||||
disk: da0s1
|
||||
@ -566,48 +216,14 @@ drivedata: 0
|
||||
|
||||
8 partitions:
|
||||
# size offset fstype [fsize bsize bps/cpg]
|
||||
a: 81920 0 4.2BSD 1024 8192 16 # (Cyl. 0 - 84*)
|
||||
b: 160000 81920 swap # (Cyl. 84* - 218*)
|
||||
c: 1173930 0 unused 0 0 # (Cyl. 0 - 1211*)
|
||||
h: 962010 211920 vinum # (Cyl. 218*- 1211*)
|
||||
a: 81920 0 4.2BSD 1024 8192 16
|
||||
b: 160000 81920 swap
|
||||
c: 1173930 0 unused 0 0 # "raw" part, don't edit
|
||||
.Ed
|
||||
.Pp
|
||||
Lines starting with a
|
||||
.Ql #
|
||||
mark are comments.
|
||||
Most of the other specifications are no longer used.
|
||||
The ones which must still be set correctly are:
|
||||
.Pp
|
||||
.Bl -inset
|
||||
.It Ar label
|
||||
is an optional label, set by the
|
||||
.Ar packid
|
||||
option when writing a label.
|
||||
.It Ar flags
|
||||
may be
|
||||
.Cm removable , ecc
|
||||
or
|
||||
.Cm badsect .
|
||||
.Cm removable
|
||||
is set for removable media drives, but no current
|
||||
.Fx
|
||||
driver evaluates this
|
||||
flag.
|
||||
.Cm ecc
|
||||
is no longer supported;
|
||||
.Cm badsect
|
||||
specifies that the drive can perform bad sector remapping.
|
||||
.It Ar sectors/unit
|
||||
describes the total size of the disk.
|
||||
This value must be correct.
|
||||
.It Ar "the partition table"
|
||||
is the
|
||||
.Ux
|
||||
partition table, not the
|
||||
.Tn DOS
|
||||
partition table described in
|
||||
.Xr fdisk 8 .
|
||||
.El
|
||||
.Pp
|
||||
The partition table can have up to 8 entries.
|
||||
It contains the following information:
|
||||
@ -723,24 +339,13 @@ file systems, the segment shift value.
|
||||
Defaults to 16 for partitions smaller than 1GB,
|
||||
64 for partitions 1GB or larger.
|
||||
.El
|
||||
.Pp
|
||||
The remainder of the line is a comment and shows the cylinder allocations based
|
||||
on the obsolete (but possibly correct) geometry information about the drive.
|
||||
The asterisk
|
||||
.Pq Ql *
|
||||
indicates that the partition does not begin or end exactly on a
|
||||
cylinder boundary.
|
||||
.Sh EXAMPLES
|
||||
.Dl "bsdlabel da0s1"
|
||||
.Pp
|
||||
Display the in-core label for the first slice of the
|
||||
Display the label for the first slice of the
|
||||
.Pa da0
|
||||
disk, as obtained via
|
||||
.Pa /dev/da0s1 .
|
||||
(If the disk is
|
||||
.Dq dangerously-dedicated ,
|
||||
the base disk name should be specified, such as
|
||||
.Pa da0 . )
|
||||
.Pp
|
||||
.Dl "bsdlabel da0s1 > savedlabel"
|
||||
.Pp
|
||||
@ -752,25 +357,18 @@ This file can be used with the
|
||||
.Fl R
|
||||
option to restore the label at a later date.
|
||||
.Pp
|
||||
.Dl "bsdlabel -w -r /dev/da0s1 da2212 foo"
|
||||
.Dl "bsdlabel -w /dev/da0s1"
|
||||
.Pp
|
||||
Create a label for
|
||||
.Pa da0s1
|
||||
based on information for
|
||||
.Dq da2212
|
||||
found in
|
||||
.Pa /etc/disktab .
|
||||
Any existing bootstrap code will be clobbered
|
||||
and the disk rendered unbootable.
|
||||
.Pp
|
||||
.Dl "bsdlabel -e -r da0s1"
|
||||
.Dl "bsdlabel -e da0s1"
|
||||
.Pp
|
||||
Read the on-disk label for
|
||||
Read the label for
|
||||
.Pa da0s1 ,
|
||||
edit it, and reinstall in-core as well as on-disk.
|
||||
Existing bootstrap code is unaffected.
|
||||
edit it, and install the result.
|
||||
.Pp
|
||||
.Dl "bsdlabel -e -r -n da0s1"
|
||||
.Dl "bsdlabel -e -n da0s1"
|
||||
.Pp
|
||||
Read the on-disk label for
|
||||
.Pa da0s1 ,
|
||||
@ -779,11 +377,10 @@ It does
|
||||
.Em not
|
||||
install the new label either in-core or on-disk.
|
||||
.Pp
|
||||
.Dl "bsdlabel -r -w da0s1 auto"
|
||||
.Dl "bsdlabel -w da0s1"
|
||||
.Pp
|
||||
Try to auto-detect the required information from
|
||||
.Pa da0s1 ,
|
||||
and write a new label to the disk.
|
||||
Write a default label on
|
||||
.Pa da0s1 .
|
||||
Use another
|
||||
.Nm Fl e
|
||||
command to edit the
|
||||
@ -795,7 +392,6 @@ Restore the on-disk and in-core label for
|
||||
.Pa da0s1
|
||||
from information in
|
||||
.Pa savedlabel .
|
||||
Existing bootstrap code is unaffected.
|
||||
.Pp
|
||||
.Dl "bsdlabel -R -n da0s1 label_layout"
|
||||
.Pp
|
||||
@ -816,16 +412,10 @@ Install a new bootstrap on
|
||||
.Pa da0s1 .
|
||||
The boot code comes from
|
||||
.Pa /boot/boot .
|
||||
On-disk and in-core labels are unchanged.
|
||||
.Pp
|
||||
.Dl "bsdlabel -w -B /dev/da0s1 -b newboot da2212"
|
||||
.Dl "bsdlabel -w -B -b newboot /dev/da0s1"
|
||||
.Pp
|
||||
Install a new label and bootstrap.
|
||||
The label is derived from
|
||||
.Xr disktab 5
|
||||
information for
|
||||
.Dq da2212 ,
|
||||
and installed both in-core and on-disk.
|
||||
The bootstrap code comes from the file
|
||||
.Pa newboot
|
||||
in the current working directory.
|
||||
@ -833,7 +423,7 @@ in the current working directory.
|
||||
dd if=/dev/zero of=/dev/da0 bs=512 count=32
|
||||
fdisk -BI da0
|
||||
dd if=/dev/zero of=/dev/da0s1 bs=512 count=32
|
||||
bsdlabel -w -B da0s1 auto
|
||||
bsdlabel -w -B da0s1
|
||||
bsdlabel -e da0s1
|
||||
.Ed
|
||||
.Pp
|
||||
@ -859,23 +449,6 @@ which could be used as a source file for
|
||||
.Dq Li "bsdlabel -R ad0s1c new_label_file" :
|
||||
.Bd -literal -offset 4n
|
||||
# /dev/ad0s1c:
|
||||
type: ESDI
|
||||
disk: ad0s1
|
||||
label:
|
||||
flags:
|
||||
bytes/sector: 512
|
||||
sectors/track: 63
|
||||
tracks/cylinder: 16
|
||||
sectors/cylinder: 1008
|
||||
cylinders: 40633
|
||||
sectors/unit: 40959009
|
||||
rpm: 3600
|
||||
interleave: 1
|
||||
trackskew: 0
|
||||
cylinderskew: 0
|
||||
headswitch: 0 # milliseconds
|
||||
track-to-track seek: 0 # milliseconds
|
||||
drivedata: 0
|
||||
|
||||
8 partitions:
|
||||
# size offset fstype [fsize bsize bps/cpg]
|
||||
@ -887,90 +460,13 @@ drivedata: 0
|
||||
g: * * 4.2BSD
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr geom 4 ,
|
||||
.Xr ccd 4 ,
|
||||
.Xr md 4 ,
|
||||
.Xr bsdlabel 5 ,
|
||||
.Xr disklabel 5 ,
|
||||
.Xr disktab 5 ,
|
||||
.Xr boot0cfg 8 ,
|
||||
.Xr fdisk 8 ,
|
||||
.Xr vinum 8
|
||||
.Xr fdisk 8
|
||||
.Sh DIAGNOSTICS
|
||||
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
|
||||
.Ql a
|
||||
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 one setting the label on the new partition
|
||||
while shrinking the
|
||||
.Ql a
|
||||
partition.
|
||||
.Pp
|
||||
On some machines, the bootstrap code may not fit entirely in the area
|
||||
allocated for it by some file systems.
|
||||
As a result,
|
||||
it may not be possible to have file systems on some partitions of a
|
||||
.Dq bootable
|
||||
disk.
|
||||
When installing bootstrap code,
|
||||
.Nm
|
||||
checks for these cases.
|
||||
If the installed boot code would overlap a partition of type
|
||||
.Dv FS_UNUSED ,
|
||||
it is marked as type
|
||||
.Dv FS_BOOT .
|
||||
The
|
||||
.Xr newfs 8
|
||||
utility will disallow creation of file systems on
|
||||
.Dv FS_BOOT
|
||||
partitions.
|
||||
Conversely, if a partition has a type other than
|
||||
.Dv FS_UNUSED
|
||||
or
|
||||
.Dv FS_BOOT ,
|
||||
.Nm
|
||||
will not install bootstrap code that overlaps it.
|
||||
.Sh BUGS
|
||||
When a disk name is given without a full pathname,
|
||||
the constructed device name uses the
|
||||
.Ql c
|
||||
partition.
|
||||
.Pp
|
||||
For the i386 architecture, the primary bootstrap sector contains
|
||||
an embedded
|
||||
.Em fdisk
|
||||
table.
|
||||
The
|
||||
.Nm
|
||||
utility takes care to not clobber it when installing a bootstrap only
|
||||
.Pq Fl B ,
|
||||
or when editing an existing label
|
||||
.Pq Fl e ,
|
||||
but it unconditionally writes the primary bootstrap program onto
|
||||
the disk for
|
||||
.Fl w
|
||||
or
|
||||
.Fl R ,
|
||||
thus replacing the
|
||||
.Em fdisk
|
||||
table by the dummy one in the bootstrap program.
|
||||
This is only of
|
||||
concern if the disk is fully dedicated, so that the
|
||||
.Fx
|
||||
disk label
|
||||
starts at absolute block 0 on the disk.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
utility
|
||||
does not perform all possible error checking.
|
||||
Warnings are given if partitions overlap,
|
||||
if an absolute offset does not match the expected offset,
|
||||
if the
|
||||
.Ql c
|
||||
partition does not start at 0 or does not cover the entire slice,
|
||||
if a partition runs past the end of the device,
|
||||
and a number of other errors,
|
||||
but no warning is given if space remains unused.
|
||||
|
@ -99,7 +99,6 @@ static char *word(char *);
|
||||
static int getasciilabel(FILE *, struct disklabel *);
|
||||
static int getasciipartspec(char *, struct disklabel *, int, int);
|
||||
static int checklabel(struct disklabel *);
|
||||
static void Warning(const char *, ...) __printflike(1, 2);
|
||||
static void usage(void);
|
||||
static struct disklabel *getvirginlabel(void);
|
||||
|
||||
@ -111,6 +110,8 @@ static char tmpfil[] = PATH_TMPFILE;
|
||||
|
||||
static struct disklabel lab;
|
||||
static u_char bootarea[BBSIZE];
|
||||
static off_t mediasize;
|
||||
static u_int secsize;
|
||||
static char blank[] = "";
|
||||
static char unknown[] = "unknown";
|
||||
|
||||
@ -121,6 +122,7 @@ static char part_offset_type[MAX_NUM_PARTS];
|
||||
static int part_set[MAX_NUM_PARTS];
|
||||
|
||||
static int installboot; /* non-zero if we should install a boot program */
|
||||
static int allfields; /* present all fields in edit */
|
||||
static char const *xxboot; /* primary boot */
|
||||
|
||||
static int labeloffset = LABELOFFSET + LABELSECTOR * DEV_BSIZE;
|
||||
@ -146,8 +148,11 @@ main(int argc, char *argv[])
|
||||
int ch, error = 0;
|
||||
char const *name = 0;
|
||||
|
||||
while ((ch = getopt(argc, argv, "Bb:em:nRrs:w")) != -1)
|
||||
while ((ch = getopt(argc, argv, "ABb:em:nRrs:w")) != -1)
|
||||
switch (ch) {
|
||||
case 'A':
|
||||
allfields = 1;
|
||||
break;
|
||||
case 'B':
|
||||
++installboot;
|
||||
break;
|
||||
@ -327,7 +332,7 @@ writelabel(void)
|
||||
struct disklabel *lp = &lab;
|
||||
|
||||
if (disable_write) {
|
||||
Warning("write to disk label supressed - label was as follows:");
|
||||
warnx("write to disk label supressed - label was as follows:");
|
||||
display(stdout, NULL);
|
||||
return (0);
|
||||
}
|
||||
@ -419,45 +424,48 @@ display(FILE *f, const struct disklabel *lp)
|
||||
lp = &lab;
|
||||
|
||||
fprintf(f, "# %s:\n", specname);
|
||||
if (lp->d_type < DKMAXTYPES)
|
||||
fprintf(f, "type: %s\n", dktypenames[lp->d_type]);
|
||||
else
|
||||
fprintf(f, "type: %u\n", lp->d_type);
|
||||
fprintf(f, "disk: %.*s\n", (int)sizeof(lp->d_typename),
|
||||
lp->d_typename);
|
||||
fprintf(f, "label: %.*s\n", (int)sizeof(lp->d_packname),
|
||||
lp->d_packname);
|
||||
fprintf(f, "flags:");
|
||||
if (lp->d_flags & D_REMOVABLE)
|
||||
fprintf(f, " removeable");
|
||||
if (lp->d_flags & D_ECC)
|
||||
fprintf(f, " ecc");
|
||||
if (lp->d_flags & D_BADSECT)
|
||||
fprintf(f, " badsect");
|
||||
fprintf(f, "\n");
|
||||
fprintf(f, "bytes/sector: %lu\n", (u_long)lp->d_secsize);
|
||||
fprintf(f, "sectors/track: %lu\n", (u_long)lp->d_nsectors);
|
||||
fprintf(f, "tracks/cylinder: %lu\n", (u_long)lp->d_ntracks);
|
||||
fprintf(f, "sectors/cylinder: %lu\n", (u_long)lp->d_secpercyl);
|
||||
fprintf(f, "cylinders: %lu\n", (u_long)lp->d_ncylinders);
|
||||
fprintf(f, "sectors/unit: %lu\n", (u_long)lp->d_secperunit);
|
||||
fprintf(f, "rpm: %u\n", lp->d_rpm);
|
||||
fprintf(f, "interleave: %u\n", lp->d_interleave);
|
||||
fprintf(f, "trackskew: %u\n", lp->d_trackskew);
|
||||
fprintf(f, "cylinderskew: %u\n", lp->d_cylskew);
|
||||
fprintf(f, "headswitch: %lu\t\t# milliseconds\n",
|
||||
(u_long)lp->d_headswitch);
|
||||
fprintf(f, "track-to-track seek: %ld\t# milliseconds\n",
|
||||
(u_long)lp->d_trkseek);
|
||||
fprintf(f, "drivedata: ");
|
||||
for (i = NDDATA - 1; i >= 0; i--)
|
||||
if (lp->d_drivedata[i])
|
||||
break;
|
||||
if (i < 0)
|
||||
i = 0;
|
||||
for (j = 0; j <= i; j++)
|
||||
fprintf(f, "%lu ", (u_long)lp->d_drivedata[j]);
|
||||
fprintf(f, "\n\n%u partitions:\n", lp->d_npartitions);
|
||||
if (allfields) {
|
||||
if (lp->d_type < DKMAXTYPES)
|
||||
fprintf(f, "type: %s\n", dktypenames[lp->d_type]);
|
||||
else
|
||||
fprintf(f, "type: %u\n", lp->d_type);
|
||||
fprintf(f, "disk: %.*s\n", (int)sizeof(lp->d_typename),
|
||||
lp->d_typename);
|
||||
fprintf(f, "label: %.*s\n", (int)sizeof(lp->d_packname),
|
||||
lp->d_packname);
|
||||
fprintf(f, "flags:");
|
||||
if (lp->d_flags & D_REMOVABLE)
|
||||
fprintf(f, " removeable");
|
||||
if (lp->d_flags & D_ECC)
|
||||
fprintf(f, " ecc");
|
||||
if (lp->d_flags & D_BADSECT)
|
||||
fprintf(f, " badsect");
|
||||
fprintf(f, "\n");
|
||||
fprintf(f, "bytes/sector: %lu\n", (u_long)lp->d_secsize);
|
||||
fprintf(f, "sectors/track: %lu\n", (u_long)lp->d_nsectors);
|
||||
fprintf(f, "tracks/cylinder: %lu\n", (u_long)lp->d_ntracks);
|
||||
fprintf(f, "sectors/cylinder: %lu\n", (u_long)lp->d_secpercyl);
|
||||
fprintf(f, "cylinders: %lu\n", (u_long)lp->d_ncylinders);
|
||||
fprintf(f, "sectors/unit: %lu\n", (u_long)lp->d_secperunit);
|
||||
fprintf(f, "rpm: %u\n", lp->d_rpm);
|
||||
fprintf(f, "interleave: %u\n", lp->d_interleave);
|
||||
fprintf(f, "trackskew: %u\n", lp->d_trackskew);
|
||||
fprintf(f, "cylinderskew: %u\n", lp->d_cylskew);
|
||||
fprintf(f, "headswitch: %lu\t\t# milliseconds\n",
|
||||
(u_long)lp->d_headswitch);
|
||||
fprintf(f, "track-to-track seek: %ld\t# milliseconds\n",
|
||||
(u_long)lp->d_trkseek);
|
||||
fprintf(f, "drivedata: ");
|
||||
for (i = NDDATA - 1; i >= 0; i--)
|
||||
if (lp->d_drivedata[i])
|
||||
break;
|
||||
if (i < 0)
|
||||
i = 0;
|
||||
for (j = 0; j <= i; j++)
|
||||
fprintf(f, "%lu ", (u_long)lp->d_drivedata[j]);
|
||||
fprintf(f, "\n\n");
|
||||
}
|
||||
fprintf(f, "%u partitions:\n", lp->d_npartitions);
|
||||
fprintf(f,
|
||||
"# size offset fstype [fsize bsize bps/cpg]\n");
|
||||
pp = lp->d_partitions;
|
||||
@ -495,6 +503,9 @@ display(FILE *f, const struct disklabel *lp)
|
||||
fprintf(f, "%20.20s", "");
|
||||
break;
|
||||
}
|
||||
if (i == RAW_PART) {
|
||||
fprintf(f, " # \"raw\" part, don't edit");
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
}
|
||||
@ -1001,36 +1012,54 @@ checklabel(struct disklabel *lp)
|
||||
if (lp == NULL)
|
||||
lp = &lab;
|
||||
|
||||
if (lp->d_secsize == 0) {
|
||||
fprintf(stderr, "sector size 0\n");
|
||||
return (1);
|
||||
if (allfields) {
|
||||
|
||||
if (lp->d_secsize == 0) {
|
||||
fprintf(stderr, "sector size 0\n");
|
||||
return (1);
|
||||
}
|
||||
if (lp->d_nsectors == 0) {
|
||||
fprintf(stderr, "sectors/track 0\n");
|
||||
return (1);
|
||||
}
|
||||
if (lp->d_ntracks == 0) {
|
||||
fprintf(stderr, "tracks/cylinder 0\n");
|
||||
return (1);
|
||||
}
|
||||
if (lp->d_ncylinders == 0) {
|
||||
fprintf(stderr, "cylinders/unit 0\n");
|
||||
errors++;
|
||||
}
|
||||
if (lp->d_rpm == 0)
|
||||
warnx("revolutions/minute 0");
|
||||
if (lp->d_secpercyl == 0)
|
||||
lp->d_secpercyl = lp->d_nsectors * lp->d_ntracks;
|
||||
if (lp->d_secperunit == 0)
|
||||
lp->d_secperunit = lp->d_secpercyl * lp->d_ncylinders;
|
||||
if (lp->d_bbsize == 0) {
|
||||
fprintf(stderr, "boot block size 0\n");
|
||||
errors++;
|
||||
} else if (lp->d_bbsize % lp->d_secsize)
|
||||
warnx("boot block size %% sector-size != 0");
|
||||
if (lp->d_npartitions > MAXPARTITIONS)
|
||||
warnx("number of partitions (%lu) > MAXPARTITIONS (%d)",
|
||||
(u_long)lp->d_npartitions, MAXPARTITIONS);
|
||||
} else {
|
||||
struct disklabel *vl;
|
||||
|
||||
vl = getvirginlabel();
|
||||
lp->d_secsize = vl->d_secsize;
|
||||
lp->d_nsectors = vl->d_nsectors;
|
||||
lp->d_ntracks = vl->d_ntracks;
|
||||
lp->d_ncylinders = vl->d_ncylinders;
|
||||
lp->d_rpm = vl->d_rpm;
|
||||
lp->d_interleave = vl->d_interleave;
|
||||
lp->d_secpercyl = vl->d_secpercyl;
|
||||
lp->d_secperunit = vl->d_secperunit;
|
||||
lp->d_bbsize = vl->d_bbsize;
|
||||
lp->d_npartitions = vl->d_npartitions;
|
||||
}
|
||||
if (lp->d_nsectors == 0) {
|
||||
fprintf(stderr, "sectors/track 0\n");
|
||||
return (1);
|
||||
}
|
||||
if (lp->d_ntracks == 0) {
|
||||
fprintf(stderr, "tracks/cylinder 0\n");
|
||||
return (1);
|
||||
}
|
||||
if (lp->d_ncylinders == 0) {
|
||||
fprintf(stderr, "cylinders/unit 0\n");
|
||||
errors++;
|
||||
}
|
||||
if (lp->d_rpm == 0)
|
||||
Warning("revolutions/minute 0");
|
||||
if (lp->d_secpercyl == 0)
|
||||
lp->d_secpercyl = lp->d_nsectors * lp->d_ntracks;
|
||||
if (lp->d_secperunit == 0)
|
||||
lp->d_secperunit = lp->d_secpercyl * lp->d_ncylinders;
|
||||
if (lp->d_bbsize == 0) {
|
||||
fprintf(stderr, "boot block size 0\n");
|
||||
errors++;
|
||||
} else if (lp->d_bbsize % lp->d_secsize)
|
||||
Warning("boot block size %% sector-size != 0");
|
||||
if (lp->d_npartitions > MAXPARTITIONS)
|
||||
Warning("number of partitions (%lu) > MAXPARTITIONS (%d)",
|
||||
(u_long)lp->d_npartitions, MAXPARTITIONS);
|
||||
|
||||
|
||||
/* first allocate space to the partitions, then offsets */
|
||||
total_size = 0; /* in sectors */
|
||||
@ -1045,7 +1074,7 @@ checklabel(struct disklabel *lp)
|
||||
pp->p_size = lp->d_secperunit;
|
||||
} else {
|
||||
if (hog_part != -1)
|
||||
Warning("Too many '*' partitions (%c and %c)",
|
||||
warnx("Too many '*' partitions (%c and %c)",
|
||||
hog_part + 'a',i + 'a');
|
||||
else
|
||||
hog_part = i;
|
||||
@ -1073,7 +1102,7 @@ checklabel(struct disklabel *lp)
|
||||
case '\0':
|
||||
break;
|
||||
default:
|
||||
Warning("unknown size specifier '%c' (K/M/G are valid)",part_size_type[i]);
|
||||
warnx("unknown size specifier '%c' (K/M/G are valid)",part_size_type[i]);
|
||||
break;
|
||||
}
|
||||
/* don't count %'s yet */
|
||||
@ -1084,7 +1113,7 @@ checklabel(struct disklabel *lp)
|
||||
*/
|
||||
if (part_size_type[i] != '\0') {
|
||||
if (size % lp->d_secsize != 0)
|
||||
Warning("partition %c not an integer number of sectors",
|
||||
warnx("partition %c not an integer number of sectors",
|
||||
i + 'a');
|
||||
size /= lp->d_secsize;
|
||||
pp->p_size = size;
|
||||
@ -1162,7 +1191,7 @@ checklabel(struct disklabel *lp)
|
||||
* this may give unneeded warnings if
|
||||
* partitions are out-of-order
|
||||
*/
|
||||
Warning(
|
||||
warnx(
|
||||
"Offset %ld for partition %c doesn't match expected value %ld",
|
||||
(long)pp->p_offset, i + 'a', current_offset);
|
||||
}
|
||||
@ -1176,14 +1205,14 @@ checklabel(struct disklabel *lp)
|
||||
part = 'a' + i;
|
||||
pp = &lp->d_partitions[i];
|
||||
if (pp->p_size == 0 && pp->p_offset != 0)
|
||||
Warning("partition %c: size 0, but offset %lu",
|
||||
warnx("partition %c: size 0, but offset %lu",
|
||||
part, (u_long)pp->p_offset);
|
||||
#ifdef notdef
|
||||
if (pp->p_size % lp->d_secpercyl)
|
||||
Warning("partition %c: size %% cylinder-size != 0",
|
||||
warnx("partition %c: size %% cylinder-size != 0",
|
||||
part);
|
||||
if (pp->p_offset % lp->d_secpercyl)
|
||||
Warning("partition %c: offset %% cylinder-size != 0",
|
||||
warnx("partition %c: offset %% cylinder-size != 0",
|
||||
part);
|
||||
#endif
|
||||
if (pp->p_offset > lp->d_secperunit) {
|
||||
@ -1197,18 +1226,17 @@ checklabel(struct disklabel *lp)
|
||||
part);
|
||||
errors++;
|
||||
}
|
||||
if (i == RAW_PART)
|
||||
{
|
||||
if (i == RAW_PART) {
|
||||
if (pp->p_fstype != FS_UNUSED)
|
||||
Warning("partition %c is not marked as unused!",part);
|
||||
warnx("partition %c is not marked as unused!",part);
|
||||
if (pp->p_offset != 0)
|
||||
Warning("partition %c doesn't start at 0!",part);
|
||||
warnx("partition %c doesn't start at 0!",part);
|
||||
if (pp->p_size != lp->d_secperunit)
|
||||
Warning("partition %c doesn't cover the whole unit!",part);
|
||||
warnx("partition %c doesn't cover the whole unit!",part);
|
||||
|
||||
if ((pp->p_fstype != FS_UNUSED) || (pp->p_offset != 0) ||
|
||||
(pp->p_size != lp->d_secperunit)) {
|
||||
Warning("An incorrect partition %c may cause problems for "
|
||||
warnx("An incorrect partition %c may cause problems for "
|
||||
"standard system utilities",part);
|
||||
}
|
||||
}
|
||||
@ -1235,7 +1263,7 @@ checklabel(struct disklabel *lp)
|
||||
part = 'a' + i;
|
||||
pp = &lp->d_partitions[i];
|
||||
if (pp->p_size || pp->p_offset)
|
||||
Warning("unused partition %c: size %d offset %lu",
|
||||
warnx("unused partition %c: size %d offset %lu",
|
||||
'a' + i, pp->p_size, (u_long)pp->p_offset);
|
||||
}
|
||||
return (errors);
|
||||
@ -1256,8 +1284,7 @@ getvirginlabel(void)
|
||||
static struct disklabel loclab;
|
||||
struct partition *dp;
|
||||
int f;
|
||||
u_int secsize, u;
|
||||
off_t mediasize;
|
||||
u_int u;
|
||||
|
||||
if ((f = open(specname, O_RDONLY)) == -1) {
|
||||
warn("cannot open %s", specname);
|
||||
@ -1301,7 +1328,7 @@ getvirginlabel(void)
|
||||
/* Various (unneeded) compat stuff */
|
||||
loclab.d_rpm = 3600;
|
||||
loclab.d_bbsize = BBSIZE;
|
||||
loclab.d_interleave = 1;;
|
||||
loclab.d_interleave = 1;
|
||||
strncpy(loclab.d_typename, "amnesiac",
|
||||
sizeof(loclab.d_typename));
|
||||
|
||||
@ -1312,20 +1339,6 @@ getvirginlabel(void)
|
||||
return (&loclab);
|
||||
}
|
||||
|
||||
|
||||
/*VARARGS1*/
|
||||
static void
|
||||
Warning(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
fprintf(stderr, "Warning, ");
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fprintf(stderr, "\n");
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user