disklabel(8) System Manager's Manual disklabel(8)
disklabel - Reads and writes disk pack label
/sbin/disklabel [-r] disk
/sbin/disklabel -p disk [disk_type]
/sbin/disklabel -w [-r] [-t ufs | advfs] disk disktype [packid] [primary-boot secondary-boot]
/sbin/disklabel -wrn disk disktype [packid]
/sbin/disklabel -e [-r] disk
/sbin/disklabel -R [-r] [-t ufs | advfs] disk protofile [disktype | primary-boot secondary-boot]
/sbin/disklabel [-N | -W] disk
/sbin/disklabel -z disk
/sbin/disklabel -s partition fstype
/sbin/disklabel [-r] -f image_file
/sbin/disklabel [-w] -f image_file [-t cdfs|ufs|advfs]
[packid] primary_boot secondary_boot
/sbin/disklabel -e -f image_file
Edits an existing label. Specifies the type of image file for operations. The default image file type is cdfs, to indicate that the image
file was created in ISO 9660 Rock Ridge format. The cdfs default applies only when the -f flag is used. Writes an initial label to a disk
which will then be labeled, but non-bootable. Disallows writing of the pack label area on the specified disk. (See -W.) Prints label
parameters for the specified disk to stdout. Reads or writes the label directly to or from the disk, rather than operating on the in-mem-
ory copy of the label. Restores a disk label that was formatted in a prior operation and saved in an ASCII file. Sets the file system
type (fstype) field in the disk label. Specifies which type of the local file system the boot blocks describe, UFS, AdvFS, or CDFS.
Writes a standard label on the designated drive. Allows writing of the pack label area on the specified disk. (See -N.) Zeros (clears)
the disk label.
The disklabel command can be used to install, examine, or modify the label on a disk drive or pack. The disk label contains information
about the disk, such as type, physical parameters, and partitioning.
The disklabel command can be used to change the drive identification or the disk partitions on the drive, or to replace a damaged label or
bootstrap. The disk label is located on one of the first sectors of each disk (usually block 0). On machines that require a block-0 boot-
strap, the label is inserted into the bootstrap program.
The disk argument specifies the disk (for example, dsk0 or /dev/rdisk/dsk0a). If you do not specify the disk partition, disklabel uses the
first partition that has a zero offset. Typically, this is the a or c partition. Note that if the full path name is used, it must be a
character special device name and not the block device name.
The disktype argument specifies the type of disk. The /etc/disktab file contains a list of disk types and their parameters and partitions.
If you want disks that are the same type to have different partition parameters, you must have separate /etc/disktab file entries describ-
ing each disk, or you must edit the disks' labels after installation with the -e flag. If your disk type is not specified in the
/etc/disktab file, disklabel uses the default partition information in the driver.
There are two copies of a disk label, one located on the disk and one located in system memory. Because it is faster to access system mem-
ory than to perform I/O, when a system recognizes a disk, it copies the disk label into memory.
The -r option causes the label to be read from or written to the disk directly, instead of reading the system's in-memory copy of the
label. When writing, the in-memory copy is also updated if the parameters are valid. The -r option must be used if there is no label
already on the disk. 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.
The first form of the command is used to examine the label on the specified disk drive. It displays all of the parameters associated with
the drive and its partition layout. If the disk has no label or if the partition types on the disk are incorrect, the kernel may have con-
structed or modified the label. If you specify the -r flag, the label from the raw disk is displayed instead of the in-memory label.
The -p option prints the disklabel parameters from /etc/disktab for a specified disk to stdout. The type of disk is obtained directly by
querying the disk special file. If there is no matching entry in /etc/disktab for the obtained type, disklabel uses the default partition
information in the driver. If the optional disktype parameter is specified, it takes precedence over the disk special file, and the infor-
mation will be obtained from /etc/disktab if a matching entry is found for the specified type. If no matching entry is found, the default
partition information from the driver will be used as described above.
The second form of the command, with the -w flag, writes a standard label on the designated drive. You must specify the disk and the disk
type as described in the /etc/disktab file. The optional packid argument specifies a pack identification string that contains up to 16
characters. Use quotes around the packid argument if it contains blanks. If you specify the -r flag with the -w flag, the disk sectors
that contain the label and bootstrap are written directly; otherwise the existing label is updated in place without modifying the boot-
strap. In either case, the kernel's in-memory label is replaced. You can specify alternate versions of the bootstrap files, using the
primary-boot and secondary-boot arguments. If an alternate bootstrap is not specified, the standard bootstrap is used.
If you specify the -f flag with the -w flag, the disk label is written to the specified image file. The default bootstrap programs are
for the CDFS file system. You can use alternative bootstrap programs by specifying the -t flag and indicating the file system type in it.
Alternatively, you can specify primary and secondary boot arguments.
The bootstrap programs are located in /mdec. The names of the bootstrap programs can be specified in the /etc/disktab file, but if they
are not specified, the default names use either the basenameboot syntax for the primary (block 0) bootstrap or the bootbasename syntax for
the secondary (blocks 1-15 for UFS and blocks 64-95 for AdvFS) bootstrap, where the basename is the type of disk, such as, rz or re. For
example, the names are /mdec/rzboot and /mdec/bootrz for a UFS rz-type disk. If you specify the -t advfs option, the default names use
either the basenameboot.advfs syntax for the primary bootstrap or the bootbasename.advfs syntax for the secondary bootstrap (blocks 64-95),
for example, /mdec/rzboot.advfs and /mdec/bootrz.advfs.
To write an initial label to a non-bootable disk, use the -n option with the -wr options. When using this form of the command, specify the
disk and disktype. You can also specify the optional packid.
You can edit an existing disk label, using the -e flag. The label is read from the in-memory kernel copy, or directly from the disk if the
-r flag is specified. The label is formatted and then sent to an editor. If no editor is specified with the EDITOR environment variable,
the vi editor is used. If vi is not available, the ed editor is used.
Note that if an unexpected error occurs during the ed editing session, the following message will appear: Warning, edit session exited
You should re-edit the disk label to ensure that you made the modifications.
When the editor terminates, the formatted label is reread and used to rewrite the disk label.
If you specify the -R flag, disklabel restores a disk label that was previously formatted and saved in an ASCII file. The protofile argu-
ment specifies the prototype file that is used to create the label. This file should be in the same format that is produced when reading
or editing a label. Comments are indicated with number signs (#) and newline. If you also specify the -r option, a block-0 bootstrap is
installed on the machines that use that type of bootstrap; either the disk type or the names of the bootstrap files must be specified on
The -N flag does not allow you to write to the disk pack label area. The -W flag allows you to write to the disk pack label area. The
label sector is always write-protected when the drive is first opened; the write-enable flag set by -W persists only until all partitions
on the drive are closed.
Note that if you replace an existing label with a new label, the existing partition information will be copied to the new label if the new
label's partition is marked unused. This may cause disklabel to fail and can be avoided by first using the -z option to clear the disk
You can use the -s option to change the file system type (fstype) in the disk label. Specify the partition whose type you are changing and
the new fstype. If a partition no longer contains valid file system data, use the -s option to set the fstype to unused. Or, if the fstype
is unused, but the partition does contain valid data, use the -s option to set a valid fstype. This prevents inadvertent loss of data, as
applications like newfs, mkfdmn, voldisk, and swapon check the fstype field in the disk label for the partition usage.
You can set the fstype field to be any of the following: Available for use. Used as swap space. Used by a UNIX file system. Used by an
AdvFS file system. Used by a CDFS file system. Used by an LSM nopriv disk. Used for an LSM private region. Used for an LSM public
region. Used by an LSM simple disk. Used by a database. Used for raw data.
The kernel device drivers do 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 or c partition of the disk while it is open. This sometimes requires the desired label to be set in two steps, the first one cre-
ating at least one other partition, and the second setting the label on the new partition while shrinking the a partition.
The kernel does not allow file system information to be set unused for open partitions. For example, if you want to set the a par-
tition to unused, you must write the label using a different partition (such as the c partition). For example: # disklabel -w
If a file system exists for an open partition, the existing file system information is copied to the new label. This preserves the
existing information without returning an error. When using LSM, if you try to recover a replaced mirror disk and the disk has been
replaced with a new disk, disklabel fails with the following error, when attempting to write the new label:
disklabel: ioctl DIOCSDINFO: open partition would move or shrink
Remove the disk from LSM before attempting to write the new disklabel: # voldisk rm rz8
# disklabel -wr rz8 rz28
The following example clears the existing label, writes a new label, and then displays the current label: # disklabel -z rz6 # disklabel
-rw rz6 rzw7s # disklabel -r rz6 # /dev/rdisk/dsk6a: type: SCSI disk: rzw7s label: flags: bytes/sector: 512 sectors/track: 71 tracks/cylin-
der: 15 sectors/cylinder: 1065 cylinders: 1900 sectors/unit: 2023500 rpm: 3600 interleave: 1 trackskew: 0 cylinderskew: 0 headswitch: 0
# milliseconds track-to-track seek: 0 # milliseconds drivedata: 0
8 partitions: # size offset fstype [fsize bsize cpg]
a: 131072 0 unused 1024 8192 # (Cyl. 0 - 123*)
b: 262144 131072 unused 1024 8192 # (Cyl. 123*- 369*)
c: 2023500 0 unused 1024 8192 # (Cyl. 0 - 1899)
d: 163840 1703936 unused 1024 8192 # (Cyl. 1599*- 1753*)
e: 32768 1867776 unused 1024 8192 # (Cyl. 1753*- 1784*)
f: 122956 1900544 unused 1024 8192 # (Cyl. 1784*- 1899*)
g: 1310720 393216 unused 1024 8192 # (Cyl. 369*- 1599*)
h: 319564 1703936 unused 1024 8192 # (Cyl. 1599*- 1899*) Note that the asterisks in the cpg column indicate that the beginning
or ending cylinders do not fall exactly on a block boundary.
The following example marks partition dsk4c for use by a database: # disklabel -s dsk4c database
The following example marks partition dsk4c as unused, which means it is available for use. # disklabel -s dsk4c unused
The following example shows how a disk label is written to a a CDFS image file and then read from it:
# disklabel -w -f system.image
# disklabel -f system.image # system.image: type: unknown disk: CDROM label: flags: removeable bytes/sector: 512 sectors/track: 1728
tracks/cylinder: 1 sectors/cylinder: 1 cylinders: 1 sectors/unit: 1728 rpm: 300 interleave: 1 trackskew: 0 cylinderskew: 0 headswitch: 0
# milliseconds track-to-track seek: 0 # milliseconds drivedata: 0
3 partitions: # size offset fstype [fsize bsize cpg]
a: 1728 0 CDFS # (Cyl. 0 - 1727)
b: 0 0 unused 0 0 # (Cyl. 0 - -1)
c: 1728 0 unused 0 0 # (Cyl. 0 - 1727) #
Contains device special files, such as disk0a. Contains raw device special files, such as disk1c. Contains information about disks and
drives. Primary bootstrap programs. Secondary bootstrap programs.
Files: disklabel(4), disktab(4), rz(7), ra(7)
Functions: check_usage(3), set_usage(3) delim off