5    Administering Disks

This chapter discusses system administration tasks related to the administration of disks, including:

See the AdvFS Administration manual for information on administering AdvFS.

5.1    Partitioning Disks Using the Disk Configuration Utility

The Disk Configuration graphical user interface (GUI), diskconfig, enables you to perform the following tasks:

See diskconfig(8) for information on invoking the Disk Configuration GUI (diskconfig). An online help volume describes how you use the GUI.

Invoke the Disk Configuration GUI using either of these methods:

Caution

Disk Configuration displays appropriate warnings when you attempt to change partition sizes. However, you should plan the changes in advance to ensure that you do not overwrite any required data. Back up any data partitions before attempting this task.

A window titled Disk Configuration on hostname is displayed. This is the main window for the Disk Configuration application, and lists each disk on the system, and gives the following information for each disk:

Select a device in the list then select Configure... to configure a specific disk; an alternate method is double clicking on the device in the list. Two windows, Configure Partitions and Partition Table, open.

Disk Configuration: Configure Partitions: device name device type

This window allows you to set the start address, end address, size, and usage options for the disk partitions.

Disk Configuration: Partition Table: device name device type

This window displays the current partitions, their start addresses, their end addresses, and their sizes.

See the online help for more information on these windows.

After making partition adjustments, use the SysMan Menu options to mount any newly created file systems as follows:

  1. Add the new file system to the /etc/fstab file.

  2. Invoke the SysMan Menu. See Chapter 1 for further information.

  3. Select File Systems. Additional options are displayed.

  4. Select General File System Utilities. Additional options are displayed.

  5. Select Mount File Systems. The Mount File Systems main window opens.

  6. Select Mount an AdvFS/UFS file system, then select Next>. The Steps dialog box opens.

  7. Select Next>. The Select File System dialog box opens.

  8. Select the file system in the List of File Systems, then enter Next>. The Mount dialog box opens.

  9. Enter a mount point, such as /usr/newusers in the Mount Directory field.

    Alternatively, use Browse... to find and select a directory for the mount point.

  10. Select the Access Mode.

  11. Select Next>. The Summary dialog box opens.

  12. Select Finish.

  13. Select Exit to close the SysMan Menu.

Your new file system is now accessible.

5.1.1    Configure Partitions Window

This window provides the following information and options:

5.1.2    Partition Table Window

This window displays a bar-chart of the current partitions in use, their sizes, and the file system in use. You can toggle between the current partition sizes, the default table for this device, and the original (starting table) when this session started. If you make errors on a manual partition change, you can use this window to reset the partition table.

5.2    Manually Partitioning Disks

The following sections provide the information you need to change the partition scheme of your disks. In general, you allocate disk space during the initial installation or when adding disks to your configuration. Usually, you do not have to alter partitions; however, there are cases when it is necessary to change the partitions on your disks to accommodate changes and to improve system performance.

5.2.1    Utilities

These commands allow you to perform several disk maintenance tasks manually:

disklabel

Use this command 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. See disklabel(4) for more information on the /etc/disktab file.

newfs

Use this command to create a new UFS file system on the specified device. Do not use the newfs command to create Advanced File System (AdvFS) domains; use the mkfdmn command instead.

mkfdmn and mkfset

Use these commands to create Advanced File System (AdvFS) domains and filesets. See mkfdmn(8) for more information.

5.2.2    Using the disklabel Utility

The disk label provides detailed information about the geometry of the disk and the partitions into which the disk is divided. As root, you can change the label with the disklabel command. See disklabel(8) for information on command options.

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 the system boots, it copies the disk label into memory. Use the disklabel -r command to access the label on the disk directly instead of going through the in-memory label.

Caution

Before you change disk partitions, back up all the file systems if there is any data on the disk. Changing a partition overwrites the data on the old file system, destroying the data.

When changing partitions, remember that:

Caution

If partition a is mounted and you attempt to edit the disk label using device partition a, you cannot change the label. Furthermore, you do not receive any error messages indicating that the label is not written.

Before changing the size of a disk partition, review the current partition setup by viewing the disk label. The disklabel command allows you to view the partition sizes. The bottom, top, and size of the partitions are in 512-byte sectors.

To review the current disk partition setup, use the following disklabel command:

/sbin/disklabel -r device

Specify the device with its directory name (/dev) followed by the raw device name, drive number, and partition a or c. You can specify the disk unit and number, such as dsk1.

An example of using the disklabel command to view a disk label follows:

# disklabel -r /dev/rdisk/dsk3a 
type: SCSI
disk: rz26
label:
flags:
bytes/sector: 512
sectors/track: 57
tracks/cylinder: 14
sectors/cylinder: 798
cylinders: 2570
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   4.2BSD   1024  8192  16  # (Cyl.    0 - 164*)
 b:  262144  131072   unused   1024  8192      # (Cyl.  164*- 492*)
 c: 2050860       0   unused   1024  8192      # (Cyl.    0 - 2569)
 d:  552548  393216   unused   1024  8192      # (Cyl.  492*- 1185*)
 e:  552548  945764   unused   1024  8192      # (Cyl. 1185*- 1877*)
 f:  552548 1498312   unused   1024  8192      # (Cyl. 1877*- 2569*)
 g:  819200  393216   unused   1024  8192      # (Cyl.  492*- 1519*)
 h:  838444 1212416   4.2BSD   1024  8192 16   # (Cyl. 1519*- 2569*)

Take care when you change partitions because you can overwrite data on the file systems or make the system inefficient. If the partition label becomes corrupted while you are changing the partition sizes, you can return to the default partition label by using the disklabel command with the -w option, as follows:

# disklabel -r -w /dev/rdisk/dsk1a rz26

The disklabel command allows you to change the partition label of an individual disk without rebuilding the kernel and rebooting the system. Use the following procedure:

  1. Display disk space information about the file systems by using the df command.

  2. View the /etc/fstab file to determine if any file systems are designated as swap space.

  3. Examine the disk's label by using the disklabel command with the -r option. (See rz(7), ra(7), and disktab(4) for information on the default disk partitions.)

  4. Back up the file systems.

  5. Unmount the file systems on the disk whose label you want to change.

  6. Calculate the new partition parameters. You can increase or decrease the size of a partition. Also, you can cause partitions to overlap.

  7. Edit the disk label by using the disklabel command with the -e option to change the partition parameters, as follows:

    # /sbin/disklabel -e disk
    

    An editor, either the vi editor or that specified by the EDITOR environment variable, is invoked so you can edit the disk label, which is in the format displayed with the disklabel -r command.

    The -r option writes the label directly to the disk and updates the system's in-memory copy, if possible. The disk parameter specifies the unmounted disk (for example, dsk0 or /dev/rdisk/dsk0a).

    After you quit the editor and save the changes, the following prompt is displayed:

    write new label? [?]:
    

    Enter y to write the new label or n to discard the changes.

  8. Use the disklabel command with the -r option to view the new disk label.

5.2.3    Examining for Overlapping Partitions with the newfs Command

Commands to mount or create file systems, add a new swap device, and add disks to the Logical Storage Manager first verify whether the disk partition specified in the command already contains valid data, and whether it overlaps with a partition that is marked for use already. The fstype field of the disk label enables you to determine when a partition or an overlapping partition is in use.

If the partition is not in use, the command continues to execute. In addition to mounting or creating file systems, commands such as mount, newfs, fsck, voldisk, mkfdmn, rmfdmn, and swapon also modify the disk label, so that the fstype field specifies partition usage. For example, when you add a disk partition to an AdvFS domain, the fstype field is set to AdvFS.

If the partition is not available, these commands return an error message and ask if you want to continue, as shown in the following example:

# newfs /dev/disk/dsk8c 
WARNING: disklabel reports that basename,partition currently
is being used as "4.2BSD" data. Do you want to
continue with the operation and possibly destroy
existing data? (y/n) [n]

Applications, as well as operating system commands, can modify the fstype of the disk label, to indicate that a partition is in use. See check_usage(3) and set_usage(3) for more information.

5.3    Copying Disks

You can use the dd command to copy a complete disk or a disk partition; that is, you can produce a physical copy of the data on the disk or disk partition.

Note

Because the dd command is not meant for copying multiple files, copy a disk or a partition only to a disk that you are using as a data disk, or to a disk that does not contain a file system. Use the dump and restore commands, as described in Chapter 9, to copy disks or partitions that contain a UFS file system. Use the vdump and vrestore commands, as described in the AdvFS Administration manual, to copy disks or partitions that contain an AdvFS fileset.

The operating system protects the first block of a disk with a valid disk label because this is where the disk label is stored. As a result, if you copy a partition to a partition on a target disk that contains a valid disk label, you must decide whether you want to keep the existing disk label on that target disk.

If you want to maintain the disk label on the target disk, use the dd command with the skip and seek options to move past the protected disk label area on the target disk. The target disk must be the same size as or larger than the original disk.

To determine if the target disk has a label, use the following disklabel command:

# /sbin/disklabel -r target_disk

You must specify the target device directory name (/dev) followed by the raw device name, drive number, and partition c. If the disk does not contain a label, the following message is displayed:

Bad pack magic number (label is damaged, or pack is unlabeled)
 

The following example shows a disk that already contains a label:

# disklabel -r /dev/rdisk/dsk1c
type: SCSI
disk: rz26
label:
flags:
bytes/sector: 512
sectors/track: 57
tracks/cylinder: 14
sectors/cylinder: 798
cylinders: 2570
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 - 164*)
 b:  262144  131072  unused 1024 8192 # (Cyl.  164*- 492*)
 c: 2050860       0  unused 1024 8192 # (Cyl.    0 - 2569)
 d:  552548  393216  unused 1024 8192 # (Cyl.  492*- 1185*)
 e:  552548  945764  unused 1024 8192 # (Cyl. 1185*- 1877*)
 f:  552548 1498312  unused 1024 8192 # (Cyl. 1877*- 2569*)
 g:  819200  393216  unused 1024 8192 # (Cyl.  492*- 1519*)
 h:  838444 1212416  unused 1024 8192 # (Cyl. 1519*- 2569*)

If the target disk already contains a label and you do not want to keep the label, you must clear the label by using the disklabel -z command. For example:

# disklabel -z /dev/rdisk/dsk1c

To copy the original disk to the target disk and keep the target disk label, use the dd command, specifying the device directory name (/dev) followed by the raw device name, drive number, and the original and target disk partitions. For example:

# dd if=/dev/rdisk/dsk0c of=/dev/rdisk/dsk1c \
skip=16 seek=16 bs=512k