SCSI(8) | System Manager's Manual | SCSI(8) |
scsi
— program to
assist with SCSI devices
scsi |
-f device
-d debug_level |
scsi |
-f device
-m page
[-e ] [-P
pc] |
scsi |
-f device
[-v ] [-s
seconds] -c
cmd_fmt [arg ...]
-o count out_fmt
[arg ...] -i
count in_fmt [arg ...] |
The scsi
program is used to send commands
to a SCSI device. It is also a sample usage of the user-level SCSI commands.
out_fmt can be
‘-
’ to read output data from stdin;
in_fmt can be
‘-
’ to write input data to stdout.
The options are as follows:
-c
cmd_fmt [arg ...]SCIOCCOMMAND
ioctl(2), so the device
being accessed must permit this ioctl. See
scsi(4) for full details of
which minor devices permit the ioctl.-d
debug_levelSCSIDEBUG
option. See
/sys/scsi/scsi_debug.h to figure out what to set
the kernel debug level to.-e
EDITOR
environment variable. To store changes
permanently, edit page control 3 using the -P
flag.-f
device-i
count in_fmt [arg ...]-
’) to indicate that
count bytes of data input should be written to
standard output.-m
pageSCSI_MODES
can specify a different file to
use.-o
count out_fmt [arg ...]-
’) to indicate that
count bytes of data should be read from standard
input.-P
pc0 Current Values 1 Changeable Values 2 Default Values 3 Saved Values
-s
seconds-v
The command arguments to the -cio
options
specify the command data buffer used to both send and receive information to
and from the scsi(4) subsystem.
Their format is:
-c
command [argument
...]
The commands are composed of a list of field specifiers. The specifiers denote the field name, the field value, and the length of the field. Examples are given below.
Whitespace and text following a ‘#’ character in the command string are ignored.
The first part of a field specifier is the field name and is surrounded by curly braces (‘{}’). This part is optional and may be left out.
The second part is the value of the field. The value may be given
directly or may arrange that the next argument to the
scsi
command be used as the value of the field.
Direct hexadecimal (0-FF
) or decimal (0-255) values
may be specified. The special value v
can be used to
arrange that the next integer argument be taken from the
argument list. For retrieving output (with
-i
), this part of the field cannot be used.
The third part specifies the length of the field. This is optional
and defaults to one byte if not specified. The length may be specified in
bits by prefixing it with b
or
t
, or in bytes by prefixing it with
i
. Additionally, character arrays can be specified
by prefixing with c
or, with zeroed trailing spaces,
with z
. Bits are packed together tightly and begin
with the high bit. New bytes are started when a byte fills or an
i
field is next. i
fields
indicate a 1-4 byte integral value that must already be given in SCSI byte
order (most significant byte first). Otherwise, the field value specified
will be swapped into SCSI byte order.
Retrieving data (with -i
) follows
similarly but without field values. Besides field specifiers, the command
can also include control operations, which currently includes seeking
operations used to ignore returned data. Seek operations are composed of the
s
character followed by the absolute position to
skip to. If the position is prefixed with a +
, the
position is interpreted relative to the current position.
Entire fields can be suppressed from being returned with the
*
modifier prepended to the field width.
Here are some examples:
s8 z8 z16
z4
1A
2
0x1A
followed by another one-byte field with the
decimal value 2.v:i1
0:7
*b3
b5
SU_DEBUG_OUTPUT
SU_DEBUG_LEVEL
SU_DEBUG_TRUNCATE
EDITOR
The scsi
utility exits 0 on
success, and >0 if an error occurs.
To verify that the device type for the disk /dev/rsd0c is 0 (direct access device):
# scsi -f /dev/rsd0c -c "12 0 0 0 64 0" -i 0x64 "*b3 b5" 0
To do an inquiry to /dev/rsd2c:
# scsi -f /dev/rsd2c -c "12 0 0 0 64 0" -i 0x64 "s8 z8 z16 z4" FUJITSU M2654S-512 010P
To spin down /dev/rsd2c:
# scsi -f /dev/rsd2c -c "1b 0 0 0 0 0"
To edit mode page 1 on /dev/rsd2c and store it permanently on the drive (set AWRE and ARRE to 1 to enable bad block remapping):
# scsi -f /dev/rsd2c -m 1 -e -P
3
The scsi
command appeared in 386BSD
0.1.2.4/FreeBSD to support the new reprobe and user SCSI commands.
scsi -f /dev/rsd0c -c "4 0 0 0 0
0"
permits anyone who can write to
/dev/rsd0c to format the disk drive.
February 28, 2015 | OpenBSD-6.8 |