| DISKLABEL(8) | System Manager's Manual | DISKLABEL(8) |
disklabel — read
and write disk pack label
disklabel |
[-Acdtv] [-h |
-p unit]
[-T file]
disk |
disklabel |
-w [-Acdnv]
[-T file]
disk disktype [packid] |
disklabel |
-e [-Acdnv]
[-T file]
disk |
disklabel |
-E [-Acdnv]
[-F|-f
file] [-T
file] disk |
disklabel |
-R [-nv]
[-F|-f
file] 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 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
disk.
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
desired.
The options are as follows:
-A-c-d-E-eEDITOR environment variable, or
vi(1) if none is specified.-F
file-F flag is only
valid when used in conjunction with the -E or
-R flags. If file already
exists, it will be overwritten.-f
file-F except that entries will be written
using disk device names.-h-n-p
unit-R-T
file-t-v-w-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.
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 EDITOR environment
variable, vi(1) is used. When the
editor terminates, the formatted label is reread and used to rewrite the
disk label.
The built-in label editor (fourth form) provides a simple interactive label editor. The editor prompt contains information about the state of the edit process.
disk*>Where disk is the name of the disk being edited, ‘*’ means that the in-memory copy of the partition table has been modified but not yet written to disk.
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 are rounded to the nearest cylinder when units are
specified for sizes (or offsets). At prompts that request a size,
‘*’ may be entered to indicate the
rest of the available space, ‘%’ for percentage of total, and
‘&’ for percentage free. Commands may be aborted by
entering ‘^D’ (Control-D). Entering
‘^D’ at the main prompt will exit the
editor.
The editor commands are as follows:
? |
hAa
[part]bdisklabel which 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.c
[part]+’ or
‘-’ to change the size by a relative
amount.Dd
[part]*’
to delete all partitions). If no partition is specified, the user will be
prompted for one.eil
[unit]MPAGER environment variable or
'less' if PAGER is not set.m
[part]n
[part]disklabel was invoked with the
-f flag.p
[unit]qR
[part]rs
[path]-R option). If no path is specified, the user will
be prompted for one.UuwxzIn 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.
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 -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.
The -A option and the editor command
A create disklabels that distribute a disk's free
space into a set of partitions appropriate for an
OpenBSD installation. The exact set of partitions
created depends on available free space, how fragmented the free space is
and some machine dependent variables, but will be approximately:
| > 10GB Free | > 2.5GB | > 700MB | < 700MB | |
| / | 150MB – 1GB | 800MB – 2GB | 700MB – 4GB | 1MB – 2GB |
| swap | 80MB – 256MB | 80MB – 256MB | 1MB – 256MB | |
| /usr | 1.5GB – 30GB | 1.5GB – 30GB | ||
| /home | 1GB – 300GB | 256MB – 2GB | ||
| /tmp | 120MB – 4GB | |||
| /var | 80MB – 4GB | |||
| /usr/X11R6 | 384MB – 1GB | |||
| /usr/local | 1GB – 20GB | |||
| /usr/src | 2GB – 5GB | |||
| /usr/obj | 5GB – 6GB |
The -A option displays the partition set
that would be created and -wA writes it to disk.
The default set can be overridden with -T.
Each line of input uses three fields to describe a partition. There must not
be whitespace before the first field, fields are separated by whitespace and
fields cannot contain whitespace.
The first field is the partition's mount point or one of the special tokens ‘RAID’ or ‘SWAP’.
The second field is the partition size. This can be ‘*’ to make the partition as large as possible, an exact size (e.g. 1G) or a size range (e.g. 1M-10G or 1G-*).
The third field is the partition's share of any space left after all minimum sizes are accounted for. This is expressed as a percentage from 0 (the default) to 100 (e.g. 37%). The last partition receives all remaining free space up to its maximum size no matter what percentage is specified.
Display, respectively, the current label, the default label and the default auto allocation for sd0:
# disklabel sd0 # disklabel -d sd0 # disklabel -A sd0
Write the default auto allocation to sd0:
# disklabel -wA sd0Edit the label for the disk with DUID 3eb7f9da875cb9ee:
# disklabel -E
3eb7f9da875cb9eeRestore the label for sd0 from information in mylabel:
# disklabel -R sd0
mylabelPut largest contiguous area of free space on sd0 into a single RAID partition:
# echo 'RAID *' | disklabel -wAT-
sd0Write the auto allocation defined in /template to sd0:
# disklabel -wAT/template
sd0A template file that results in an auto allocation similar to the default one for a disk with 5GB of free space is:
| / | 800M–2G | 5% |
| swap | 80M–256M | 10% |
| /usr | 1300M–3G | 75% |
| /home | 256M–2G | 10% |
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.
softraid(4), disklabel(5), disktab(5), installboot(8), scan_ffs(8)
The disklabel utility appeared in
4.3BSD-Tahoe.
The maximum disk and partition size is 64PB.
On some machines, such as Sparc64, partition tables may not exhibit the full functionality described above.
| March 22, 2024 | openbsd |