From 7502647d46389b2e0e659f658b51f56abd1f9511 Mon Sep 17 00:00:00 2001
From: Douglas Gilbert
-
Introduction
The sg3_utils package contains
utilities
-that send SCSI commands to "SCSI" devices. As well as devices on
-transports associated with SCSI (e.g. Fibre Channel (FCP) and the SCSI
+that send SCSI commands to devices. As well as devices on
+transports traditionally associated with SCSI (e.g. Fibre Channel
+(FCP), Serial
+Attached SCSI (SAS) and the SCSI
Parallel Interface(SPI)) many
other devices use SCSI command sets. ATAPI cd/dvd drives
-and SATA disks that use a translation layer or bridge device are
+and SATA disks that connect via a translation layer or a bridge device
+are
examples of devices that use SCSI command sets.
SCSI command sets are divided into a common set and several device
@@ -60,9 +64,10 @@ targeted the linux kernel 2.2 series with some support for the
2.0 series. See an earlier version of this web page
for further information about sg_utils. This
document describes
-version 1.22 of version 1.23 of sg3_utils . A subset of these
-utilities have been ported to the FreeBSD, Tru64 and Windows operating
+utilities have been ported to the FreeBSD, Tru64 and the Windows
+operating
systems.
In the linux kernel 2.4 series most of these utilities must be
@@ -84,12 +89,20 @@ of this page has been moved to the tools page.
Main
SCSI commands |
- subdirectory + | directory |
+ CLI + |
Ported |
Notes @@ -112,10 +127,12 @@ SCSI commands |
utils |
- + | adhoc + |
+ fb |
converts stdin (assumed binary)
-to ASCII hex and ASCII, sending its output to stdout (like Unix od command) |
archive |
+ adhoc + |
copy of Kurt Garloff's useful
@@ -139,6 +158,8 @@ script |
examples |
+ adhoc + |
uses deprecated
@@ -150,9 +171,11 @@ SCSI_IOCTL_SEND_COMMAND ioctl |
MODE SENSE/SELECT, INQUIRY |
- **** + | --> |
- + | getopt + |
+ fb,t64,w |
was in sg3_utils for a short
time; now in own package, see sdparm .
@@ -167,10 +190,13 @@ commands. |
utils |
- + | getopt |
- check asc/ascq codes from
-www.t10.org page against sg3_utils table + | fb + |
+ check asc/ascq codes from www.t10.org page against
+sg3_utils table |
||||||||||||||||
adhoc + |
symbolic decoding (optional
changing) of mode pages. Can also output (disk) defect lists. In lk 2.4
-can be given primary device nodes (e.g. /dev/sda) as well as sg device
-nodes. See scsiinfo package
-notes below. +can be given primary device nodes (e.g. /dev/sda) as well as sg device +nodes. Port of older scsiinfo +utility. |
||||||||||||||||||||||||||||||||||||||||||||
dd + |
sg_dd variant that uses memory
-mapped IO (only on sg devices) +mapped IO (only on linux sg devices) |
||||||||||||||||||||||||||||||||||||||||||||
dd + |
sg_dd variant that uses POSIX
@@ -222,6 +255,8 @@ threads |
dd + |
Unix | adhoc + |
utility specialized for EMC
@@ -249,6 +286,8 @@ Clariion series |
getopt + |
fb,t64,w |
format or resize a SCSI disk @@ -261,6 +300,8 @@ Clariion series |
getopt + |
fb,t64,w | fetch features and profiles of a
cd/dvd drive and/or its current media @@ -269,13 +310,17 @@ cd/dvd drive and/or its current media | ||||||||||||||||||||||||||||||||||
sg_ident |
- REPORT/SET DEVICE IDENTIFIER + | REPORT/SET IDENTIFYING
+INFORMATION |
getopt + |
fb,t64,w | default is to report (fetch) the
-device identifier. With the '--set' option a new identifier is sent
+device identifier. With the '--set'
+option a new identifier is sent
to the device. |
getopt+ + |
fb,t64,w | fetch standard response, VPD
-pages (including device identification) or version descriptors. Also
-can perform IDENTIFY (PACKET) DEVICE ATA command. VPD page decoding now
-also performed by sg_vpd . +pages or version descriptors. Also +can perform IDENTIFY (PACKET) DEVICE ATA command. VPD page decoding +also performed by sg_vpd and sdparm. |
|||||||||||||||||||||||||||||||||||||
getopt+ + |
fb,t64,w | fetch log sense pages, decode
-standard pages +standard and some vendor pages |
|||||||||||||||||||||||||||||||||||||||||||
getopt + |
fb,t64,w | fetch luns reported by a device
(lun 0 or "well known lu") @@ -324,6 +375,8 @@ standard pages |
adhoc + |
shows mapping between sg devices @@ -338,9 +391,12 @@ and primary device node (if any). In lk 2.6 see | getopt + |
maps between single sg device + | 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. |
@@ -352,8 +408,10 @@ out of, sysfs. For the linux 2.6 series.getopt+ + |
fb,t64,w | -dump mode pages (mainly in hex) + | fetch mode pages (mainly in hex) |
||||||||||||||||||||||||||||||||||
+ | getopt+ + |
+ fb,t64,w |
fetch supported SCSI commands or
supported task management functions @@ -376,6 +436,8 @@ supported task management functions |
getopt + |
fb,t64,w | control persistent reservations
and report
@@ -389,6 +451,8 @@ reservation status |
getopt + |
fb,t64,w | control media removal, mainly
for those SCSI devices which have removable media (e.g. CD/DVD and tape
@@ -402,6 +466,8 @@ drives) |
getopt+ + |
read from SCSI device cache.
@@ -415,6 +481,8 @@ Typically for testing the SCSI transport (for throughput or errors) |
adhoc + |
fb,t64,w | display or modify RDAC redundant
controller mode page @@ -427,11 +495,13 @@ controller mode page |
dd + |
read continually from same
offset. Syntax similar to sg_dd (without write side). Can test SCSI
-device cache and transport performance (like sg_rbuf). +device cache and transport performance. |
|||||||||||||||||||||||||||||
getopt+ + |
fb,t64,w | fetch the number of blocks and
the individual block size for disks and CD/DVD media |
|||||||||||||||||||||||||||||||||||||||||||
sg_read_buffer + |
+ READ BUFFER + |
+ + |
+ getopt + |
+ fb,t64,w + |
+ read descriptors or data + |
+ ||||||||||||||||||||||||||||||||||||||||
sg_read_long |
@@ -453,6 +539,8 @@ the individual block size for disks and CD/DVD mediagetopt + |
fb,t64,w | read data from given lba which
includes the block and ECC data. @@ -465,6 +553,8 @@ includes the block and ECC data. |
getopt + |
fb,t64,w | reassign a lba from one sector
on a disk (typically damaged) to a new (spare) sector. User data copied
@@ -478,10 +568,12 @@ if it is recoverable. |
getopt + |
fb,t64,w | fetch sense data from the given
-SCSI device. Useful if no autosense , to get progress indication (e.g.
-during a format) or find the power condition state. +device. Modern uses include getting a progress indication (e.g. +during a format) or finding the power condition state. |
||||||||||||||||||||||||||||||||||||
adhoc + |
Issue a driver, (SCSI) bus or
@@ -504,6 +598,8 @@ device (target or lun?) reset. |
getopt + |
fb,t64,w | Relatively new command
added to SPC-3. Format of response is vendor specific so this utility
@@ -517,6 +613,8 @@ outputs it in hex (default) or binary. |
getopt + |
fb,t64,w | Specialized for multi-ported
SCSI devices where one port (or a group of them) is preferred for IO
@@ -529,6 +627,8 @@ over another (or others). | ATA PASS-THROUGH | getopt + |
fb,t64,w |
Sends IDENTIFY DEVICE or @@ -542,6 +642,8 @@ IDENTIFY PACKET DEVICE ATA commands via the SAT ATA PASS-THROUGH (16 or | examples |
+ adhoc + |
Simpler version of
@@ -556,11 +658,15 @@ examples subdirectory. | [INQUIRY] |
+ |
+ adhoc +[win: +getopt] |
w |
maps each sg device name to
-the corresponding numeric <host, channel, target', lun> tuple. In
+the corresponding numeric <host, channel, target, lun> tuple. In
lk 2.6 series the "lsscsi -g" command is
similar. In Windows shows one device per line, with the device's
various names and INQUIRY response string on that line. @@ -573,6 +679,8 @@ various names and INQUIRY response string on that line. |
getopt+ + |
fb,t64,w | Issues either a default self
test or a short/extended foreground/background self test. With no
@@ -588,6 +696,8 @@ pages. |
getopt + |
fb,t64,w | Fetches status diagnostic pages from, and sends some control pages to, a SCSI Enclosure Services @@ -601,6 +711,8 @@ pages from, and sends some control pages to, a SCSI Enclosure Services | examples |
+ adhoc + |
Simple code examples of using
@@ -614,6 +726,8 @@ the scsi generic (sg) driver interface |
examples |
+ adhoc + |
Simple code example of sending a
@@ -627,9 +741,12 @@ the scsi generic (sg) driver interface |
getopt+ + |
fb,t64,w | Controls the power condition
-state of a SCSI device. Primary use is to spin up and down SCSI disks. +state of a SCSI device. Primary use is to spin up and down SCSI disks. +Can also load and eject removable media. |
|||||||||||
getopt + |
fb,t64,w | Causes disk caches to be flushed
to media @@ -651,6 +770,8 @@ to media |
getopt + |
Random pattern written to SCSI
@@ -665,6 +786,8 @@ corruption. |
getopt+ + |
fb,t64,w | Issue one or more Test Unit
Ready commands. Can be used to time SCSI command overhead. @@ -675,6 +798,8 @@ Ready commands. Can be used to time SCSI command overhead. | VERIFY | getopt + |
fb,t64,w | reads indicated blocks on a SCSI disks, stops on the first error found. Does not yield any data. Useful @@ -687,12 +812,29 @@ for media scans. | getopt + |
fb,t64,w |
Decodes standard and some vendor
Vital Product Data (VPD) pages. |
|||||||||||||||||||||||||||||||
sg_write_buffer + |
+ WRITE BUFFER + |
+ + |
+ getopt + |
+ fb,t64,w + |
+ write data; can be used to
+download firmware + |
+ ||||||||||||||||||||||||||||||||||||||||
sg_write_long |
@@ -700,6 +842,8 @@ Vital Product Data (VPD) pages.getopt + |
fb,t64,w | writes to a lba, data which
includes the block and ECC data. Suitable data typically fetched by
@@ -714,19 +858,23 @@ sg_read_long utility. |
getopt + |
fb,t64,w | writes mode pages supplied in
-ASCII hex (e.g. from "sg_modes -r") to the given SCSI device. See sdparm for another method of setting mode page
+ASCII hex (e.g. from "sg_modes -r")
+to the SCSI device. See sdparm for
+another method of setting mode page
parameters. |
Example: given these 3 SCSI devices:
@@ -1104,63 +1291,245 @@ lun=0 type=0
/dev/sg2: scsi2 channel=0 id=6
lun=0 type=5
INQUIRY data can be added to that output with the "-i" option. The +
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
+
$ sg_map
/dev/sg0 /dev/sda
/dev/sg1 /dev/scd0
-/dev/sg2 /dev/scd1
See the notes about header file problems in the README file inside each package.
sg3_utils version +release date + |
+ tarballs + |
+ rpm source rpms ** + |
+ i386 rpm binaries ** + |
+ debian
+packages + |
+
1.20 +20060418 + |
+ sg3_utils-1.20.tgz | +sg3_utils-1.20-1.src.rpm | +sg3_utils-1.20-1.i386.rpm + libsgutils-1_0-1.20-1.i386.rpm |
+ sg3-utils_1.20-0.1_i386.deb + libsgutils1-0_1.20-0.1_i386.deb |
+
1.21 + 20060706 + |
+ sg3_utils-1.21.tgz | +sg3_utils-1.21-1.src.rpm | +sg3_utils-1.21-1.i386.rpm + libsgutils-1_0-1.21-1.i386.rpm |
+ sg3-utils_1.21-0.1_i386.deb + libsgutils1-0_1.21-0.1_i386.deb |
+
1.22 + 20061016 + |
+ sg3_utils-1.22.tgz + |
+ sg3_utils-1.22-1.src.rpm | +sg3_utils-1.22-1.i386.rpm + libsgutils-1_0-1.22-1.i386.rpm + |
+ sg3-utils_1.22-0.1_i386.deb + libsgutils1-0_1.22-0.1_i386.deb + |
+
1.23 +20070127 + |
+ sg3_utils-1.23.tgz | +sg3_utils-1.23-1.src.rpm | +sg3_utils-1.23-1.i386.rpm + sg3_utils-libs-1.23-1.i386.rpm + |
+ sg3-utils_1.23-0.1_i386.deb + libsgutils1-0_1.23-0.1_i386.deb |
+
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 | +
OS @@ -1224,22 +1593,40 @@ subdirectory included |
|
- Windows NT and latter supported + | Windows NT and later supported
(uses SPT interface). Builds in a cygwin environment and requires
cygwin1.dll to run. |
|
Windows + |
+ + |
+ make -f Makefile.mingw + |
+ + |
+ Builds in a MinGW/MSYS
+environment and requires no third party dll + |
+
Return to main page.
Last updated: 14th October 2006
+
Last updated: 31st January 2007
ignored |
- applied on <ofile> + | applied on OFILE |
- applied on <ofile> + | applied on OFILE |
use O_APPEND open flag.
-Conflicts with 'seek=<n>' when "n > 0" +Conflicts with 'seek=SEEK' +when "SEEK > 0" |
|
append=0|1 - |
- 0 - |
- both - |
- append to output file (rather
-than overwrite). Better to use 'iflag=append' and/or 'oflag=append'. - |
- |||
blk_sgio=0|1 + | blk_sgio=0 | 1 |
0 |
when set access devices via SCSI
-commands (SG_IO ioctl). May use 'iflag=sgio' and/or 'oflag=sgio'
+commands (SG_IO ioctl). May use iflag=sgio and/or oflag=sgio
instead. |
|||
bpt + | bpt=BPT |
128 or 32 |
both |
- blocks_per_transfer (granularity
-of each IO). Default is 128 when bs < 2048 (bytes) else the default
-is 32. For block devices (bpt * bs) is constrained by where BPT is the blocks per transfer
+(granularity
+of each IO). Default is 128 when BS
+< 2048 (bytes) else the default
+is 32. For block devices (BPT
+* BS) is constrained by /sys/block/<device>/queue/max_sectors_kb
. |
||
cdbsz=6|10|12|16 + | cdbsz=6 | 10 | 12 | 16 |
10 or 16 |
@@ -582,7 +608,7 @@ case a 16 cdb is used.||||
coe=0|1|2|3 + | coe=0 | 1 | 2 | 3 |
0 |
@@ -590,13 +616,14 @@ case a 16 cdb is used.when non-zero, continue_on_error
for
-sg devices and block devices using the SG_IO ioctl. May use 'iflag=coe'
-and/or 'oflag=coe'
-instead. An equivalent of 'coe=2' is 'iflag=coe,coe' +sg devices and block devices using the SG_IO ioctl. May use iflag=coe +and/or oflag=coe +instead. An equivalent of coe=2 is 'iflag=coe,coe' |
|||
coe_limit=<n> + | coe_limit=CL |
0 |
@@ -608,7 +635,7 @@ interpreted as no limit.||||
dio=0|1 + | dio=0 | 1 |
0 |
@@ -619,27 +646,18 @@ nodes)||||
fua=0|1|2|3 - |
- 0 - |
- both - |
- force_unit_access, 1->of, -2->if, 3->of+if . Better to use 'iflag=fua' and/or 'oflag=fua'. | -|||
odir=0|1 + | odir=0 | 1 |
0 |
O_DIRECT flag on open() when -set. Better to use 'iflag=direct' and/or 'oflag=direct'. | +set. Better to use iflag=direct and/or oflag=direct.|||
retries=<n> + | retries=RETR |
0 |
@@ -650,19 +668,20 @@ error on a sg device READ or WRITE command||||
sync=0|1 + | sync=0 | 1 |
0 |
both |
when set, sends SYNCHRONIZE
-CACHE SCSI command to <ofile> if it is a sg device or accessed
+CACHE SCSI command to OFILE
+if it is a sg device or accessed
via the SG_IO ioctl. |
||
time=0|1 + | time=0 | 1 |
0 |
@@ -673,13 +692,15 @@ throughput calculation at the completion of the copy||||
verbose=<n> + | verbose=VERB |
0 |
sgm_dd |
- larger <n> is the greater + | larger VERB is the greater
the debug output. 1 and 2 print the cdbs for setup commands; 3 and 4
print the cdbs for all commands |
@@ -689,8 +710,9 @@ print the cdbs for all commands|
/dev/null or . (period) + | /dev/null or . (period) |
O_RDONLY | [do nothing] @@ -769,8 +792,8 @@ written | O_RDWR | SCSI commands | Opens input O_RDONLY if O_RDWR -fails. The 'blk_sgio=1' option equates to both 'iflag=sgio' and -'oflag=sgio'. Partitions ignored. | +fails. The blk_sgio=1 option equates to both iflag=sgio and +oflag=sgio. Partitions ignored.
sg device @@ -811,10 +834,10 @@ series is a replacement for raw devices |
Return to main page.
Last updated: 15th October 2006
+
Last updated: 24th January 2007
Last updated: 11th June 2006
+
Last updated: 10th January 2007