|DISKLABEL(8)||System Manager's Manual||DISKLABEL(8)|
disklabel — read
and write disk pack label
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 layout, stored on the disk itself. It is used by the operating
system to optimize disk I/O and locate the filesystems resident on the
disklabel supports 15 configurable
partitions, ‘a’ through ‘p’, excluding
‘c’. The ‘c’ partition describes the entire
physical disk, is automatically created by the kernel, and cannot be
modified or deleted by
disklabel. By convention, the
‘a’ partition of the boot disk is the root partition, and the
‘b’ partition of the boot disk is the swap partition, but all
other letters can be used in any order for any other partitions as
The options are as follows:
EDITORenvironment variable, or vi(1) if none is specified.
-Fflag is only valid when used in conjunction with the
-Rflags. If file already exists, it will be overwritten.
-Fexcept that entries will be written using disk device names.
%’ (percent of total) and ‘
&’ (percent of free) units are also accepted.
-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. 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.
The second form of the command (write) is used to write a standard label 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 disktab 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 pack ID must be quoted if it contains blanks. The existing label will be updated via the in-core copy and any bootstrap code will be unaffected.
In the third form of the command (edit), the label is read from
the in-core kernel copy and then supplied to an editor for changes. If no
editor is specified in an
variable, vi(1) is used. When the
editor terminates, the formatted label is reread and used to rewrite the
disk label. Existing bootstrap code is unchanged.
The built-in label editor (fourth form) provides a simple
interactive label editor. Some commands or prompts take an optional unit.
Available units are ‘b’ for bytes, ‘c’ for
cylinders, ‘k’ for kilobytes, ‘m’ for megabytes,
‘g’ for gigabytes, and ‘t’ for terabytes. If no
unit is given, the default is to use sectors (usually 512 bytes). Quantities
will be rounded to the nearest cylinder when units are specified for sizes
(or offsets). Commands may be aborted by entering
^D’ (Control-D). Entering
^D’ at the main
>’ prompt will exit the editor. At
prompts that request a size, ‘
be entered to indicate the rest of the available space. The editor commands
are as follows:
disklabelwhich parts of the disk it is allowed to modify. This option is probably only useful for ports with fdisk(8) partition tables 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 where the fdisk partition table is incapable of storing the real size. Note: data may become corrupted if boundaries are extended such that they overlap with other resident operating systems.
+’ or ‘
-’ to change the size by a relative amount.
*’ to delete all partitions). If no partition is specified, the user will be prompted for one.
g[d | u]
disklabelmade any changes).
PAGERenvironment variable or 'less' if
PAGERis not set.
Xbelow), then block fragment size, block size, and cylinders per group can also be modified. Note that not all parameters are configurable for non-BSD partitions.
disklabelwas invoked with the
-Roption). If no path is specified, the user will be prompted for one.
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 produced when reading or editing a label. Comments are delimited by # and newline. Any existing bootstrap code will be unaffected.
The final three forms of
used to install bootstrap code on machines where the bootstrap is part of
When installing bootstrap code with the
-B flag, if the boot program name is not explicitly
-b boot1, a
standard boot program will be used. The standard boot programs are located
in /usr/mdec. The name of the program is taken from
the “b0” parameter of the
disktab(5) entry for the
disk if disktype was given and its disktab entry
exists and includes a b0 field. Otherwise, the boot program name is derived
from the name of the disk. These names are of the form
basenameboot. For example,
/usr/mdec/sdboot if the disk device is
The first of the three boot-installation forms is used to install bootstrap 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 versions except that they will install bootstrap code in addition to a new label.
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) partitions the
default label will also include DOS and Linux partitions. However, these
entries are not dynamic, they are fixed at the time
disklabel is run. That means that subsequent changes
that affect non-OpenBSD 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
disklabel can then
be run with the
-e flag and any entries pasted as
desired from the default label into the real one.
-A option and the editor command
A automatically create a disklabel with a set of
partitions suitable for a majority of OpenBSD
installations. Any existing OpenBSD disklabel on the
disk is ignored, but native partitions that would normally be spoofed are
preserved in the disklabel, and are not modified during the allocation
Disk size determines the set of partitions which are created. Each partition is allocated space between a specified minimum and maximum. Each partition is allocated its minimum and remaining space is split between the partitions up to their maximum allowed space, which is a fixed percentage. Space left after all partitions have reached their maximum size is left unallocated. The sizes below are approximations, and may vary from architecture to architecture.
Disks > 7 Gigabytes
/ 5% of disk. 80M – 1G swap 5% of disk. 80M – 2x max physical memory /tmp 8% of disk. 120M – 4G /var 13% of disk. 80M – 2x size of crash dump /usr 5% of disk. 900M – 2G /usr/X11R6 3% of disk. 512M – 1G /usr/local 10% of disk. 2G – 10G /usr/src 2% of disk. 1G – 2G /usr/obj 4% of disk. 1.3G – 2G /home 45% of disk. 1G – 300G
Disks > 2 Gigabytes
/ 5% of disk. 800M – 2G swap 10% of disk. 80M – 2x max physical memory /usr 78% of disk. 900M – 3G /home 7% of disk. 256M – 2G
Disks > 700 Megabytes
/ 95% of disk. 700M – 4G swap 5% of disk. 1M – 2x max physical memory
A template for the automatic allocation can be passed to disklabel
-T option. The template consists of one
line per partition, with each line giving mountpoint, min-max size range,
and percentage of disk, space-separated. Max can be unlimited by specifying
'*'. If only mountpoint and min size are given, the partition is created
with that exact size.
/ 250M swap 80-256M 10% /tmp 120M-4G 8% /var 80M-4G 13% /usr 900M-2G 5% /usr/X11R6 512M-1G 3% /usr/local 2G-10G 10% /usr/src 1-2G 2% /usr/obj 1.3G-2G 4% /home 1G-* 45%
Display the in-core label for sd0 as obtained via /dev/rsd0c:
# disklabel sd0
Create a label for sd0 based on information for “sd2212” found in /etc/disktab. Any existing bootstrap code will be clobbered.
# disklabel -w /dev/rsd0c sd2212 foo
Read the on-disk label from a disk with DUID 3eb7f9da875cb9ee, edit it and reinstall in-core as well as on-disk. Existing bootstrap code is unaffected.
# disklabel -E 3eb7f9da875cb9ee
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 in-core labels 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 on-disk. 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 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 ‘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 partition 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 be
possible 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
newfs(8) utility will disallow
creation of filesystems on
Conversely, if a partition has a type other than
disklabel will not install bootstrap code that
The maximum disk and partition size is 64PB.
On some machines, such as Sparc and Sparc64, partition tables may not exhibit the full functionality described above.
|May 19, 2015||OpenBSD-5.8|