disklabel can be used to install, examine, or modify 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.
The
-e,
-i,
-l,
-R,
-w,
-N, and
-W options determine the basic operation. If none are specified the label is displayed.
-e
Edit the existing label (using
EDITOR) and write it back to the disk. If
EDITOR is undefined, then
vi(1) is used.
-i
Interactively update the existing label and write it back to the disk.
-l
Show all known file system types (those that can be specified along a partition within the label) and exit.
-R
Write (restore) a label by reading it from protofile. The file should be in the same format as the default output.
-w
Write a standard label for the specified
disktype. See
disktab(5).
-N
Disallow writes to the disk sector that contains the label. This is the default state.
-W
Allow writes to the disk sector that contains the label. This state may not persist if no programs have the disk open.
The majority of the rest of the options affect more than one form of the command:
-A
Read all labels from the disk, including ones deleted with disklabel -D. Implies -r.
-C
Output the partition offset and size values in <cylinder/head/sector> format. Note this format is always accepted on input with either the -e or -R flags.
-D
Delete all existing labels (by 1's complementing the magic number) before writing any labels to their default location. Implies -r. If -D is specified without a request to write the label, then existing labels are just deleted.
-F
Treat
disk as a regular file. This suppresses all
ioctl(2) calls, and is the default if
disk is a regular file.
disk is always opened using
opendisk(3) even if
-F is specified. Implies
-r.
-I
If a label cannot be read from disk request the default one from the kernel. Implies -r.
-f disktab
Specify the name of a file to use instead of /etc/disktab.
-r
Read/write the disk directly rather than using
ioctl(2) requests on the kernel. When writing a label, the kernel will be told about the label before the label is written and asked to write afterwards. This is the historic behaviour and can be supressed by specifying
-F.
-v
Be verbose about the operations being done, in particular the disk sectors being read and written. Specifying -v more than once will increase the verbosity.
On systems that expect to have disks with MBR partitions (see
fdisk(8))
disklabel will find, and update if requested, labels in the first 8k of type 169 (
NetBSD) MBR labels and within the first 8k of the physical disk. On other systems
disklabel will only look at the start of the disk. The offset at which the labels are written is also system dependent.
disklabel will detect byteswapped labels, but currently cannot display them.
Previous versions of
disklabel could update the bootstrap code on some architectures. This functionality has been subsumed by
installboot(8).