A list of SCSI and storage utility programs can be found on this
tools page.
| Utility name |
Main SCSI commands invoked |
CLI |
Ported |
Notes |
| sginfo [legacy, use sdparm] |
MODE SENSE/SELECT, READ
DEFECT |
adhoc |
symbolic decoding (optional
changing) of mode pages. Can also output (disk) defect
lists. Port of older scsiinfo
utility. |
|
| sgm_dd |
READ, WRITE |
dd |
sg_dd variant that uses
memory mapped IO (only on Linux sg devices) |
|
| sgp_dd |
READ, WRITE |
dd |
sg_dd variant that uses POSIX
threads |
|
| sg_compare_and_write |
COMPARE AND WRITE |
getopt |
f,s,t,w | if compare successful then write |
| sg_copy_results |
RECEIVE COPY RESULTS |
getopt |
used to get the results from the previous
sg_xcopy (EXTENDED COPY) |
|
| sg_dd |
READ, WRITE |
dd |
Unix dd command variant, uses
SG_IO ioctl to send SCSI commands to copy data. See the sg_dd page. Newer ddpt utility adds features and is
ported to "f,s,w" |
|
| sg_decode_sense |
getopt |
f,s,t,w |
decodes sense data given as a
string of hexadecimal bytes or in binary |
|
| sg_emc_trespass |
MODE SELECT |
adhoc |
utility specialized for EMC
Clariion series |
|
| sg_format |
FORMAT |
getopt |
f,s,t,w |
format or resize a SCSI disk |
| sg_get_config |
GET CONFIGURATION |
getopt |
f,s,t,w | fetch features and profiles
of a cd/dvd drive and/or its current media |
| sg_get_lba_status |
GET LBA STATUS |
getopt |
f,s,t,w |
logical block provisioning
support |
| sg_ident |
REPORT/SET IDENTIFYING
INFORMATION |
getopt |
f,s,t,w | default is to report (fetch)
the device identifier. With the '--set' option a new identifier is sent
to the device. |
| sg_inq |
INQUIRY |
getopt+ |
f,s,t,w | fetch standard response, VPD
pages or version descriptors. Also can perform IDENTIFY
(PACKET) DEVICE ATA command. VPD page decoding also
performed by sg_vpd and sdparm. |
| sg_logs |
LOG SENSE |
getopt+ |
f,s,t,w | fetch log sense pages, decode
standard and some vendor pages |
| sg_luns |
REPORT LUNS |
getopt |
f,s,t,w | fetch luns reported by a
device (lun 0 or "well known lu") |
| sg_map |
INQUIRY |
adhoc |
shows mapping between sg
devices and primary device node (if any). In lk 2.6 see lsscsi . |
|
| sg_map26 |
getopt |
maps between single Linux sg
device and primary device node (and vice versa). Also does
mapping in to, and out of, sysfs. For the Linux 2.6 series. |
||
| sg_modes |
MODE SENSE |
getopt+ |
f,s,t,w | fetch mode pages (output
mainly in hex, to decode output use sdparm) |
| sg_opcodes |
REPORT SUPPORTED OPERATION
CODES |
getopt+ |
f,s,t,w |
fetch supported SCSI commands
or supported task management functions |
| sg_persist |
PERSISTENT RESERVE IN/OUT |
getopt |
f,s,t,w | control persistent
reservations and report reservation status |
| sg_prevent |
PREVENT ALLOW MEDIUM REMOVAL |
getopt |
f,s,t,w | control media removal, mainly
for those SCSI devices which have removable media (e.g.
CD/DVD and tape drives) |
| sg_raw |
<user specified> |
getopt |
f,s,t,w |
send user supplied cdb |
| sg_rbuf |
READ BUFFER |
getopt+ |
read from SCSI device cache.
Typically for testing the SCSI transport (for throughput or
errors) |
|
| sg_rdac |
MODE SENSE/SELECT |
adhoc |
f,s,t,w | display or modify RDAC
redundant controller mode page |
| sg_read |
READ |
dd |
read continually from same
offset. Syntax similar to sg_dd (without write side). Can
test SCSI device cache and transport performance. |
|
| sg_readcap |
READ CAPACITY |
getopt+ |
f,s,t,w | fetch the number of blocks
and the individual block size for disks and CD/DVD media |
| sg_read_buffer |
READ BUFFER |
getopt |
f,s,t,w |
read descriptors or data |
| sg_read_long |
READ LONG |
getopt |
f,s,t,w | read data from given LBA
which includes the block and ECC data. |
| sg_reassign |
REASSIGN BLOCKS |
getopt |
f,s,t,w | reassign a LBA from one
sector on a disk (typically damaged) to a new (spare)
sector. User data copied if it is recoverable. |
| sg_referrals |
REPORT REFERRALS |
getopt |
f,s,t,w | report data segment
accessibility from target port groups |
| sg_requests |
REQUEST SENSE |
getopt |
f,s,t,w | fetch sense data from the
given device. Modern uses include getting a progress
indication (e.g. during a format) or finding the power
condition state. |
| sg_reset |
- |
adhoc |
Issue a driver, (SCSI) bus or
device (target or lun?) reset. |
|
| sg_rmsn |
READ MEDIA SERIAL NUMBER |
getopt |
f,s,t,w | Relatively new command added
to SPC-3. Format of response is vendor specific so this
utility outputs it in hex (default) or binary. |
| sg_rtpg |
REPORT TARGET PORT GROUPS |
getopt |
f,s,t,w | Specialized for multi-ported
SCSI devices where one port (or a group of them) is
preferred for IO over another (or others). |
| sg_safte | READ BUFFER | getopt | f,s,t,w | fetch information from a SAF-TE processor |
| sg_sanitize |
SANITIZE |
getopt |
f,s,t,w |
Send SCSI SANITIZE command |
| sg_sat_identify |
ATA PASS-THROUGH | getopt |
f,s,t,w |
Send ATA IDENTIFY DEVICE or IDENTIFY PACKET DEVICE commands via the SAT ATA PASS-THROUGH (16 or 12) SCSI command. |
| sg_sat_phy_event |
ATA PASS-THROUGH | getopt |
f,s,t,w | Sends an ATA READ LOG EXT
command via a SAT to fetch log page 11h which contains SATA
phy event counters. |
| sg_sat_set_features |
ATA PASS_THROUGH |
getopt |
f,s,t,w | Sends ATA SET FEATURES
command via SAT |
| sg_scan [.c.linux] |
[INQUIRY] |
adhoc |
Linux only |
maps each sg device name to the corresponding numeric <host, channel, target, lun> tuple. In lk 2.6 series the "lsscsi -g" command is similar. |
| sg_scan [.c.win32] |
[INQUIRY] |
getopt |
win32 only |
shows one device per line,
with the device's various names and INQUIRY response string
on that line. |
| sg_senddiag |
SEND DIAGNOSTIC |
getopt+ |
f,s,t,w | Issues either a default self
test or a short/extended foreground/background self test.
With no arguments it uses RECEIVE DIAGNOSTIC RESULTS to list
all supported diagnostic pages. |
| sg_ses |
SEND/RECEIVE DIAGNOSTIC |
getopt |
f,s,t,w | Fetches status diagnostic
pages from, and sends some control pages to, a SCSI
Enclosure Services (SES) device. See the sg_ses page. |
| sg_start |
START STOP UNIT |
getopt+ |
f,s,t,w | Controls the power condition
state of a SCSI device. Primary use is to spin up and down
SCSI disks. Can also load and eject removable media. |
| sg_stpg |
SET TARGET PORT GROUPS | getopt |
f,s,t,w | Specialized for multi-ported SCSI devices where one port (or a group of them) is preferred for IO over another (or others). |
| sg_sync |
SYNCHRONIZE CACHE |
getopt |
f,s,t,w | Causes disk caches to be
flushed to media |
| sg_test_rwbuf |
READ/WRITE BUFFER |
getopt |
Random pattern written to
SCSI device buffer then read back and checked. Used in
testing for data corruption. |
|
| sg_turs |
TEST UNIT READY |
getopt+ |
f,s,t,w | Issue one or more Test Unit
Ready commands. Can be used to time SCSI command overhead. |
| sg_unmap |
UNMAP |
getopt |
f,s,t,w |
logical block provisioning
support ("Trim" in the ATA world) |
| sg_verify | VERIFY | getopt |
f,s,t,w | reads indicated blocks on a SCSI disks, stops on the first error found. Does not yield any data. Useful for media scans. |
| sg_vpd |
INQUIRY |
getopt |
f,s,t,w |
Decodes standard and some
vendor Vital Product Data (VPD) pages. |
| sg_write_buffer |
WRITE BUFFER |
getopt |
f,s,t,w |
write data; can be used to
download firmware |
| sg_write_long |
WRITE LONG |
getopt |
f,s,t,w | writes to a LBA, data which
includes the block and ECC data. Suitable data typically
fetched by prior sg_read_long utility. |
| sg_write_same |
WRITE SAME |
getopt |
f,s,t,w |
writes a single block to one
or more (consecutive) LBAs. Also supports some logical block
provisioning options. |
| sg_wr_mode |
MODE SELECT |
getopt |
f,s,t,w | writes mode pages supplied in
ASCII hex (e.g. from "sg_modes
-r") to the SCSI device. See sdparm for another method of
setting mode page parameters. |
| sg_xcopy |
EXTENDED COPY |
dd |
Uses the EXTENDED COPY command to copy
between devices |
| Utility |
Main SCSI commands invoked |
directory |
CLI |
Ported |
Notes |
| hxascdmp |
- |
utils |
adhoc |
f,s,w |
converts stdin (assumed
binary) to ASCII hex and ASCII, sending its output to stdout
(like the Unix od
command and hexdump
in BSD) |
| rescan-scsi-bus.sh |
- |
archive |
adhoc |
copy of Kurt Garloff's useful
script |
|
| scsi_inquiry |
INQUIRY |
examples |
adhoc |
uses deprecated
SCSI_IOCTL_SEND_COMMAND ioctl |
|
| sdparm |
MODE SENSE/SELECT, INQUIRY |
--> |
getopt |
f,s,t,w |
was in the sg3_utils package
for a short time; now in own package, see sdparm . sdparm manipulates mode
pages, reads VPD pages and sends simple commands |
| sg_chk_asc |
- |
utils |
getopt |
f,s |
check asc/ascq codes from www.t10.org page against
sg3_utils internal table |
| sg__sat_identify |
ATA PASS-THROUGH |
examples |
adhoc |
Simpler version of
sg_sat_identify that uses the Linux SG_IO ioctl directly. |
|
| sg__sat_phy_event |
ATA PASS-THROUGH | examples |
getopt |
Simpler version of sg_sat_phy_event | |
| sg__sat_set_features | ATA PASS_THROUGH | examples | getopt |
Simpler version of sg_sat_set_features that uses the Linux SG_IO ioctl directly. | |
| sg_simple1,2,3,4,5 |
INQUIRY, TEST UNIT READY |
examples |
adhoc |
Simple code examples of using
the scsi generic (sg) driver interface |
|
| sg_simple16 |
READ |
examples |
adhoc |
Simple code example of
sending a 16 byte cdb SCSI READ command |
| Exit status |
Description |
| 0 |
no error detected. Utility
completed successfully |
| 1 |
syntax error in command line options or their arguments, or an illegal combination of options |
| 2 |
the device reports that it is not ready for the operation requested. The device may be in the process of becoming ready (e.g. spinning up but not at speed) so the utility may work a little while later |
| 3 |
the device reports a medium or hardware error (or a blank check). For example an attempt to read a corrupted block on a disk will yield this value |
| 5 |
the device reports an "illegal request" with an additional sense code other than "invalid operation code". This is often a supported command with a field set requesting an unsupported capability. For commands that require a "service action" field (e.g. READ CAPACITY(16) ) this value can indicate that the command is not supported |
| 6 |
the device reports a "unit attention" condition. This usually indicates that something, unrelated to the requested command, has occurred (e.g. a device reset) potentially before the current SCSI command was sent. The requested command has not been executed by the device. Note that unit attention conditions are usually only reported once by a device |
| 9 |
the device reports an illegal request with an additional sense code of "invalid operation code" which means that the device doesn't support the requested command |
| 11 |
the device (or transport) reports an aborted command. In some cases this can be caused by congestion on the transport and retrying the command may be successful |
| 15 |
the utility is unable to open, close or use the given device. The given file name could be incorrect or there may be permission problems. Adding the '-v' option may give more information |
| 20 |
the DEVICE reports it has a check condition but "no sense". Some polling commands (e.g. REQUEST SENSE) can react this way. It is unlikely that this value will occur as an exit status |
| 21 |
the device reports a "recovered error". The requested command was successful. Most likely a utility will report a recovered error to stderr and continue, probably leaving the utility with an exit status of 0 |
| 33 |
the command sent to the device has timed out. This occurs in Linux, in other ports a command timeout will appear as a transport (or OS) error |
| 97 |
the response to a SCSI command failed sanity checks |
| 98 |
the device reports it has a check condition but the error doesn't fit into any of the above categories |
| 99 |
any errors that can't be categorized into values 1 to 98 may yield this value. This includes transport and operating system errors |
Example: given these 3 SCSI devices:
$ cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00
Lun: 00
Vendor: SEAGATE
Model: ST318451LW Rev: 0003
Type:
Direct-Access
ANSI SCSI revision: 03
Host: scsi2 Channel: 00 Id: 04
Lun: 00
Vendor: PIONEER
Model: DVD-ROM DVD-303 Rev: 1.10
Type:
CD-ROM
ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 06
Lun: 00
Vendor:
YAMAHA Model:
CRW4416S Rev:
1.0g
Type:
CD-ROM
ANSI SCSI revision: 02
then the output from sg_scan is:
$ sg_scan
/dev/sg0: scsi1 channel=0 id=0
lun=0 type=0
/dev/sg1: scsi2 channel=0 id=4 lun=0 type=5
/dev/sg2: scsi2 channel=0 id=6
lun=0 type=5
INQUIRY data can be added to that output with the '-i' option. The sg_map
utility shows the mapping between scsi generic (sg) devices and
the corresponding primary device node. For some peripheral device
types, SCSI enclosures for example, there is no mapping and the
enclosure device must be accessed via a sg device node.
$ sg_map
/dev/sg0 /dev/sda
/dev/sg1 /dev/scd0
/dev/sg2 /dev/scd1
| sg_utils version |
tarballs |
rpm source rpms ** |
i386 rpm binaries ** |
| 1.02 | sg_utils-1.02.tgz | sg_utils-1.02-1.src.rpm | sg_utils-1.02-1.i386.rpm |
Return to main page.
Last updated: 17th January 2013