Index Index for
Section 8
Index Alphabetical
listing for D
Bottom of page Bottom of
page

disklabel(8)

NAME

disklabel - Reads and writes a disk pack label and formats disk partitions

SYNOPSIS

/sbin/disklabel [-r] [disk] /sbin/disklabel [-r] -f filename /sbin/disklabel -w disk [type[packid]] /sbin/disklabel -wr [-n] [-t {ufs | advfs}] [disk] [type [packid] [xxboot bootxx]] /sbin/disklabel -wr [-n] [-t {ufs | advfs | cdfs}] -ffilename [packid] [xxboot bootxx] /sbin/disklabel -e [-r] disk /sbin/disklabel -e -f filename /sbin/disklabel -R [-t {ufs | advfs}] disk protofile /sbin/disklabel -Rr [-t {ufs | advfs}] disk protofile { type | xxboot bootxx } /sbin/disklabel [-N | -W] disk /sbin/disklabel -z disk /sbin/disklabel -s -F disk fstype /sbin/disklabel -p disk [type]

OPTIONS

-e Edits an existing label. -f filename 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 option is used. -F Enables you to force an override of the current file system type. You can set the file system type by using the -s option. If the target disk partition is in use, the disklabel command displays a warning message and does not set a file system type. This safety feature prevents you from accidentally overwriting any partition that is in use. If you are certain that you want to set a new file system type, you can choose to ignore the warning and specify the -F option to override the safety feature. -n Writes an initial label to a disk which is then labeled, but not bootable. Use the -wr option alone to create a bootable disk. -N Disallows writing of the pack label area on the specified disk. (See the -W option.) -p Prints label operands for the specified disk to stdout. -r Reads or writes the label directly to or from the disk, rather than operating on the in-memory copy of the label. Used with the -w option, this option creates a bootable disk. -R Restores a disk label that was formatted in a prior operation and saved in an ASCII file. -s Sets the file system type (fstype) field in the disk label. See the -F option, which enables you to force an override of any existing settings. -t ufs|advfs|cdfs Specifies which type of the local file system the boot blocks describe, UFS, AdvFS, or CDFS. -w Writes a standard label on the designated drive. Used with the -r option, this option creates a bootable disk. -W Allows writing of the pack label area on the specified disk. (See -N.) -z Zeros (clears) the disk label.

PARAMETERS

disk Identifies the disk on which you want to perform a labelling operation. You use the disk's device special file name, such as dsk0 or /dev/rdisk/dsk0a. If you do not specify the disk partition, the disklabel command uses the first partition that has a zero offset. Typically, this is the a or c partition. If the full path name is used, it must be a character special device name and not the block device name. filename Specifies an image file name that the disklabel command reads to perform the specified operation. type Specifies the type (or model) of disk. This parameter is optional. The /etc/disktab file contains a list of disk types and their operands and partitions. If you want disks that are the same type to have different partition operands, create separate /etc/disktab file entries describing each disk, or edit the disks' labels after installation with the -e option. See disktab(4) for more information. If your disk type is not specified in the /etc/disktab file, the disklabel command uses the default partition information in the driver. You can also use the following command to display disk types: # hwmgr -show comp | grep WWID COMPONENT NAME SCSI-WWID:0410003a:"DEC RZ26L (C) DECPCB=ZG51569480 ; HDA=000051892202" SCSI-WWID:04100024:"COMPAQ HB00931B93 WT7050055125" SCSI-WWID:0c000008:0060-9487-2a12-4ed2 The preceding output is edited to show only the COMPONENT NAME column. The disk type is contained in the quoted string of the worldwide identifier (WWID), which is the manufacturer's model information. This data appears under the COMPONENT NAME column. The first field contains the manufacturer's code, such as COMPAQ The second field contains the disk type, such as RZ26L or HB00931B93. The example device shown on the last line of the output contains no information on the disk type. In such cases, you cannot specify a type, and the disklabel command uses the default partition information in the device driver. See hwmgr(8) for more information. packid Specifies an optional pack identification string containing up to 16 characters. Use quotes (" ") around the packid parameter if it contains space characters. protofile Specifies a prototype file that is used to create the label. This file is in the same format as the output produced when you read or edit a label. You can add comments by preceding the comment string with a pound sign (#) and ending it by using the newline character. xxboot The primary bootstrap program which must be a valid boot file residing in the /mdec directory. bootxx The secondary bootstrap program which must be a valid boot file residing in the /mdec directory. fstype The file system type, which can be any of the options listed in the following table: File System Types Usage Description Value of fstype unused Available for use swap Swap space UNIX file system 4.2BSD, ufs, or UFS AdvFS AdvFS file system. This string is case sensistive. You cannot use advfs. cdfs CDFS file system LSMnoprv An LSM nopriv disk LSMpriv An LSM private region LSMpubl An LSM public region LSMsimp An LSM simple disk database A database raw Raw data

DESCRIPTION

Use the disklabel command to install, examine, or modify the label on a disk drive or pack. The disk label contains information about the disk, such as its type and physical operands. See rz(7) for information on SCSI disk partitions. The diskconfig graphical user interface (GUI) provides an alternate way to label and partition disks. If you need to create custom partition sizes on a disk, the diskconfig command provides you with the easiest method. See diskconfig(8) for more information. You also use the disklabel command to do the following tasks: · Change the drive identification · Modify the size and usage of disk partitions on the drive · Replace a damaged label · Change the bootstrap program These tasks are referred to as formatting operations on other operating systems. The disk label is located on one of the first sectors of each disk, which is usually block 0 (zero). On systems that require a block-zero bootstrap, the label is inserted into the bootstrap program. 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 memory than to perform I/O, when a system recognizes a disk, it copies the disk label into memory. Reading and Writing a Label Use the -r option to read the label from or write it to the disk directly, instead of reading the system's in-memory copy of the label. When writing a label, the in-memory copy is also updated provided the label operands are valid. You must use the -r option if a disk has no label. This option might enable you to install a label on a disk that does not have kernel support for a label, such as when labels are first installed on a system. You also use the -r option to examine the label on the specified disk drive. The disklabel command displays all of the operands 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 might have constructed or modified the label. Use the -w option to write a standard label on the designated drive. You must specify the disk name. The type and packid arguments are optional. If you specify the -r option with the -w option, the disk sectors that contain the label and bootstrap are written directly; otherwise the existing label is updated in place without modifying the bootstrap. In either case, the kernel's in-memory label is replaced. You can specify alternate versions of the bootstrap files, using the xxboot and bootxx arguments. If an alternate bootstrap is not specified, the standard bootstrap is used. See Specifying Bootstrap Programs for more information. The -wr options create a bootable disk by default and you must specify the -n option to create a non bootable disk label. When using the -n option, you can choose to specify the disk, the type, and the packid depending on how you want the disk labeled. The -N option disables writing to the disk pack label area. The -W option enables writing to the disk pack label area. The label sector is always write-protected when the drive is first opened; the write-enable option set by -W persists only until all partitions on the drive are closed. Specifying Bootstrap Programs If you specify the -ffilename option with the -w option, 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 option and indicating the file system type, such as ufs. Alternatively, you can specify primary and secondary (xxboot and bootxx) boot arguments. The bootstrap programs are located in the /mdec directory. You can specify the file names of the bootstrap programs in the /etc/disktab file. If you do not specify the names, the syntax of the default file names is as follows: · xxboot - The primary bootstrap, loaded at block 0 (zero). · bootxx - The secondary bootstrap, loaded as follows: -- Blocks 1-15 for the UFS file system -- Blocks 64-95 for the AdvFS file system The replaceable string, xx, specifies the type of disk, such as, rz or re. For example, the names are /mdec/rzboot and /mdec/bootrz for a UFS type rz disk. Note In Version 5.0 and later the rz device naming convention for SCSI disks changed to a dsk device naming convention. However, rz basenames still apply to SCSI disks. The /mdec/*rz* files map to any dsk device. See System Administration for information on device naming. See hwmgr(8) for information on finding devices and device names. For example, If you specify the -t advfs option when labeling dsk1, the disklabel command uses the /mdec/rzboot.advfs and /mdec/bootrz.advfs files by default. Printing a Label Use the -p option to print the disklabel operands for a specified disk from the /etc/disktab file to stdout. The type of disk is obtained directly by querying the disk special file. If there is no matching entry in the /etc/disktab file for the obtained type, the disklabel command uses the default partition information in the driver. If the optional type parameter is specified, it takes precedence over the disk special file, and the information is obtained from /etc/disktab providing a matching entry is found for the specified type. If no matching entry is found, the disklabel command uses the default partition information from the device driver. Editing a Label You can edit an existing disk label by using the -e option. The label is read from the in-memory kernel copy, or directly from the disk if you specify the -r option. 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. If an unexpected error occurs during the ed editing session, the following message is displayed: Warning, edit session exited abnormally! You MUST re-edit the disk label to ensure that the modifications you made were saved correctly. When the editor terminates, the formatted label is reread and is used by the disklabel command to rewrite the disk label. Restoring a Label If you specify the -R option, the disklabel command restores a disk label that was previously formatted and saved in an ASCII file. You can also specify a prototype file that is used to resotre the label. If you also specify the -r option, a block-0 bootstrap is installed on systems that use that type of bootstrap. You must specify either the disk type or the names of the bootstrap files when labelling a disk for use on such systems. See the Owner's manual for your system for more information. 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 might cause disklabel to fail and you can avoid this failure by using the -z option to first clear the disk label before performing the restoration operation. Changing the File System Type Use the -s option to change the file system type (fstype) in the disk label. Specify the disk partition, such as dsk10c, and the new value for the fstype parameter, such as ufs. If a partition no longer contains valid file system data, use the -s option to set the fstype parameter to unused. Or, if the fstype parameter is unused, but the partition does contain valid data, use the -s option to set a valid value for the fstype parameter. This prevents inadvertent loss of data, as applications such as newfs, mkfdmn, voldisk, and swapon check the fstype field in the disk label for the partition usage. If a partition is already in use, the diskabel command might display a warning message and the partition file system type does not changed. You can force an override of this safety feature by using the -F option with the -s option.

NOTES

· 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 the partition 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 that the desired label be set in two steps, the first one creating at least one other partition, and the second one 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 partition to unused, you must write the label using a different partition (such as the c partition). For example: # disklabel -w /dev/rdisk/dsk0c 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, the disklabel command 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 label: # voldisk rm dsk8 # disklabel -wr dsk8

EXAMPLES

1. If you enter the disklabel command but do not specify any options, the following command usage help is displayed: # disklabel Usage: Read 'in-memory copy' of label: disklabel disk Read 'on-disk copy' of label: disklabel -r disk Read label from image file: disklabel [-r] -f filename Write over existing label: disklabel -w disk [type [packid]] Write initial label on disk: disklabel -wr [-n] [-t {advfs | ufs}] disk [type [packid] [xxboot bootxx]] Write label to image file: disklabel -wr [-n] [-t {advfs | ufs | cdfs}] -f filename [packid] [xxboot bootxx] Edit label: disklabel -e [-r] disk Edit label on image file: disklabel -e -f filename Restore label: disklabel -R [-t {advfs | ufs}] disk protofile disklabel -Rr [-t {advfs | ufs}] disk protofile [type | xxboot bootxx] Write disable/enable label: disklabel [-N | -W] disk Zero label: disklabel -z disk Set partition fstype: disklabel -s [-F] disk fstype Print Default label: disklabel -p disk [type] 2. The following example indicates which variants of the device special file name are acceptable. The disk is labeled with partitions a, b, and g: # disklabel /dev/disk/dsk1 disklabel: /dev/disk/dsk1: No such file or directory # disklabel /dev/disk/dsk1c disklabel: not a character device: /dev/disk/dsk1c # disklabel /dev/disk/dsk1a disklabel: not a character device: /dev/disk/dsk1a # disklabel /dev/rdisk/dsk1 disklabel: /dev/rdisk/dsk1: No such file or directory # disklabel /dev/rdisk/dsk1c # /dev/rdisk/dsk1c: type: SCSI disk: RZ28M label: . . . # disklabel dsk1 # /dev/rdisk/dsk1c: type: SCSI disk: RZ28M label: flags: . . . # disklabel dsk1g # /dev/rdisk/dsk1g: type: SCSI disk: RZ28M label: . . . # disklabel /dev/rdisk/dsk1g # /dev/rdisk/dsk1g: type: SCSI disk: RZ28M label: flags: . . . # disklabel /dev/disk/dsk1g disklabel: not a character device: /dev/disk/dsk1g . . . 3. The following example uses only the -r (read) option to read and display the on-disk copy of the disk label: # disklabel -r dsk1 # /dev/rdisk/dsk1c: type: SCSI disk: RZ28M label: flags: bytes/sector: 512 sectors/track: 99 tracks/cylinder: 16 sectors/cylinder: 1584 cylinders: 2595 sectors/unit: 4110480 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 # ~Cyl values a: 262144 0 4.2BSD 1024 8192 16 # 0 - 165* b: 401404 262144 swap # 165*- 418* c: 4110480 0 unused 1024 8192 # 0 - 2594 d: 1060869 663547 unused 1024 8192 # 418*- 1088* e: 1191936 1724416 unused 1024 8192 # 1088*- 1841* f: 1194128 2916352 unused 1024 8192 # 1841*- 2594 g: 3446932 663548 4.2BSD 1024 8192 16 # 418*- 2594 h: 1790096 2320384 unused 1024 8192 # 1464*- 2594 4. The following command indicates an error caused by attempting a labeling operation on a disk that is in use. In this case, a partition on the disk was still mounted when the command was issued: # disklabel -rw dsk1 disklabel: ioctl DIOCSDINFO: Open partition would move or shrink Use alternate partition 5. The following example clears the existing label, writes a new label, and then displays the current label. This disk is the same disk used in Example 3, and you can compare the differences in the label: # disklabel -rw dsk1 # disklabel -r dsk1 # /dev/rdisk/dsk1c: type: SCSI disk: RZ28M label: flags: bytes/sector: 512 sectors/track: 99 tracks/cylinder: 16 sectors/cylinder: 1584 cylinders: 2595 sectors/unit: 4110480 rpm: 5411 interleave: 1 trackskew: 12 cylinderskew: 25 headswitch: 0 # milliseconds track-to-track seek: 0 # milliseconds drivedata: 0 8 partitions: # size offset fstype fsize bsize cpg # ~Cyl values a: 131072 0 unused 0 0 # 0 - 82* b: 401408 131072 unused 0 0 # 82*- 336* c: 4110480 0 unused 0 0 # 0 - 2594 d: 1191936 532480 unused 0 0 # 336*- 1088* e: 1191936 1724416 unused 0 0 # 1088*- 1841* f: 1194128 2916352 unused 0 0 # 1841*- 2594 g: 1787904 532480 unused 0 0 # 336*- 1464* h: 1790096 2320384 unused 0 0 # 1464*- 2594 6. The following example marks partition dsk1c for use by the UFS file system (4.2BSD). The second command issued attempts to change the usage to swap space but instead returns an error message stating that the partition is in use. This safety feature prevents you from losing data by accidentally overwriting in-use partitions: # disklabel -s dsk1 ufs # disklabel -s dsk1 swap disklabel: /dev/rdisk/dsk1c is marked in use for 4.2BSD by the disklabel. disklabel: Use -F option to force an override. The following command overrides the safety feature and the output shows than usage of partition dsk1c is changed: # disklabel -s -F dsk1 swap # disklabel -r dsk1 # /dev/rdisk/dsk1c: type: SCSI disk: RZ28M . . . # size offset fstype fsize bsize cpg # ~Cyl values c: 4110480 0 swap # 0 - 2594 . . . 7. The following example marks partition dsk4c as unused, which means it is available for use: # disklabel -s dsk4c unused 8. The following example shows how a disk label is written to a CDFS image file and then read from it: # disklabel -r dsk1 > system.image # disklabel -w -f system.image # disklabel -f system.image # system.image: type: unknown disk: CDROM label: flags: removeable bytes/sector: 512 sectors/track: 2 tracks/cylinder: 1 sectors/cylinder: 1 cylinders: 1 sectors/unit: 2 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 # ~Cyl values a: 2 0 CDFS # 0 - 1 b: 0 0 unused 0 0 # 0 - 0

FILES

/dev/disk Contains device special files, such as disk0a /dev/rdisk Contains raw device special files, such as disk1c /etc/disktab Contains information about disks and drives /mdec/xxboot Contains primary bootstrap programs /mdec/bootxx Contains secondary bootstrap programs

SEE ALSO

Commands: diskconfig(8), hwmgr(8) Files: disklabel(4), disktab(4) Misc: rz(7), ra(7) Functions: check_usage(3), set_usage(3)

Index Index for
Section 8
Index Alphabetical
listing for D
Top of page Top of
page