SGDIAG(8)SGDIAG(8)NAMEsgdiag - Do Diagnostic functions on SCSI devices
SYNOPSISsgdiag [-aentx]
DESCRIPTION
Sgdiag is a program that uses the SCSI Generic interface to send spe‐
cific SCSI commands to specified SCSI devices. The SCSI Generic inter‐
face requires that the kernel .config file have CONFIG_CHR_DEV_SG set.
A log file, named sgdiag.log is created in the /var/log directory which
logs the status of the functions and any errors.
Several different functions can be performed with this utility.
c = Compose Command to send
This function allows the user to compose a custom SCSI command
to send to one or more devices. It prompts the user for the
command length, each command byte, the write data length, each
write data byte, and the receive data length.
r = Reset SCSI bus
This function will send a bus reset signal to the SCSI bus of
the selected device. This may be useful to free up a hung
device.
i = Special Ser# Inquiries
This issues several special SCSI inquiry to obtain the serial
number of the device. Normally this is not needed, since the
serial number of most modern devices is included in the standard
inquiry.
f = Format SCSI disk
This function issues a low-level SCSI format command to the
selected device. This will remap any media defects as it for‐
mats the disk. Of course, it will erase any data on the
selected disk.
w = Wipe SCSI disk
This function issues a low-level SCSI format command to the
selected device. This will NOT include the previous grown
defect list. This may be useful in testing to cause a disk to
expose some media defects. This is dangerous and should not be
used on production systems.
d = Send Diagnostic self-test
This function issues a SCSI Send Diagnostic self-test command to
the selected device. The device returns a sense error if the
self-test does not succeed.
s = Start Unit
This function issues a SCSI Start Unit command. Some disk
drives may not be configured to automatically start after power
up. A reported sense of 02-04-02 indicates that this command is
needed.
t = Stop Unit
This function issues a SCSI Stop Unit command. This might be
used in testing to simulate a device failure.
1 = Do bug 1 (sense_len = 18)
The standard sg structure only defines 16 bytes of sense data,
whereas 18 bytes are needed to parse some illegal request sense
keys. This function attempts to request 18 bytes of sense data
from the standard sg structure, which should cause a 5/24/00
sense error, but should not cause the driver or the utility to
hang or stop working.
2 = Do bug 2 (INQ hang)
In versions of the old adaptec driver that were delivered with
RedHat 6.2, this function will hang the driver by requesting a
receive buffer less than 96 bytes. Newer versions of the driver
should handle this function without error (status = 0).
3 = Do bug 3 (format w short timeout)
A SCSI format command can take several minutes to complete. If
the SCSI timeout is set too short, it should cause several
retries, followed by marking the SCSI device offline. The
device should return to normal after a reboot.
OPTIONS
Command line options are described below.
-? This option displays a summary of the commands accepted by
sgdiag-a Automatically send command for all devices. If this option is
specified, a diagnostic self-test command (function 'd') will be
sent to each device.
-e Causes any file writes to be avoided, such as the log file.
-i N Autorun for the device at Index N, as shown in the 'Num' column.
This sends the diagnostic self-test command.
-n Naming. By default, the device names are displayed as numeric
sequences (/dev/sg0). This option shows the device names as
alphabetic sequences (/dev/sga).
-t Timeout for the format operation, in minutes. The default is
150 minutes, which should suffice for 150 GB disks. Larger
disks require more time. Figure approximately 1 minute per GB
of disk capacity.
-x Causes extra debug messages to be displayed.
SEE ALSOsgdefects(8)sgdskfl(8)sgmode(8)WARNINGS
On some systems with older scsi drivers, the primary defect list cannot
be returned without errors.
See http://scsirastools.sourceforge.net for a bug list and any later
versions of this utility.
COPYRIGHT
Copyright (C) 2001-2002 Intel Corp.
sgdiag is open source software. You can redistribute it and/or modify
it under the terms of the BSD License. See the COPYING file included
with this software package for more details regarding distribution.
sgdiag is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY.
AUTHOR
Andy Cress <arcress@users.sourceforge.net>
Version 1.5: 22 Jul 2004 SGDIAG(8)