disklabel - read and write disk pack label
disklabel [-c | -d | -r | -t] [-v] [-p unit] disk
disklabel -w [-c | -d | -r] [-nv] disk disktype [packid]
disklabel -e [-c | -d | -r] [-nv] disk
disklabel -E [-c | -d | -r] [-nv] [-f tempfile] disk
disklabel -R [-nrv] disk protofile
disklabel -N | -W [-nv] disk
disklabel -B [-nv] [-b boot1] [-s boot2] disk [disktype]
disklabel -Bw [-nv] [-b boot1] [-s boot2] disk disktype
disklabel -BR [-nv] [-b boot1] [-s boot2] disk protofile
The disklabel utility can be used to install, examine, or
modify the label
on a disk drive or pack. The disk label contains information about
disk characteristics (size, type, etc.) and the partition
on the disk itself. It is used by the operating system to
I/O and locate the filesystems resident on the disk.
The options are as follows:
-B Install bootstrap code. The -r flag is implied by
-B and never
needs to be specified.
-b Specify the single level boot program, or the primary boot program,
depending on the system boot architecture
-c Clear the system's in-core copy of the label and update it based
on the on-disk label. May not be used in conjunction with the -r
-d Use the default label. This ignores any existing
on the disk. Note that this option will only
disks that are capable of reporting their geometry,
such as SCSI,
IDE, and ESDI. May not be used in conjunction with
the -r flag.
-E Use a simple initial label editor, using the command-driven
built-in editor described below.
-e Edit an existing disk label using the editor specified in the
EDITOR environment variable, or vi(1) if none is
Write entries to tempfile in fstab(5) format for any
for which mount point information has been specified. The -f
flag is only valid when used in conjunction with the
-E flag. If
tempfile already exists, it will be overwritten.
-N Disallow writing of the pack label area on the selected disk.
-n Make no permanent changes to the disklabel (useful
Print partition sizes and offsets in unit instead of
Valid units are b(ytes), c(ylinders), k(ilobytes),
and g(igabytes). For operations other than displaying a partition
the `%' (percent of total) and `&' (percent of
are also accepted.
-R Restore a disk label that was formatted in a prior
saved in an ASCII file.
-r Causes the label to be read from or written to the
rather than going through the system's in-core copy
of the label.
This option may allow a label to be installed on a
kernel support for a label, such as when labels are
on a system. This flag does not work on a
number of architectures,
thus it is not considered the right way
to put a new
label on a disk. Its use is discouraged.
-s On machines with a two-level bootstrap (such as
systems), specify the secondary boot program.
-t Format the label as a disktab(5) entry.
-v Print additional information during operation (verbose mode).
-W Allow writing of the pack label area on the selected
-w Write a standard label on the designated drive.
disk Specify the disk to operate on. It can be specified
its full pathname or an abbreviated disk form. In
form, the path to the device, the `r' donating
and the slice, can all be omitted. For example, the
disk can be specified as either /dev/rwd0c,
/dev/wd0c, or wd0.
Specify a disktype entry from the disktab(5)
packid Specify a pack identification string for the device
Used with the restore option (-R) to specify a file
to read an
ASCII label from.
The first form of the command (read) is used to examine the
label on the
named disk drive. It will display all of the parameters associated with
the drive and its partition layout. Unless the -r flag is
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
have constructed or modified the label.
The second form of the command (write) is used to write a
on the designated drive. 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
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 pack ID must be quoted if it
If the -r flag 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
If -r is not specified, the existing label will be updated
via the incore
copy and any bootstrap code will be unaffected. If the
not already have a label, the -r flag must be used. In either case, the
kernel's in-core label is replaced.
In the third form of the command (edit), the label is read
from the incore
kernel copy, or directly from the disk if the -r flag
is also given.
The label is formatted and then supplied to an editor for
changes. If no
editor is specified in an EDITOR environment variable, vi(1)
When the editor terminates, the formatted label is reread
and used to
rewrite the disk label. Existing bootstrap code is unchanged regardless
of whether -r was specified.
The initial label editor mode (fourth form) is only intended
disks as it will move partitions around as necessary to
maintain a contiguous
pool of free blocks. Some commands or prompts take
unit. Available units are `b' for bytes, `c' for cylinders,
kilobytes, `m' for megabytes, and `g' for gigabytes. Quantities will be
rounded to the nearest cylinder when units are specified for
offsets). Commands may be aborted by entering `^D' (Control-D). Entering
`^D' at the main `>' prompt will exit the editor. At
request a size, `*' may be entered to indicate the rest of
space. The editor commands are as follows:
Display help message with all available commands.
may be specified to get more detailed help.
There is also
(simple) context-sensitive help available at most
a [part] Add new partition. This option adds a new BSD
no partition letter is specified (a-p), the user
prompted for one.
b Set OpenBSD disk boundaries. This option tells
which parts of the disk it is allowed to modify.
is probably only useful for ports with fdisk(8)
where the ending sector in the MBR is incorrect. The user
may enter `*' at the ``Size'' prompt to indicate the entire
size of the disk (minus the starting sector).
This is useful
for disks larger than 8 gigabytes where the fdisk
table is incapable of storing the real size.
c [part] Change the size of an existing partition. If no
specified, the user will be prompted for one.
The new size
may be in terms of the aforementioned units and
may also be
prefixed with `+' or `-' to change the size by a
D Sets the disk label to the default values as reported by the
kernel. This simulates the case where there is
no disk label.
d [part] Delete an existing partition (or `*' to delete
If no partition is specified, the user
prompted for one. The `c' partition cannot be
e Edit drive parameters. This option is used to
set the following
parameters: disk type, a descriptive label
cylinders, total sectors, rpm, and interleave.
g [b|d|u] Set disk geometry based on what the BIOS, disk,
or user thinks
(the user geometry is simply what the label said
disklabel made any changes).
M Display this manual page.
m [part] Modify parameters for an existing partition. If
is specified, the user will be prompted for one.
allows the user to change the filesystem type,
partition size, and mount point for the
If expert mode is enabled (see X below),
fragment size, block size, and cylinders per
group can also be
modified. Note that not all parameters are configurable for
n [part] Name the mount point for an existing partition.
If no partition
is specified, the user will be prompted for
option is only valid if disklabel was invoked
with the -f
p [unit] Print the current disk label. If a unit is given, the size
and offsets are displayed in terms of the specified unit.
q Quit the editor. If any changes have been made,
the user will
be asked whether or not to save the changes to
the on-disk label.
r Recalculate free space. This option should really not be necessary
under normal circumstances.
s [path] Save the label to a file in ASCII format (suitable for loading
via the -R option). If no path is specified, the
user will be
prompted for one.
u Undo (or redo) last change. Entering u once will
last change. Entering it again will restore the
w Write the label to disk. This option will commit
to the on-disk label.
X Toggle ``expert mode''. By default, some settings are reserved
for experts only (such as the block and
on ffs partitions).
x Exit the editor without saving any changes to the
z Zeroes out the existing partition table, leaving
only the `c'
partition. The drive parameters are not changed.
In the restore form of the command (fifth form), the prototype file used
to create the label should be in the same format as that
reading or editing a label. Comments are delimited by # and
with -w, any existing bootstrap code will be clobbered if -r
and will be unaffected otherwise.
The sixth form of the command (protect) is used to control
to the label area of a disk so that the label cannot be inadvertently
overwritten. The -N and -W options are only available on
that support this feature, such as vax, hp300 and some sparc
The final three forms of disklabel are used to install bootstrap code on
machines where the bootstrap is part of the label. The
bootstrap code is
comprised of one or two boot programs, depending on the machine.
When installing bootstrap code with the -B flag, if the
names are not explicitly
given, standard boot programs will be used. The
are located in /usr/mdec. The names of the programs are
taken from the
``b0'' and ``b1'' parameters of the disktab(5) entry for the
disktype was given and its disktab entry exists and includes
Otherwise, boot program names are derived from the
name of the
disk. These names are of the form basenameboot for the primary (or only)
bootstrap, and bootbasename for the secondary bootstrap; for
/usr/mdec/sdboot and /usr/mdec/bootsd if the disk device is
The first of the three boot-installation forms is used to
code without changing the existing label. It is essentially a read
command with respect to the disk label itself and all options are related
to the specification of the boot program as described previously. The
final two forms are analogous to the basic write and restore
that they will install bootstrap code in addition to a
Note that when a disk has no real BSD disklabel, the kernel
creates a default
label so that the disk can be used. This default label will include
other partitions found on the disk if they are supported on your
architecture. For example, on systems that support fdisk(8)
the default label will also include DOS and Linux partitions. However,
these entries are not dynamic, they are fixed at the time
run. That means that subsequent changes that affect nonOpenBSD partitions
will not be present in the default label, though they
may be updated
by hand. To see the default label, run disklabel with
the -d flag.
disklabel can then be run with the -e flag and any entries
pasted as desired
from the default label into the real one.
/etc/disklabels Directory for backup labels.
/etc/disktab Disk description file.
/usr/mdec/xxboot Primary bootstrap.
/usr/mdec/bootxx Secondary bootstrap.
Display the in-core label for sd0 as obtained via
# disklabel sd0
Create a label for sd0 based on information for ``sd2212''
/etc/disktab. Any existing bootstrap code will be clobbered. (Normally
you do not want to use the -r flag though.)
# disklabel -w -r /dev/rsd0c sd2212 foo
Read the on-disk label for sd0, edit it and reinstall incore as well as
on-disk. (Normally you do not want to use the -r flag
bootstrap code is unaffected.
# disklabel -e -r sd0
Restore the on-disk and in-core label for sd0 from information in
mylabel. Existing bootstrap code is unaffected.
# disklabel -R sd0 mylabel
Install a new bootstrap on sd0. The boot code comes from
/usr/mdec/sdboot and possibly /usr/mdec/bootsd. On-disk and
are unchanged, but on some systems other information
may be destroyed.
Use with care.
# disklabel -B sd0
Install a new label and bootstrap. The label is derived
from disktab information
for ``sd2212'' and installed both in-core and ondisk. The
bootstrap code comes from the file /usr/mdec/newboot.
# disklabel -w -B /dev/rsd0c -b newboot sd2212
The kernel device drivers will not allow the size of a disk
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
if a disk is unlabeled; thus, the label must be written
to the `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 setting the label on the new
while shrinking the `a' partition.
On some machines the bootstrap code may not fit entirely in
the area allocated
for it by some filesystems. As a result, it may not
to have filesystems on some partitions of a ``bootable''
disk. When installing
bootstrap code, disklabel checks for these cases.
If the installed
boot code would overlap a partition of type FS_UNUSED it is
marked as type FS_BOOT. The newfs(8) utility will disallow
filesystems on FS_BOOT partitions. Conversely, if a partition has a type
other than FS_UNUSED or FS_BOOT, disklabel will not install
code that overlaps it.
disklabel(5), disktab(5), scan_ffs(8)
On i386 machines, installboot(8) is normally used to install
The -B option to disklabel can still be used to install old
code, but this usage is deprecated.
On some machines, such as the sparc, partition tables may
not exhibit the
full functionality that is described above.
disklabel only supports up to a maximum of 15 partitions,
`p', excluding `c'. The `c' partition is reserved for the
disk. By convention, the `a' partition of the boot disk
is the root
partition, and the `b' partition of the boot disk is the
but all other letters can be used in any order for any other
When a disk name is given without a full pathname, the constructed device
name uses the `a' partition on the tahoe, the `c' partition
on all others.
In -E mode, disklabel is far too quick to shuffle partitions
around; it should keep a free block list and only move partitions around
with the user's permission. Also, in -E mode, partitions
OpenBSD portion of the disk should be changeable.
OpenBSD 3.6 October 27, 1997
[ Back ]