SCSI(8)

NAME
scsi - program to assist with scsi devices.

SYNOPSIS

    Usage:
    scsi -f device -d debug_level                    # To set debug level
    scsi -f device [-v] -z seconds                   # To freeze bus
    scsi -f device -m page [-P pc] [-e]              # To read mode pages
    scsi -f device -p [-b bus] [-l lun]              # To probe all devices
    scsi -f device -r [-b bus] [-t targ] [-l lun]    # To reprobe a device
    scsi -f device [-v] [-s seconds] -c cmd_fmt [arg0 ... argn] # A command...
                   -o count out_fmt [arg0 ... argn]  #   EITHER (for data out)
                   -i count in_fmt                   #   OR     (for data in)

    "out_fmt" can be "-" to read output data from stdin;
    "in_fmt" can be "-" to write input data to stdout;

    If debugging is not compiled in the kernel, "-d" will have no effect

DESCRIPTION
The scsi program is used to send commands to a scsi device. It is also a sample usage of the user level SCSI commands.

The -d option sets the SCSI kernel debug level. The kernel must have been compiled with the SCSIDEBUG option. See /sys/scsi/scsi_debug.h to figure out what to set the kernel debug level to.

The -z option freezes all activity on all SCSI busses for a given number of seconds. If -v is also specified then a BEL character is sent to the standard output at the start and finish of the bus freeze. This requires that the kernel be built with the SCSI_FREEZE kernel option. This kernel code is not committed yet.

The -m option is used to read a device mode page. The file /usr/share/misc/scsi_modes is read to look at for how to interpret the mode data. The environment variable SCSI_MODES can specify a different file to use.

The -P option can be used to specify a page control field. The page control fields are

    0 Current Values
    1 Changeable Values
    2 Default Values
    3 Saved Values

The -e option permits you to edit the fields. It will use the editor specified by your EDITOR environment variable. To store changes permanently, edit page control 3 using the -P flag.

The -p option can be used against the "super scsi" device /dev/scsi/super to probe all devices with a given SCSI lun on a given SCSI bus. The bus can be selected with the -b option and the default is 0. The lun can be selected with the -l option and the default is 0. See scsi(4) for a description of the "super scsi" device.

The -r option can be used in FreeBSD 1.1 to reprobe a specific SCSI device at a given Bus, Target and Lun. This is not needed in FreeBSD 2.1, since opening a fixed SCSI device has the side effect of reprobing it, and probing with the bus with the -p option should bring on line any newly found devices. See scsi(4) for a description of fixed scsi devices.

The -c option permits you to send user level SCSI commands specified on the command line to a device. The command is sent using the SCIOCCOMMAND ioctl, so the device you are accessing must permit this ioctl. See scsi(4) for full details of which minor devices permit the ioctl, and scsi(3) for the full details on how to build up the commands and data phases using the format arguments.

-v turns on more verbose information.

-s sets the command timeout in seconds. The default is two seconds.

-c cmd_fmt specifies the command as described in scsi(3). The additional arguments provide values for any variables specified in the command format.

-o count out_fmt arg0 ... argn indicates that this is a data out command (i.e., data will be sent from the system to the device) with count bytes of data. The data out is built up using the facilities described in scsi(3) using the provided arguments to fill in any integer variables. out_fmt can be specified as a hyphen ("-") to indicate that the count bytes of data should be read from the standard input.

-i count in_fmt indicates that this is a data in command (i.e., data will be read from the device into the system) with count bytes of data read in. The information is extracted according to in_fmt using the facilities described in scsi(3) and displayed on the standard output. in_fmt can be specified as a hyphen ("-") to indicate that the count bytes of data input should be written to the standard output.

EXAMPLES
To verify that the device type for the disk /dev/rsd0c is 0 (direct access device):

    root# scsi -f /dev/rsd0c -c "12 0 0 0 64 0" -i 64 "*b3 b5"
    0

To do an inquiry to /dev/rsd2c:

    root# scsi -f /dev/rsd2c -c "12 0 0 0 64 0" -i 64 "s8 z8 z16 z4"
    FUJITSU M2654S-512 010P

    To edit mode page 1 on /dev/rsd2c, and store it permanently on the
    drive:

        root# scsi -f /dev/rsd2c -m 1 -e -P 3

ENVIRONMENT
The SU_DEBUG_OUTPUT variable can be set to a file to send debugging output to that file.

The SU_DEBUG_LEVEL variable can be set to a non-zero integer to increase the level of debugging. Currently this is a on or off thing; it should perhaps use the ioctl to set the debug level in the kernel and then set it back to zero at program exit.

The SU_DEBUG_TRUNCATE variable can be set to an integer to limit the amount of data phase output sent to the debugging file.

The EDITOR variable determines the editor to use for the mode editor.

SEE ALSO
scsi(4), scsi(3)

BUGS

This command wasn't ready for inclusion in 2.0R and so is missing in that release.

Some devices respond to an inquiry for all LUNS. This will cause them to come on line to 8 times during reprobe to different logical units.

The "-i" option to do an inquiry went away in 2.1. The new facilities provided by "-c" supercede that.

Check your permissions carefully. "scsi -f /dev/rsd0c -c "4 0 0 0 0 0" permits anyone who can open /dev/rsd0c to format the disk drive. This must be changed to at least require write access to the drive.

HISTORY
The scsi command appeared in 386BSD 0.1.2.4/FreeBSD to support the new reprobe and user SCSI commands.