p There are several forms of the command that read (display), install, or edit the label on a disk. Each form has an additional option, .Fl r , which causes the label to be read from or written to the disk directly, rather than going through the system's in-core copy of the label. This option may allow 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. Any special effects of the .Fl r flag are described with the affected commands.
p The .Fl F option indicates that .Nm should treat .Ar disk as if it is a regular file, instead of as if it is a block device, for the purposes of reading and writing a disklabel.
p The .Fl I option is similar to the .Fl r option but provides defaults instead of failing with an error, if there is no existing disklabel on the disk.
p The first form of the command (read) is used to examine the label on the named disk drive (e.g.,
a sd0 or
a /dev/rsd0c ) . It will display all of the parameters associated with the drive and its partition layout. Unless the .Fl r flag 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 flag is given, the label from the raw disk will be displayed rather than the in-core label. If the .Fl t flag is given, then the label will be formatted as a .Xr disktab 5 entry.
p The second form of the command, with the .Fl w flag, is used to write a standard label on the designated drive. The required arguments to .Nm are the drive to be labelled (e.g.,
a sd0 ) , 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 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. If the disk does not already have a label, the .Fl r flag must be used. In either case, the kernel's in-core label is replaced.
p An alternate .Xr disktab 5 file may be specified with the .Fl f Ar disktab option.
p An existing disk label may be edited by using the .Fl e flag. The label is formatted and then supplied to an editor for changes. If no editor is specified in an .Ev EDITOR environment variable, .Xr vi 1 is used. When the editor terminates, the formatted label is reread and used to rewrite the disk label.
p Labels can also created interactively using the .Fl i flag.
p The .Fl C flag causes the partition offset and size values to be displayed in .Aq cylinder/track/sector format. Note that, regardless of whether .Fl C was specified, this format is always accepted by .Nm on input with either the .Fl e or .Fl R flag.
p With the .Fl R flag, .Nm is capable of restoring a disk label that was formatted in a prior operation and saved in an ascii file. 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 .Ar # and newline.
p The .Fl NW flags for .Nm explicitly disallow and allow, respectively, writing of the pack label area on the selected disk.
p Previous versions of .Nm could update the bootstrap code on some architectures. This functionality has been subsumed by .Xr installboot 8 . .Sh EXIT STATUS The exit status of .Nm is set to indicate any errors or warnings. The values used are: l -tag -width indent t 0 The .Nm utility has completed successfully. t 1 A fatal error has occurred, such as unknown options passed on the command line, or writing the disklabel failed. t 4 An I/O error of some sort occurred. t 101..n One or more warnings occured while reading the disklabel. Subtract 100 to get the number of warnings detected. .El .Sh FILES l -tag -width /etc/disktab -compact t Pa /etc/disktab .El .Sh EXAMPLES .Dl disklabel sd0
p Display the in-core label for sd0 as obtained via
p .Dl disklabel -w -r /dev/rsd0c sd2212 foo
p Create a label for sd0 based on information for .Dq sd2212 found in
a foo as the disk pack label. If you do not have an entry for your disk in
a /etc/disktab , you can use this style to put an initial label onto a new disk. Then dump the label to a file (using .Em disklabel sd0 \*[Gt] .Em protofile ) , editing the file, and replacing the label with .Em disklabel -R sd0 .Em protofile .
p .Dl disklabel -e -r sd0
p Read the on-disk label for sd0, edit it and reinstall in-core as well as on-disk.
p .Dl disklabel -e -I sd0
p As previous, but don't fail if there was no label on the disk yet; provide some default values instead.
p .Dl disklabel -i -I sd0
p As previous, only use the built-in interactive editor.
p .Dl disklabel -R sd0 mylabel
p Restore the on-disk and in-core label for sd0 from information in
a mylabel . .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 .Dq 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 .Dq a partition. .Sh SEE ALSO .Xr disklabel 5 , .Xr disktab 5 , .Xr dkctl 8 , .Xr fdisk 8 , .Xr installboot 8 , .Xr mbrlabel 8 , .Xr mscdlabel 8 .Sh BUGS If the disk partition is not specified in the disk name (i.e., .Dq xy0 instead of .Dq /dev/rxy0c ) , .Nm will construct the full pathname of the disk and use the .Dq d partition on i386, hpcmips, or arc, and the .Dq c partition on all others.
p On the sparc, sparc64, sun2, and sun3 .Nx systems, the size of each partition must be a multiple of the number of sectors per cylinder (i.e., each partition must be an integer number of cylinders), or the boot ROMs will declare the label invalid and fail to boot the system.
p In addition, the .Fl r option should never be used on a sparc, sparc64, sun2 or sun3 system boot disk - the .Nx kernel translates the .Nx disk label into a SunOS compatible format (which is required by the boot PROMs) when it writes the label. Using the .Fl r flag causes .Nm to write directly to disk, and bypass the format translation. This will result in a disk label that the PROMs will not recognize, and that therefore cannot be booted from.