5    Using Device Commands and Utilities

The preceding chapters described generic hardware management tools that you use to manage many aspects of all devices, such as the hwmgr command described in Chapter 3. The following sections describe hardware management tools that are targeted at a particular kind of device and perform a specific task:

5.1    Finding Device Utilities

Many of the device utilities are documented elsewhere in this manual or at other locations in the documentation set. For example, utilities that enable you to configure network devices are documented in detail in the Network Administration: Services manual. Table 5-1 provides references to utilities, including those listed in this chapter. Other utilities are documented in reference pages. Table 5-2 provides references to utilities documented in the reference pages and also provides pointers to reference data such as the Section 7 interface reference pages.

Table 5-1:  Device Utilities Documented in the Manuals

Device Task Location
Processor Starting or Stopping System Administration
  Sharing Resources System Configuration and Tuning
  Monitoring System Administration
  Power Management System Administration, dxpower
  Testing Memory System Administration
  Error and Event Handling System Administration
SCSI buses Advanced Configuration and Management Section 5.2.1, scu
Disks Partitioning diskconfig, disklabel
  Copying Section 5.5, dd
  Monitoring Usage Section 5.6, df and du
  Power Management System Administration
  File Systems Status System Administration
  Testing and Exercising System Administration
Tapes (and disks) Archiving System Administration
  Testing and Exercising System Administration
Clock Setting System Administration
Modem Configuring System Administration

Table 5-2:  Device Utilities Documented in the Reference Pages

Device Task Location
Devices (General) Configuring hwmgr(8), devswmgr(8), dsfmgr(8)
  Device Special Files kmknod(8) , mknod(8), MAKEDEV(8), dsfmgr(8)
  Interfaces atapi_ide(7), devio(7), emx(7)
Processor Starting and Stopping halt(8), psradm(8), reboot(2).
  Allocating CPU Resources class_scheduling(4), processor_sets(4), runon(1)
  Monitoring dxsysinfo(8), psrinfo(1).
SCSI buses Managing sys_attrs_cam(5), ddr.dbase(4), ddr_config(8)
Disks Partitioning diskconfig(8), disklabel(4), disklabel(8), disktab(4)
  Monitoring dxsysinfo(8) , diskusg(8), acctdisk(8), df(1), du(1), quota(1)
  Testing and Maintenance diskx(8), zeero(8)
  Interfaces ra(7), radisk(8), ri(7), rz(7)
  Swap Space swapon(8)
Tapes (and Disks) Archiving bttape(8), dxarchiver(8), rmt(8)
  Testing and Maintenance tapex(8)
  Interfaces tz(7), mtio(7), tms(7)
Floppy Tools dxmtools(1), mtools(1)
  Testing and Maintenance fddisk(8)
  Interfaces fd(7)
Terminals, ports Interfaces ports(7)
Modem Configuring chat(8)
  Interfaces modem(7)
Keyboard, mouse Interfaces dc(7), scc(7)

See the System Administration manual for a list of the utilities provided by the SysMan graphical user interface.

5.2    SCSI and Device Driver Utilities

The following sections describe utilities that you use to manage SCSI devices and device drivers.

5.2.1    Using the SCSI Configuration Utility, scu

The SCSI/CAM Utility Program, scu, provides commands for advanced maintenance and diagnostics of SCSI peripheral devices and the CAM I/O subsystem. For most daily operations, you use the hwmgr command. The scu program has an extensive help feature that describes its options and conventions. See scu(8) for detailed information on using this command.

You can use scu to:

Note

For Digital Storage Architecture (DSA) disks, use the radisk program. See radisk(8) for information.

Examples of scu usage are:

# scu 
scu> set nexus bus 0 target 0 LUN 0
Device: RZ1CB-CA, Bus: 0, Target: 0, LUN: 0, Type: Direct Access
scu> show capacity
 
Disk Capacity Information:
 
                  Maximum Capacity: 8380080 (4091.836 megabytes)
                      Block Length: 512
scu> show scsi status 0
SCSI Status = 0 = SCSI_STAT_GOOD = Command successfully completed

5.2.2    Using the Device Switch Manager, devswmgr

The devswmgr command enables you to manage the device switch table by displaying information about the device drivers in the table. You can also use the command to release device switch table entries. Typically, you release the entries for a driver after you have unloaded the driver and do not plan to reload it later. Releasing the entries frees them for use by other device drivers.

Examples of devswmgr usage for device data are:

# devswmgr -display 
device switch database read from primary file
  device switch table has 200 entries
# devswmgr -getnum 

Device switch reservation list
                          (*=entry in use)
  driver name             instance   major
-----------------------   --------   -----
                    pfm          1      71*
                    fdi          2      58*
                    xcr          2      57 
                   kevm          1      56*
               cam_disk          2      55*
                    emx          1      54 
                  TMSCP          2      53 
                   MSCP          2      52 
                    xcr          1      44 
                    LSM          4      43 
                    LSM          3      42 
                    LSM          2      41*
                    LSM          1      40*
                    ace          1      35*
          parallel_port          1      34*
               cam_uagt          1      30 
                   MSCP          1      28 
                  TMSCP          1      27 
                    scc          1      24 
                 presto          1      22 
                cluster          2      21*
                cluster          1      19*
                    fdi          1      14*
               cam_tape          1       9 
               cam_disk          1       8*
                    pty          2       7 
                    pty          1       6 
                    tty          1       1 
                console          1       0

5.3    Partitioning Disks Using diskconfig

The Disk Configuration graphical user interface (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 graphical interface. See disklabel(8) for information on command options.

The Disk Configuration GUI provides a graphical interface to several disk maintenance tasks that you can perform manually, by using the following commands:

Invoke the Disk Configuration interface in either of the following ways:

Caution

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

The system displays a window titled Disk Configuration on hostname. This main window for the DiskConfig utility lists the following information for each disk:

When you select a device by doubleclicking on the list item (or click on the configure button when a disk is highlighted), the two windows are displayed at the same time. The windows are displayed overlapped. Move the cursor to the appropriate window to configure partitions or edit the disk's partition table as follows:

Disk Configuration: Configure Partitions: device name device type

This window provides the following information and options:

Disk Configuration: Partition Table: device name device type

This window displays a bar chart of the current partitions in use, their sizes, and the file system in use. You can choose from the following:

If you make errors on a manual partition change, you can use this window to reset the partition table.

Refer to 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. Invoke the SysMan Menu.

  2. Expand the Storage options, and select Basic File System Utilities - Mount File Systems.

  3. In the Mount Operation window, select the option to mount a specific file system and click on the Next button.

  4. In the Name and Mount Point window:

    1. Type a mount point, such as /usr/newusers

    2. Type the partition name, such as /dev/disk/dsk0g or a domain name, such as newusr_domain#usr.

  5. Click on the OK button to implement the partition adjustment.

Your new file system is now accessible.

5.4    Manually Partitioning Disks

This section provides 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.

The disk label provides detailed information about the geometry of the disk and the partitions into which the disk is divided. You can change the label with the disklabel command. You must be the root user to use the disklabel command.

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 directly access the label on the disk 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 also 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. You can also 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.4.1    Finding Overlapping Partitions

Commands to mount or create file systems, add a new swap device, and add disks to the Logical Storage Manager first check whether the disk partition specified in the command already contains valid data, and whether it overlaps with a partition that is already marked for use. 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 prompt you to continue or abort the operation, 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.5    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 the System Administration manual, 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.

UNIX 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 whether 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

5.6    Monitoring Disk Use

To ensure an adequate amount of free disk space, regularly monitor the disk use of your configured file systems. You can do this in any of the following ways:

You can use the quota command only if you are the root user.

5.6.1    Checking Available Free Space

To ensure sufficient space for your configured file systems, use the df command regularly to determine the amount of free disk space in all of the mounted file systems. The df command displays statistics about the amount of free disk space on a specified file system or on a file system that contains a specified file.

With no arguments or options, the df command displays the following:

If you specify a device that has no file systems mounted on it, df displays the information for the root file system. You can also specify a file path name to display the amount of available disk space on the file system that contains the file. See df(1) for more information.

Note

You cannot use the df command with the block or character special device name to find free space on an unmounted file system. Instead, use the dumpfs command.

The following example displays disk space information about all the mounted file systems:

# /sbin/df 
Filesystem         512-blks   used  avail capacity Mounted on
/dev/disk/dsk2a      30686  21438   6178    77%  /
/dev/disk/dsk0g     549328 378778 115616    76%  /usr
/dev/disk/dsk2g     101372   5376  85858     5%  /var
/dev/disk/dsk3c     394796     12 355304     0%  /usr/users
/usr/share/mn@tsts  557614 449234  52620    89%  /usr/share/mn
domain#usr          838432 680320  158112   81%  /usr

Note

The newfs command reserves a percentage of the file system disk space for allocation and block layout. This can cause the df command to report that a file system is using more than 100 percent of its capacity. You can change this percentage by using the tunefs command with the -minfree flag.

5.6.2    Checking Disk Use

If you determine that a file system has insufficient space available, you might want to find out who is using the space. You can do this with the du command or the quot command.

The du command returns disk space allocation by directory. With this information you can decide who is using the most space and who should free up disk space.

The du command displays the number of blocks contained in all directories (listed recursively) within each specified directory, file name, or (if none are specified) the current working directory. The block count includes the indirect blocks of each file in 1-kilobyte units, independent of the cluster size in use by the system

If you do not specify any options, an entry is generated for each directory. See du(1) for more information on command options.

The following example displays a summary of blocks that all main subdirectories in the /usr/users directory use:

# /usr/bin/du -s /usr/users/*  
440     /usr/users/barnam
43      /usr/users/broland
747     /usr/users/frome
6804    /usr/users/morse
11183   /usr/users/rubin
2274    /usr/users/somer

From this information, you can determine that user Rubin is using the most disk space.

The following example displays the space that each file and subdirectory in the /usr/users/rubin/online directory uses:

# /usr/bin/du -a /usr/users/rubin/online 
1	/usr/users/rubin/online/inof/license
2	/usr/users/rubin/online/inof
7	/usr/users/rubin/online/TOC_ft1
16	/usr/users/rubin/online/build
  .
  .
  .
251	/usr/users/rubin/online

Note

As an alternative to the du command, you can use the ls -s command to obtain the size and usage of files. Do not use the ls -l command to obtain usage information; ls -l displays file sizes only.

5.6.3    Verifying Disk Quotas

You can use the quot command to list the number of blocks in the named file system currently owned by each user. You must be root user to use the quot command.

The following example displays the number of blocks that each user owns and the number of files owned by each user in the /dev/disk/dsk0h file system:

# /usr/sbin/quot -f /dev/disk/dsk0h 

Note

You must specify the character device special file to return the information, because when the device is mounted the block special device file is busy.

See quot(8) for more information.