Collection of Linux utilities for devices that use the SCSI command set.
Includes utilities to copy data based on "dd" syntax and semantics (called
sg_dd, sgp_dd and sgm_dd); check INQUIRY data and VPD pages (sg_inq); check
mode and log pages (sginfo, sg_modes and sg_logs); spin up and down
disks (sg_start); do self tests (sg_senddiag); and various other functions.
See the README, CHANGELOG and COVERAGE files. Requires the linux kernel 2.4
series or later. In the 2.4 series SCSI generic device names (e.g. /dev/sg0)
must be used. In the 2.6 series other device names may be used as
well (e.g. /dev/sda).
Warning: Some of these tools access the internals of your system
and the incorrect usage of them may render your system inoperable.
scsi_logging_level This bash shell script accesses the Linux SCSI subsystem logging level. The current values can be shown (e.g. with --get) or changed (e.g. with --set)... scsi_mandat This bash shell script calls several SCSI commands on the given DEVICE. These SCSI commands are considered mandatory (although that varies a little depending on... scsi_readcap This bash shell script calls the sg_readcap utility on each given DEVICE. This will send a SCSI READ CAPACITY command to each DEVICE. The default action of this... scsi_ready This bash shell script calls the sg_turs utility on each given DEVICE. This will send a SCSI TEST UNIT READY command to each DEVICE. Disks, tape drives and... scsi_satl This bash shell script calls several SCSI commands on the given DEVICE that is assumed to be an ATA device behind a SCSI to ATA Translation (SAT) layer (SATL)... scsi_start This bash shell script calls the sg_start utility on each given DEVICE. The purpose is to spin up (start) each given DEVICE. scsi_stop This bash shell script calls the sg_start utility on each given DEVICE. The purpose is to spin down (stop) each given DEVICE. scsi_temperature This bash shell script calls the sg_logs utility on each given DEVICE in order to find the device's temperature. The Temperature log page is checked first and... sg3_utils sg3_utils is a package of utilities that send SCSI commands to the given DEVICE via a SCSI pass through interface provided by the host operating system. The... sg_compare_and_write Send the SCSI COMPARE AND WRITE command to DEVICE. This utility reads a compare buffer and a write buffer from either one or two files. If the --inw=WF option... sg_copy_results This utility is designed to query the status of the SCSI Extended Copy (XCOPY) facility (see SPC-3 revision 23 sections 6.3 and 6.17), present in some modern... sg_dd Copy data to and from any files. Specialized for "files" that are Linux SCSI generic (sg) devices, raw devices or other devices that support the SG_IO ioctl... sg_decode_sense This utility takes SCSI sense data in binary or as a sequence of ASCII hexadecimal bytes and decodes it. The primary reference for the decoding is SPC-3 ANSI... sg_emc_trespass sg_emc_trespass sends an EMC-specific Trespass Command to the DEVICE with the selected options. This Mode Select changes the ownership of the LUN of the device... sg_format Not all SCSI direct access devices need to be formatted and some have vendor specific formatting procedures. SCSI disks with rotating media are probably the... sg_get_config Sends a SCSI GET CONFIGURATION command to DEVICE and decodes the response. The response includes the features and profiles of the device. Typically these... sg_get_lba_status Send the SCSI GET LBA STATUS command to the DEVICE and outputs the response. This command was introduced in (draft) SBC-3 revision 20 and devices that support... sg_ident Send a SCSI REPORT IDENTIFYING INFORMATION or SET IDENTIFYING INFORMATION command to DEVICE. Prior to SPC-4 (revision 7) these commands were called REPORT... sginfo sginfo is a port of the Linux scsiinfo program by Eric Youngdale. It uses SCSI generic (sg) devices; however in some cases the high level device name (i.e. sd... sg_inq This utility, when DEVICE is given, sends a SCSI INQUIRY command to it then outputs the response. All SCSI devices are meant to respond to a "standard" INQUIRY... sg_logs This utility sends a SCSI LOG SENSE command to the DEVICE and then outputs the response. The LOG SENSE command is used to fetch log pages. Known log pages can... sg_luns In the first form shown in the Synopsis this utility sends the SCSI REPORT LUNS command to the DEVICE and outputs the response. The response should be a list of... sg_map Sometimes it is difficult to determine which SCSI device a sg device name (e.g. /dev/sg0) refers to. This command loops through the sg devices and finds the... sg_map26 Maps a special file (block or char) associated with a SCSI device to the corresponding SCSI generic (sg) device, or vice versa. Can also be given a sysfs file... sgm_dd Copy data to and from any files. Specialized for "files" that are Linux SCSI generic (sg) devices and raw devices. Uses memory mapped transfers on sg devices... sg_modes This utility sends a MODE SENSE SCSI command to the DEVICE and outputs the response. There is a 6 byte and 10 byte (cdb) variant of the MODE SENSE command, this... sg_opcodes This utility sends a SCSI REPORT SUPPORTED OPERATION CODES or a REPORT SUPPORTED TASK MANAGEMENT FUNCTIONS command to the DEVICE and then outputs the response... sgp_dd Copy data to and from any files. Specialised for "files" that are Linux SCSI generic (sg) and raw devices. Similar syntax and semantics to dd(1) but does not... sg_persist This utility allows Persistent reservations and registrations to be queried and changed. Persistent reservations and registrations are queried by sub-commands... sg_prevent Sends a SCSI PREVENT ALLOW MEDIUM REMOVAL command to DEVICE. The default action of this utility is to prevent the removing or ejecting of the medium from a... sg_raw This utility sends an arbitrary SCSI command (between 6 and 256 bytes) to the DEVICE. There may be no associated data transfer; or data may be read from a file... sg_rbuf This command reads data with the SCSI READ BUFFER command and then discards it. Typically the data being read is from a disk's memory cache. It is assumed that... sg_rdac sg_rdac displays or modifies the RDAC controller settings via the Redundant Controller mode page (0x2C). When modifying the settings it allows to transfer the... sg_read Read data from a Linux SCSI generic (sg) device, a block device or a normal file with each read command issued to the same offset or logical block address... sg_read_block_limits Send a SCSI READ BLOCK LIMITS command to DEVICE and outputs the response. This command is defined for tape (drives) and its description is found in the SSC... sg_read_buffer Sends a SCSI READ BUFFER command to the DEVICE, and if there is a response either decodes it, prints it in hexadecimal or sends it in binary to stdout. If a... sg_readcap The normal action of the SCSI READ CAPACITY command is to fetch the number of blocks (and block size) from the DEVICE. The SCSI READ CAPACITY command (both 10... sg_read_long Send SCSI READ LONG command to DEVICE. The read buffer is output in hex and ASCII to stdout or placed in a file. Note that the data returned includes the... sg_reassign Send a SCSI REASSIGN BLOCKS command to DEVICE. Alternatively this utility can find the number of element in a "grown" or "primary" defect list with a SCSI READ... sg_referrals Send the SCSI REPORT REFERRALS command to the DEVICE and outputs the response. This command was introduced in (draft) SBC-3 revision 24 and devices that support... sg_rep_zones Sends a SCSI REPORT ZONES command to DEVICE and outputs the data returned. This command is found in the ZBC draft standard, revision 2 (zbc-r02.pdf). sg_requests Send SCSI REQUEST SENSE command to DEVICE and output the parameter data response which is expected to be in sense data format. Both fixed and descriptor sense... sg_reset The sg_reset utility with no options (just a DEVICE) reports on the reset state (e.g. if a reset is underway) of the DEVICE. When given a --device, --target... sg_reset_wp Sends a SCSI RESET WRITE POINTER command to the DEVICE. This command is found in the ZBC draft standard revision 2 (zbc-r02.pdf). sg_rmsn Send a SCSI READ MEDIA SERIAL NUMBER command to DEVICE and outputs the response. This command is described in SPC-3 found at www.t10.org . It was originally... sg_rtpg Send a SCSI REPORT TARGET PORT GROUPS command to DEVICE and outputs the response. Target port group access is described in SPC-3 and SPC-4 found at www.t10.org... sg_safte Fetches enclosure status (via a SCSI READ BUFFER command). The DEVICE should be a SAF-TE device which may be a storage array controller (INQUIRY peripheral... sg_sanitize This utility invokes the SCSI SANITIZE command. This command was first introduced in the SBC-3 revision 27 draft. The purpose of the sanitize operation is to... sg_sat_identify This utility sends either an ATA IDENTIFY DEVICE command or an ATA IDENTIFY PACKET DEVICE command to DEVICE and outputs the response. The devices that respond... sg_sat_phy_event This utility sends an ATA READ LOG EXT with the log page ("address") set to 11h to DEVICE and outputs the response. Log page 11h is defined in the SATA 2.5... sg_sat_read_gplog This utility sends an ATA READ LOG EXT or an ATA READ LOG DMA EXT command to the DEVICE. This command is used to read the general purpose log of (S)ATA disks... sg_sat_set_features This utility sends an ATA SET FEATURES command to the DEVICE. This command is used to change settings of ATA non-packet (i.e. disks) and packet devices (e.g... sg_scan If no DEVICE names are given, sg_scan does a scan of the sg devices and outputs a line of information for each sg device that is currently bound to a SCSI... sg_senddiag This utility sends a SCSI SEND DIAGNOSTIC command to the DEVICE. It can issue self-tests, find supported diagnostic pages or send arbitrary diagnostic pages... sg_ses Fetches management information from a SCSI Enclosure Service (SES) device. This utility can also modify the state of a SES device. The DEVICE should be a SES... sg_ses_microcode This utility attempts to download microcode to an enclosure (or one of its sub-enclosures) associated with the DEVICE. The process for doing this is defined in... sg_start sg_start sends a SCSI START STOP UNIT command to the DEVICE with the selected options. The most used options are --stop to spin down a disk and --start to spin... sg_stpg Send a SCSI SET TARGET PORT GROUPS command to DEVICE. This utility has different modes depending on whether the --tp= option is given. If --tp= is given then... sg_sync Send SYNCHRONIZE CACHE(10) or SYNCHRONIZE CACHE(16) command to DEVICE. These commands are defined for SCSI block devices (see SBC-3). If successful these... sg_test_rwbuf sg_test_rwbuf writes and reads back SZ bytes to the internal buffer of DEVICE (e.g. /dev/sda or /dev/sg0). A pseudo random pattern is written to the data buffer... sg_turs This utility sends one or more SCSI TEST UNIT READY commands to the DEVICE. This may be useful for timing the per command overhead. Note that TEST UNIT READY... sg_unmap Send a SCSI UNMAP command to DEVICE to unmap one or more logical blocks. This command was introduced in SBC-3 revision 18 under the broad heading of "logical... sg_verify Sends one or more SCSI VERIFY (10 or 16) commands to DEVICE. These SCSI commands are defined in the SBC-2 (draft) standard at http://www.t10.org and SBC-3... sg_vpd This utility, when DEVICE is given, fetches a Vital Product Data (VPD) page and decodes it or outputs it in ASCII hexadecimal or binary. VPD pages are fetched... sg_write_buffer Sends one or more SCSI WRITE BUFFER commands to DEVICE, along with data provided by the user. In some cases no data is required, or data can be read from the... sg_write_long Send the SCSI WRITE LONG (10 or 16 byte) command to DEVICE. The buffer to be written to the DEVICE is filled with 0xff bytes or read from the IF file. This... sg_write_same Send the SCSI WRITE SAME (10, 16 or 32 byte) command to DEVICE. This command writes the given block NUM times to consecutive blocks on the DEVICE starting at... sg_write_verify Send a SCSI WRITE AND VERIFY (10) or (16) command to DEVICE. The data to be written is read from the IF file or, in its absence, a buffer full of 0xff bytes is... sg_wr_mode Writes a modified mode page to DEVICE. Uses the SCSI MODE SENSE (6 or 10 byte variant) command to fetch the existing mode data which includes a mode page (or... sg_xcopy Copy data to and from any files. Specialized for "files" that are Linux SCSI devices that support the SCSI EXTENDED COPY (XCOPY) command. During the draft... sg_zone Sends a SCSI OPEN ZONE, CLOSE ZONE or FINISH ZONE command to the DEVICE. These commands are found in the ZBC draft standard revision 2 (zbc-r02.pdf). One and...