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

NAME

6       sg_raw - sends an 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.
16
17       The SCSI command may be between 6 and 256 bytes long. Each command byte
18       is  specified  in plain hex format (00..FF) without a prefix or suffix.
19       See EXAMPLES section below.
20
21       The commands pass through a generic SCSI interface which is implemented
22       for several operating systems including Linux, FreeBSD and Windows.
23

OPTIONS

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

NOTES

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

EXAMPLES

84       sg_raw /dev/scd0 1b 00 00 00 02 00
85              Eject the medium in CD drive /dev/scd0.
86
87       sg_raw -r 1k /dev/sg0 12 00 00 00 60 00
88              Perform an INQUIRY on /dev/sg0 and dump the response data (up to
89              1024 bytes) to stdout.
90
91       sg_raw -s 512 -i i512.bin /dev/sda 3b 02 00 00 00 00 00 02 00 00
92              Showing an example of writing 512 bytes to a sector on a disk is
93              a  little  dangerous.  Instead  this  example will read i512.bin
94              (assumed to be 512 bytes long) and use  the  SCSI  WRITE  BUFFER
95              command  to  send it to the "data" buffer (that is mode 2). This
96              is a safe operation.
97
98       sg_raw -r 512 -o o512.bin /dev/sda 3c 02 00 00 00 00 00 02 00 00
99              This will use the SCSI READ BUFFER command  to  read  512  bytes
100              from  the  "data"  buffer  (i.e.  mode  2)  then write it to the
101              o512.bin file.  When used in conjunction with the previous exam‐
102              ple,  if  both commands work then 'cmp i512.bin o512.bin' should
103              show a match.
104

EXIT STATUS

106       The exit status of sg_raw is 0 when it is successful. Otherwise see the
107       sg3_utils(8) man page.
108

AUTHOR

110       Written by Ingo van Lil
111

REPORTING BUGS

113       Report bugs to <inguin at gmx dot de>.
114
116       Copyright © 2001-2009 Ingo van Lil
117       This  software is distributed under the GPL version 2. There is NO war‐
118       ranty; not even for MERCHANTABILITY or FITNESS FOR  A  PARTICULAR  PUR‐
119       POSE.
120

SEE ALSO

122       sg_inq sg_vpd(sg3_utils), plscsi
123
124
125
126
127sg3_utils-1.28                    August 2009                        SG_RAW(8)
Impressum