1SG_RAW(8)                          SG3_UTILS                         SG_RAW(8)
2
3
4

NAME

6       sg_raw - send arbitrary SCSI command to a device
7

SYNOPSIS

9       sg_raw [OPTIONS] DEVICE CDB0 CDB1 ...
10

DESCRIPTION

12       This  utility sends an arbitrary SCSI command (between 6 and 256 bytes)
13       to the DEVICE. There may be no associated data transfer; or data may be
14       read  from  a file and sent to the DEVICE; or data may be received from
15       the DEVICE and then displayed or written to a file. If supported by the
16       pass  through, bidirectional commands may be sent (i.e. containing both
17       data to be sent to the DEVICE and received from the DEVICE).
18
19       The SCSI command may be between 6 and 256 bytes long. Each command byte
20       is  specified  in plain hex format (00..FF) without a prefix or suffix.
21       See EXAMPLES section below.
22
23       The commands pass through a generic SCSI interface which is implemented
24       for several operating systems including Linux, FreeBSD and Windows.
25

OPTIONS

27       Arguments to long options are mandatory for short options as well.
28
29       -b, --binary
30              Dump data in binary form, even when writing to stdout.
31
32       -h, --help
33              Display usage information and exit.
34
35       -i, --infile=IFILE
36              Read data from IFILE instead of stdin. This option is ignored if
37              --send is not specified.
38
39       -k, --skip=LEN
40              Skip the first LEN bytes of  the  input  file  or  stream.  This
41              option is ignored if --send is not specified.
42
43       -n, --nosense
44              Don't display SCSI Sense information.
45
46       -o, --outfile=OFILE
47              Write  data received from the DEVICE to OFILE. The data is writ‐
48              ten in binary. By default, data is dumped in hex format to  std‐
49              out.   If  OFILE is '-' then data is dumped in binary to stdout.
50              This option is ignored if --request is not specified.
51
52       -r, --request=RLEN
53              Expect to receive up to RLEN bytes  of  data  from  the  DEVICE.
54              RLEN  may  be  suffixed  with  'k' to use kilobytes (1024 bytes)
55              instead of bytes.
56
57       -R, --readonly
58              Open DEVICE read-only. The default (without this option)  is  to
59              open it read-write.
60
61       -s, --send=SLEN
62              Read  SLEN  bytes of data, either from stdin or from a file, and
63              send them to the DEVICE.
64
65       -t, --timeout=SEC
66              Wait up to SEC seconds for  command  completion  (default:  20).
67              Note  that if a command times out the operating system may start
68              by aborting the command and  if  that  is  unsuccessful  it  may
69              attempt to reset the device.
70
71       -v, --verbose
72              Increase level of verbosity. Can be used multiple times.
73
74       -V, --version
75              Display version and license information and exit.
76

NOTES

78       The  sg_inq  utility can be used to send an INQUIRY command to a device
79       to determine its peripheral device  type  (e.g.  '1'  for  a  streaming
80       device  (tape drive)) which determines which SCSI command sets a device
81       should support (e.g. SPC and SSC). The sg_vpd utility probes the  Vital
82       Product Pages of a devices which may contain useful information.
83
84       The ability to send more than a 16 byte CDB (in some cases 12 byte CDB)
85       may be restricted by the pass-through interface, the low  level  driver
86       or the transport.
87

EXAMPLES

89       These  examples,  apart  from the last one, use Linux device names. For
90       suitable device names in other  supported  Operating  Systems  see  the
91       sg3_utils(8) man page.
92
93       sg_raw /dev/scd0 1b 00 00 00 02 00
94              Eject the medium in CD drive /dev/scd0.
95
96       sg_raw -r 1k /dev/sg0 12 00 00 00 60 00
97              Perform an INQUIRY on /dev/sg0 and dump the response data (up to
98              1024 bytes) to stdout.
99
100       sg_raw -s 512 -i i512.bin /dev/sda 3b 02 00 00 00 00 00 02 00 00
101              Showing an example of writing 512 bytes to a sector on a disk is
102              a  little  dangerous.  Instead  this  example will read i512.bin
103              (assumed to be 512 bytes long) and use  the  SCSI  WRITE  BUFFER
104              command  to  send it to the "data" buffer (that is mode 2). This
105              is a safe operation.
106
107       sg_raw -r 512 -o o512.bin /dev/sda 3c 02 00 00 00 00 00 02 00 00
108              This will use the SCSI READ BUFFER command  to  read  512  bytes
109              from  the  "data"  buffer  (i.e.  mode  2)  then write it to the
110              o512.bin file.  When used in conjunction with the previous exam‐
111              ple,  if  both commands work then 'cmp i512.bin o512.bin' should
112              show a match.
113
114       sg_raw --infile=urandom.bin --send=512 --request=512  --outfile=out.bin
115       "/dev/bsg/7:0:0:0" 53 00 00 00 00 00 00 00 01 00
116              This is a bidirectional XDREADWRITE(10) command being sent via a
117              Linux bsg device. Note that  data  is  being  read  from  "uran‐
118              dom.bin"  and sent to the device (data-out) while resulting data
119              (data-in) is placed in the "out.bin" file. Also note the  length
120              of both is 512 bytes which corresponds to the transfer length of
121              1 (block) in the cdb (i.e.  the second last byte).
122
123       sg_raw.exe PhysicalDrive1 a1 0c 0e 00 00 00 00 00 00 e0 00 00
124              This example is from Windows and shows a ATA  STANDBY  IMMEDIATE
125              command  being  sent to PhysicalDrive1. That ATA command is con‐
126              tained within the SCSI ATA PASS-THROUGH(12) command (see the SAT
127              or  SAT-2  standard  at  http://www.t10.org).  Notice  that  the
128              STANDBY IMMEDIATE command does not send  or  receive  any  addi‐
129              tional  data,  however if it fails sense data should be returned
130              and displayed.
131

EXIT STATUS

133       The exit status of sg_raw is 0 when it is successful. Otherwise see the
134       sg3_utils(8) man page.
135

AUTHOR

137       Written by Ingo van Lil
138

REPORTING BUGS

140       Report bugs to <inguin at gmx dot de>.
141
143       Copyright © 2001-2012 Ingo van Lil
144       This  software is distributed under the GPL version 2. There is NO war‐
145       ranty; not even for MERCHANTABILITY or FITNESS FOR  A  PARTICULAR  PUR‐
146       POSE.
147

SEE ALSO

149       sg_inq, sg_vpd, sg3_utils (sg3_utils), plscsi
150
151
152
153
154sg3_utils-1.35                   December 2012                       SG_RAW(8)
Impressum