title: sg_ident(8)

text:
# sg_ident(8)

## NAME
sg_ident - send SCSI REPORT/SET IDENTIFYING INFORMATION command

## SYNOPSIS
sg_ident [--ascii] [--clear] [--help] [--itype=IT] [--raw] [--set] [--verbose] [--version] DEVICE

## DESCRIPTION
Send a SCSI REPORT IDENTIFYING INFORMATION or SET IDENTIFYING INFORMATION command to DEVICE. Prior to SPC-4 (revision 7) these commands were called REPORT DEVICE IDENTIFIER and SET DEVICE IDENTIFIER respectively. SCSI devices that support these two commands allow users to write (set) identifying information and report it back at some later time. The information is persistent (i.e. stored on some non-volatile medium within the SCSI device that will survive a power outage).

Typically the space allocated for the information is limited: SPC-4 (revision 7) states that for information type 0, the minimum length is 64 bytes and the maximum is 512 bytes. For other information types (1 to 126 inclusive) the maximum length is 256 bytes. Also information types 1 to 126 (inclusive) should contain a null terminated UTF-8 string. The author has seen older disks that only support 16 bytes.

The default action when no options are given is to invoke the Report Identifying Information command with the information type defaulting to zero. Error reports are sent to stderr. By default the information is shown in ASCII-HEX (up to 16 bytes per line) with an ASCII representation to the right with dots replacing non printable characters.

## OPTIONS
Arguments to long options are mandatory for short options as well.

-A, --ascii

invokes the Report Identifying Information command and if anything is found interprets it as ASCII (or UTF-8 which is locale dependent) and prints the information to stdout.

-C, --clear

invokes the Set Identifying Information command with an information length of zero. This has the effect of clearing the existing information.

-h, --help

output the usage message then exit.

-i, --itype=IT

where IT is the information type. Defaults to zero. The maximum value is 127 which is special and cannot be used with --set or --clear. The information type of 127 (if supported) causes the REPORT IDENTIFYING INFORMATION command to respond with a list of available information types and their maximum lengths in bytes. The odd numbered information types between 3 and 125 (inclusive) are not to be used (as they clash with the SCC-2 standard).

-r, --raw

invokes the Report Identifying information command and if anything is found sends the information (which may be binary) to stdout. Nothing else is sent to stdout however error reports, if any, are sent to stderr.

-S, --set

first reads stdin until an EOF is detected then invokes the Set Identifying Information command to set what has been fetched from stdin as the information. The amount of data read must be between 1 and 512 bytes length (inclusive).

-v, --verbose

increase the level of verbosity, (i.e. debug output).

-V, --version

print the version string and then exit.

This utility permits users to write their own identifying information to their SCSI devices. There are several other types of descriptors (or designators) that the user cannot change. These include the SCSI INQUIRY command with its standard vendor and product identification strings and the product revision level; plus the large amount of information provided by the "Device Identification" VPD page (see sg_vpd). There is also the READ MEDIA SERIAL NUMBER command (see sg_rmsn). The MMC-4 command set for CD and DVDs has a "media serial number" feature (0x109) [and a "logical unit serial number" feature]. These can be viewed with the sg_get_config utility.

## EXAMPLES
First, to see if there is an existing information whose format is unknown (for information type 0), use no options:

\# sg_ident /dev/sdb

00 31 32 33 34 35 36 37 38 39 30 1234567890

If it is ASCII then it can printed as such:

\# sg_ident --ascii /dev/sdb

1234567890

The information can be copied to a file, cleared and then re-asserted with this sequence:

\# sg_ident --raw /dev/sdb > t

\# sg_ident --clear /dev/sdb

\# cat t | sg_ident --set /dev/sdb

## EXIT STATUS
The exit status of sg_ident is 0 when it is successful. Otherwise see the sg3_utils(8) man page.

## AUTHORS
Written by Douglas Gilbert.

## REPORTING BUGS
Report bugs to <dgilbert at interlog dot com>.

## COPYRIGHT
Copyright © 2005-2018 Douglas Gilbert

This software is distributed under a BSD-2-Clause license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

## SEE ALSO
sg_vpd(sg3_utils), sg_rmsn(sg3_utils), sg_get_config(sg3_utils)


title: sg_inq(8)

text:
# sg_inq(8)

## NAME
sg_inq - issue SCSI INQUIRY command and/or decode its response

## SYNOPSIS
sg_inq [--ata] [--block=0|1] [--cmddt] [--descriptors] [--export] [--extended] [--force] [--help] [--hex] [--id] [--inhex=FN] [--json[=JO]] [--js-file=JFN] [--len=LEN] [--long] [--maxlen=LEN] [--only] [--page=PG] [--quiet] [--raw] [--sinq_inraw=RFN] [--vendor] [--verbose] [--version] [--vpd] DEVICE

sg_inq [-36] [-a] [-A] [-b] [--B=0|1] [-c] [-cl] [-d] [-e] [-f] [-h] [-H] [-i] [-I=FN] [-j[=JO]] [-l=LEN] [-L] [-m] [-M] [-o] [-p=VPD_PG] [-P] [-q] [-r] [-s] [-u] [-v] [-V] [-x] [-36] [-?] DEVICE

## DESCRIPTION
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 command with at least a 36 byte response (in SCSI 2 and higher). An INQUIRY is termed as "standard" when both the EVPD and CmdDt (now obsolete) bits are clear. Formally (i.e. as per SPC stardards) the name of a standard INQUIRY response is the "standard INQUIRY data format" but here the "standard INQUIRY response" is used as it is shorter and more descriptive.

Alternatively the --inhex=FN option can be given. In this case FN is assumed to be a file name ('-' for stdin) containing ASCII hexadecimal representing an INQUIRY response.

This utility supports two command line syntaxes. The preferred one is shown first in the synopsis and is described in the main OPTIONS section. A later section titled OLDER COMMAND LINE OPTIONS describes the second group of options.

An important "non-standard" INQUIRY page is the Device Identification Vital Product Data (VPD) page [0x83]. Since SPC-3, support for this page is mandatory. The --id option decodes this page. New VPD page information is no longer being added to this utility. The sg_vpd(8) utility is specialized for decoding VPD pages and shares code with this utility for that purpose. The sdparm(8) utility which is in a package of that name also decodes VPD pages although its major purpose is to access and modify SCSI mode pages.

In Linux, if the DEVICE exists and the SCSI INQUIRY fails (e.g. because the SG_IO ioctl is not supported) then an ATA IDENTIFY (PACKET) DEVICE is tried. If it succeeds then device identification strings are output. The --raw and --hex options can be used to manipulate the output. If the --ata option is given then the SCSI INQUIRY is not performed and the DEVICE is assumed to be ATA (or ATAPI). For more information see the ATA DEVICES section below.

In some operating systems a NVMe device (e.g. SSD) may be given as the DEVICE. For more information see the NVME DEVICES section below.

The reference document used for interpreting an INQUIRY is T10/BSR INCITS 566 Revision 6 which is draft SPC-6 dated 22 October 2021. It can be found at https://www.t10.org . Obsolete and reserved items in the standard INQUIRY response output are displayed in square brackets.

## OPTIONS
Arguments to long options are mandatory for short options as well. The options are arranged in alphabetical order based on the long option name.

-a, --ata

Assume given DEVICE is an ATA or ATAPI device which can receive ATA commands from the host operating system. Skip the SCSI INQUIRY command and use either the ATA IDENTIFY DEVICE command (for non-packet devices) or the ATA IDENTIFY PACKET DEVICE command. To show the response in hex, add a '--verbose' option. This option is only available in Linux.

-B, --block=0|1

this option controls how the file handle to the DEVICE is opened. If this argument is 0 then the open is non-blocking. If the argument is 1 then the open is blocking. In Unix a non-blocking open is indicated by a O_NONBLOCK flag while a blocking open is indicated by the absence of that flag. The default value depends on the operating system and the type of DEVICE node. For Linux pass-throughs (i.e. the sg and bsg drivers) the default is 0.

-c, --cmddt

set the Command Support Data (CmdDt) bit (defaults to clear(0)). Used in conjunction with the --page=PG option where PG specifies the SCSI command opcode to query. When used twice (e.g. '-cc') this utility forms a list by looping over all 256 opcodes (0 to 255 inclusive) only outputting a line for commands that are found. The CmdDt bit is now obsolete; it has been replaced by the REPORT SUPPORTED OPERATION CODES command, see the sg_opcodes(8) utility.

-d, --descriptors

decodes and prints the version descriptors found in a standard INQUIRY response. There are up to 8 of them. Version descriptors indicate which versions of standards and/or drafts the DEVICE complies with. The normal components of a standard INQUIRY are output (typically from the first 36 bytes of the response) followed by the version descriptors if any.

-e

see entry below for --vpd.

-f, --force

As a sanity check, the normal action when fetching VPD pages other than page 0x0 (the "Supported VPD pages" VPD page), is to first fetch page 0x0 and only if the requested page is one of the supported pages, to go ahead and fetch the requested page.

When this option is given, skip checking of VPD page 0x0 before accessing the requested VPD page. The prior check of VPD page 0x0 is known to crash certain USB devices, so use with care.

-u, --export

prints out information obtained from the device. The output can be modified by selecting a VPD page with PG (from --page=PG). If the device identification VPD page 0x83 is given it prints out information in the form: "SCSI_IDENT_<assoc>_<type>=<ident>" to stdout. If the device serial number VPD page 0x80 is given it prints out information in the form: "SCSI_SERIAL=<ident>". Other VPD pages are not supported. If no VPD page is given it prints out information in the form: "SCSI_VENDOR=<vendor>", "SCSI_MODEL=<model>", and "SCSI_REVISION=<rev>", taken from the standard inquiry. This may be useful for tools like udev(7) in Linux.

-E, -x, --extended

prints the extended INQUIRY VPD page [0x86]. It has the same effect as giving the --page=ei option.

-h, --help

print out the usage message then exit. When used twice, after the usage message, there is a list of available abbreviations than can be given to the --page=PG option.

-H, --hex

rather than decode a standard INQUIRY response, a VPD page or command support data; print out the response in hex and send the output to stdout. Error messages and warnings are typically output to stderr. When used twice with the ATA Information VPD page [0x89] decodes the start of the response then outputs the ATA IDENTIFY (PACKET) DEVICE response in hexadecimal bytes (not 16 bit words). When used three times with the ATA Information VPD page [0x89] or the --ata option, this utility outputs the ATA IDENTIFY (PACKET) DEVICE response in hexadecimal words suitable for input to 'hdparm --Istdin'. See note below.

To generate output suitable for placing in a file that can be used by a later invocation with the --inhex=FN option, use the '-HHHH' option (e.g. 'sg_inq -p di -HHHH /dev/sg3 > dev_id.hex').

-i, --id

prints the device identification VPD page [0x83]. It has the same effect as giving the --page=di option.

-I, --inhex=FN

FN is expected to be a file name (or '-' for stdin) which contains ASCII hexadecimal or binary representing an INQUIRY (including VPD page) response. This utility will then decode that response. It is preferable to also supply the --page=PG option, if not this utility will attempt to guess which VPD page (or standard INQUIRY) that the response is associated with. The hexadecimal should be arranged as 1 or 2 digits representing a byte each of which is whitespace or comma separated. Anything from and including a hash mark to the end of a line is ignored. If the --raw option is also given then FN is treated as binary.

-j[=JO], --json[=JO]

output is in JSON format instead of plain text form. Note that arguments to the short and long form are themselves optional and if present start with "=" and no whitespace is permitted around that "=".

See sg3_utils_json manpage or use '?' for JO to get a summary.

-J, --js-file=JFN

output is in JSON format and it is sent to a file named JFN. If that file exists then it is truncated. By default, the JSON output is sent to stdout.

When this option is given, the --json[=JO] option is implied and need not be given. The --json[=JO] option may still be needed to set the JO parameter to non-default values.

-l, --len=LEN

the number LEN is the "allocation length" field in the INQUIRY cdb. This is the (maximum) length of the response returned by the device. The default value of LEN is 0 which is interpreted as: first request is for 36 bytes and if necessary execute another INQUIRY if the "additional length" field in the response indicates that more than 36 bytes is available.

If LEN is greater than 0 then only one INQUIRY command is performed. This means that the Serial Number (obtained from the Serial Number VPD pgae (0x80)) is not fetched and therefore not printed. See the NOTES section below about "36 byte INQUIRYs".

-L, --long

this option causes more information to be decoded from the Identify command sent to a NVMe DEVICE.

-m, --maxlen=LEN

this option has the same action as the --len=LEN option above. It has been added for compatibility with the sg_vpd, sg_modes and sg_logs utilities.

-O, --old

Switch to older style options. Please use as first option on the command line.

-o, --only

Do not attempt to additionally retrieve the serial number VPD page (0x80) to enhance the output of a standard INQUIRY. So with this option given and no others, this utility will send a standard INQUIRY SCSI command and decode its response. No other SCSI commands will be sent to the DEVICE. Without this option an additional SCSI command is sent: a (non-standard) SCSI INQUIRY to fetch the Serial Number VPD page. However the Serial Number VPD page is not mandatory (while the Device Identification page is mandatory but a billion USB keys ignore that) and may cause nuisance error reports. In most cases if the --maxlen=LEN option is given and LEN is greater than 0 then this option is not needed.

For NVMe devices only the Identify controller is performed, even if the DEVICE includes a namespace identifier. For example in FreeBSD given a DEVICE named /dev/nvme0ns1 then an Identify controller is sent to /dev/nvme0 and nothing is sent to its "ns1" (first namespace).

-p, --page=PG

the PG argument can be either a number of an abbreviation for a VPD page. To enumerate the available abbreviations for VPD pages use '-hh' or a bad abbreviation (e.g, '--page=xxx'). When the --cmddt option is given (once) then PG is interpreted as an opcode number (so VPD page abbreviations make little sense).

If PG is a negative number, then a standard INQUIRY is performed. This can be used to override some guessing logic associated with the --inhex=FN option.

If PG is not found in the 'Supported VPD pages' VPD page (0x0) then EDOM is returned. To bypass this check use the --force option.

-q, --quiet

suppress the amount of decoding and error output.

-r, --raw

in the absence of --inhex=FN then the output response is in binary. The output should be piped to a file or another utility when this option is used. The binary is sent to stdout, and errors are sent to stderr.

If used with --inhex=FN then the contents of FN is treated as binary.

-Q, --sinq_inraw=RFN

where RFN is a filename containing binary standard INQUIRY response data that matches either DEVICE or FN. Linux places this standard INQUIRY response in its sysfs pseudo filesystem. A typical location is at /sys/class/scsi_device/<hctl>/device/inquiry where <hctl> is a four part numeric tuple separated by colons. This tuple distinguishes the device from any others on the system. Linux also places some VPD page responses in binary in the same directory with names like "vpd_pg83" where the last two digits form the hexadecimal VPD page number whose binary contents are therein.

Some VPD pages (e.g. the Extended Inquiry VPD page) depend on knowing the settings in the standard INQUIRY response to interpret the fields in that VPD page. This option together with the --all, --examine or --page=PG allows this utility to process both the standard INQUIRY response and VPD pages in the same invocation.

The --raw option has no effect on this option. The DEVICE argument may be given with this option.

-s, --vendor

output a standard INQUIRY response's vendor specific fields from offset 36 to 55 in ASCII. When used twice (i.e. '-ss') also output the vendor specific field from offset 96 in ASCII. This is only done if the data passes some simple sanity checks.

-v, --verbose

increase level of verbosity. Can be used multiple times.

-V, --version

print out version string then exit.

-e, --vpd

set the Enable Vital Product Data (EVPD) bit (defaults to clear(0)). Used in conjunction with the --page=PG option where PG specifies the VPD page number to query. If the --page=PG is not given then PG defaults to zero which is the "Supported VPD pages" VPD page.

## NOTES
Some devices with weak SCSI command set implementations lock up when they receive commands they don't understand (and some lock up if they receive response lengths that they don't expect). Such devices need to be treated carefully, use the '--len=36' option. Without this option this utility will issue an initial standard INQUIRY requesting 36 bytes of response data. If the device indicates it could have supplied more data then a second INQUIRY is issued to fetch the longer response. That second command may lock up faulty devices.

ATA or ATAPI devices that use a SCSI to ATA Translation layer (see SAT at www.t10.org) may support the SCSI ATA INFORMATION VPD page. This returns the IDENTIFY (PACKET) DEVICE response amongst other things. The ATA Information VPD page can be fetched with '--page=ai'.

In the INQUIRY standard response there is a 'MultiP' flag which is set when the device has 2 or more ports. Some vendors use the preceding vendor specific ('VS') bit to indicate which port is being accessed by the INQUIRY command (0 -> relative port 1 (port "a"), 1 -> relative port 2 (port "b")). When the 'MultiP' flag is set, the preceding vendor specific bit is shown in parentheses. SPC-3 compliant devices should use the device identification VPD page (0x83) to show which port is being used for access and the SCSI ports VPD page (0x88) to show all available ports on the device.

In the 2.4 series of Linux kernels the DEVICE must be a SCSI generic (sg) device. In the 2.6 series and later block devices (e.g. disks and ATAPI DVDs) can also be specified. For example "sg_inq /dev/sda" will work in the 2.6 series kernels. From lk 2.6.6 other SCSI "char" device names may be used as well (e.g. "/dev/st0m").

The number of bytes output by --hex and --raw is 36 bytes or the number given to --len=LEN (or --maxlen=LEN). That number is reduced if the "resid" returned by the HBA indicates less bytes were sent back from DEVICE.

The DEVICE is opened with a read-only flag (e.g. in Unix with the O_RDONLY flag).

## ATA DEVICES
There are two major types of ATA devices: non-packet devices (e.g. ATA disks) and packet devices (ATAPI). The majority of ATAPI devices are CD/DVD/BD drives in which the ATAPI transport carries the MMC set (i.e. a SCSI command set). Further, both types of ATA devices can be connected to a host computer via a "SCSI" (or some other) transport. When an ATA disk is controlled via a SCSI (or non-ATA) transport then two approaches are commonly used: tunnelling (e.g. STP in Serial Attached SCSI (SAS)) or by emulating a SCSI device (e.g. with a SCSI to ATA translation layer, see SAT at www.t10.org ). Even when the physical transport to the host computer is ATA (especially in the case of SATA) the operating system may choose to put a SAT layer in the driver "stack" (e.g. libata in Linux).

The main identifying command for any SCSI device is an INQUIRY. The corresponding command for an ATA non-packet device is IDENTIFY DEVICE while for an ATA packet device it is IDENTIFY PACKET DEVICE.

When this utility is invoked for an ATAPI device (e.g. a CD/DVD/BD drive with "sg_inq /dev/hdc") then a SCSI INQUIRY is sent to the device and if it responds then the response to decoded and output and this utility exits. To see the response for an ATA IDENTIFY PACKET DEVICE command add the --ata option (e.g. "sg_inq --ata /dev/hdc).

This utility doesn't decode the response to an ATA IDENTIFY (PACKET) DEVICE command, hdparm does a good job at that. The '-HHH' option has been added for use with either the '--ata' or '--page=ai' option to produce a format acceptable to "hdparm --Istdin". An example: 'sg_inq --ata -HHH /dev/hdc | hdparm --Istdin'. See hdparm.

## NVME DEVICES
Currently these device are typically SSDs (Solid State Disks) directly connected to a PCIe connector or via a specialized connector such as a M2 connector. Linux and FreeBSD treat NVMe storage devices as separate from SCSI storage with device names like /dev/nvme0n1 (in Linux) and /dev/nvme0ns1 (in FreeBSD). The NVM Express group has a document titled "NVM Express: SCSI Translation Reference" which defines a partial "SCSI to NVMe Translation Layer" often known by its acronym: SNTL.

On operating systems where it is supported by this package, this utility will detect NVMe storage devices directly connected and send an Identify controller NVMe Admin command and decode its response. A NVMe controller is architecturally similar to a SCSI target device. If the NVMe DEVICE indicates a namespace then an Identify namespace NVMe Admin command is sent to that namespace and its response is decoded. Namespaces are numbered sequentially starting from 1. Namespaces are similar to SCSI Logical Units and their identifiers (nsid_s) can be thought of as SCSI LUNs. In the Linux and FreeBSD example device names above the "n1" and the "ns1" parts indicate nsid 1 . If no namespace is given in the DEVICE then all namespaces found in the controller are sent Identify namespace commands and the responses are decoded.

To get more details in the response use the --long option. To only get the controller's Identify decoded use the --only option.

It is possible that even though the DEVICE presents as a NVMe device, it has a SNTL and accepts SCSI commands. In this case to send a SCSI INQUIRY command (and fetch its VPD pages) use the sg_vpd(8) utility.

## SG_INQ and SG_VPD
Both these utilities have much in common since VPD pages are fetched with the SCSI INQUIRY command. As more VPD pages have been added (and existing pages expanded) the newer ones were only decoded with sg_vpd. Recently with the optional JSON output work, it was decided to place all VPD page decoding in a source file called sg_vpd_common.c that is linked in by both sg_inq and sg_vpd.

This means that the VPD page decoding capabilities of both sg_inq and sg_vpd will be the same. Their default actions remain as they were, namely when sg_inq is used without command line options, it decodes the "standard INQUIRY data format" (usually called the "standard INQUIRY response") response while when sg_vpd is used without options, it decodes the "Supported VPD pages" VPD page.

## EXIT STATUS
The exit status of sg_inq is 0 when it is successful. Otherwise see the sg3_utils(8) man page.

## OLDER COMMAND LINE OPTIONS
The options in this section were the only ones available prior to sg3_utils version 1.23 . Since then this utility defaults to the newer command line options which can be overridden by using --old (or -O) as the first option. See the ENVIRONMENT VARIABLES section for another way to force the use of these older command line options.

-36

only requests 36 bytes of response data for an INQUIRY. Furthermore even if the device indicates in its response it can supply more data, a second (longer) INQUIRY is not performed. This is a paranoid setting. Equivalent to '--len=36' in the OPTIONS section.

-a

fetch the ATA Information VPD page [0x89]. Equivalent to '--page=ai' in the OPTIONS section. This page is defined in SAT (see at www.t10.org).

-A

Assume given DEVICE is an ATA or ATAPI device. Equivalent to --ata in the OPTIONS section.

-b

decodes the Block Limits VPD page [0xb0]. Equivalent to '--page=bl' in the OPTIONS section. This page is defined in SBC-2 (see www.t10.org) and later.

-B=0|1

equivalent to --block=0|1 in OPTIONS section.

-c

set the Command Support Data (CmdDt) bit (defaults to clear(0)). Used in conjunction with the -p=VPD_PG option to specify the SCSI command opcode to query. Equivalent to --cmddt in the OPTIONS section.

-cl

lists the command data for all supported commands (followed by the command name) by looping through all 256 opcodes. This option uses the CmdDt bit which is now obsolete. See the sg_opcodes(8) utility. Equivalent to '--cmddt --cmddt' in the OPTIONS section.

-d

decodes depending on context. If -e option is given, or any option that implies -e (e.g. '-i' or '-p=80'), then this utility attempts to decode the indicated VPD page. Otherwise the version descriptors (if any) are listed following a standard INQUIRY response. In the version descriptors sense, equivalent to --descriptors in the OPTIONS section.

-e

enable (i.e. sets) the Vital Product Data (EVPD) bit (defaults to clear(0)). Used in conjunction with the -p=VPD_PG option to specify the VPD page to fetch. If -p=VPD_PG is not given then VPD page 0 (list supported VPD pages) is assumed.

-f

Equivalent to --force in the OPTIONS section.

-h

outputs INQUIRY response in hex rather than trying to decode it. Equivalent to --hex in the OPTIONS section.

-H

same action as -h. Equivalent to --hex in the OPTIONS section.

-i

decodes the Device Identification VPD page [0x83]. Equivalent to --id in the OPTIONS section. This page is made up of several "designation descriptors". If -h is given then each descriptor header is decoded and the identifier itself is output in hex. To see the whole VPD 0x83 page response in hex use '-p=83 -h'.

-I=FN

equivalent to --inhex=FN in the OPTIONS section.

-j[=JO]

equivalent to --json[=JO] in the OPTIONS section.

-l=LEN

equivalent to --len=LEN in the OPTIONS section.

-L

equivalent to --long in the OPTIONS section.

-m

decodes the Management network addresses VPD page [0x85]. Equivalent to '--page=mna' in the OPTIONS section.

-M

decodes the Mode page policy VPD page [0x87]. Equivalent to '--page=mpp' in the OPTIONS section.

-N, --new

Switch to the newer style options.

-o

equivalent to --only in the OPTIONS section.

-p=VPD_PG

used in conjunction with the -e or -c option. If neither given then the -e option assumed. When the -e option is also given (or assumed) then the argument to this option is the VPD page number. The argument is interpreted as hexadecimal and is expected to be in the range 0 to ff inclusive. Only VPD page 0 is decoded and it lists supported VPD pages and their names (if known). To decode the mandatory device identification page (0x83) use the -i option. A now obsolete usage is when the -c option is given in which case the argument to this option is assumed to be a command opcode number. Recent SCSI draft standards have moved this facility to a separate command (see sg_opcodes(8)). Defaults to 0 so if -e is given without this option then VPD page 0 is output.

-P

decodes the Unit Path Report VPD page [0xc0] which is EMC specific. Equivalent to '--page=upr' in the OPTIONS section.

-r

outputs the response in binary to stdout. Equivalent to --raw in the OPTIONS section. Can be used twice (i.e. '-rr' (and '-HHH' has same effect)) and if used with the -A or -a option yields output with the same format as "cat /proc/ide/hd<x>/identify" so that it can then be piped to "hdparm --Istdin".

-s

decodes the SCSI Ports VPD page [0x88]. Equivalent to '--page=sp' in the OPTIONS section.

-u

equivalent to '--export' in the OPTIONS section.

-v

increase level of verbosity. Can be used multiple times.

-V

print out version string then exit.

-x

decodes the Extended INQUIRY data VPD [0x86] page. Equivalent to '--page=ei' in the OPTIONS section.

-?

output usage message and exit. Ignore all other parameters.

## EXAMPLES
The examples in this page use Linux device names. For suitable device names in other supported Operating Systems see the sg3_utils(8) man page.

To view the standard inquiry response use without options:

sg_inq /dev/sda

Some SCSI devices include version descriptors indicating the various SCSI standards and drafts they support. They can be viewed with:

sg_inq -d /dev/sda

Modern SCSI devices include Vital Product Data (VPD)pages which can be viewed with the SCSI INQUIRY command. To list the supported VPD pages (but not their contents) try:

sg_inq -e /dev/sda

In Linux, binary images of some important VPD page responses (e.g. 0, 80h and 83h) are cached in files within the sysfs pseudo file system. Since VPD pages hardly ever change their contents, decoding those files will give the same output as probing the device with the added benefit that decoding those files doesn't need root permissions. If /dev/sg3 is a disk at 2:0:0:0 , then these three invocations should result in the same output:

sg_inq --raw --inhex=/sys/class/scsi_generic/sg3/device/vpd_pg83

sg_inq -rI /sys/class/scsi_generic/sg3/device/vpd_pg83

sg_inq -r -I /sys/class/scsi_disk/2:0:0:0/device/vpd_pg83

Without the --raw option, the --inhex=FN option would expect the contents of those files to be hexadecimal. vpd_pg83 contains the response (in binary) to the Device Identification VPD page whose page number is 83h (i.e. hexadecimal).

Some VPD pages can be read with the sg_inq utility but a newer utility called sg_vpd specializes in showing their contents. The sdparm utility can also be used to show the contents of VPD pages.

Further examples of sg_inq together with some typical output can be found on https://sg.danny.cz/sg/sg3_utils.html web page.

## ENVIRONMENT VARIABLES
Since sg3_utils version 1.23 the environment variable SG3_UTILS_OLD_OPTS can be given. When it is present this utility will expect the older command line options. So the presence of this environment variable is equivalent to using --old (or -O) as the first command line option.

## AUTHOR
Written by Douglas Gilbert

## REPORTING BUGS
Report bugs to <dgilbert at interlog dot com>.

## COPYRIGHT
Copyright © 2001-2023 Douglas Gilbert

This software is distributed under the GPL version 2 or the BSD-2-Clause license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

## SEE ALSO
sg_opcodes(8), sg_vpd(8), sg_logs(8), sg_modes(8), sg_decode_sense(8), sdparm(8), hdparm(8),sgdiag(scsirastools)


title: sg_logs(8)

text:
# sg_logs(8)

## NAME
sg_logs - access log pages with SCSI LOG SENSE command

## SYNOPSIS
sg_logs [--ALL] [--all] [--brief] [--exclude] [--filter=FL] [--full] [--hex] [--json[=JO]] [--js-file=JFN] [--list] [--maxlen=LEN] [--name] [--no_inq] [--page=PG] [--paramp=PP] [--pcb] [--ppc] [--pdt=DT] [--raw] [--readonly] [--sp] [--temperature] [--transport] [--undefined] [--vendor=VP] [--verbose] DEVICE

sg_logs --inhex=FN [--ALL] [--all] [--brief] [--exclude] [--filter=FL] [--full] [--hex] [--json[=JO]] [--js-file=JFN] [--list] [--name] [--page=PG] [--pdt=DT] [--raw] [--undefined] [--vendor=VP]

sg_logs --select [--control=PC] [--page=PG] [--raw] [--reset] [--sp] [--verbose] DEVICE

sg_logs --enumerate [--filter=FL] [--help] [--vendor=VP] [--version]

sg_logs [-a] [-A] [-b] [-c=PC] [-D=DT] [-e] [-E] [-f=FL] [-F] [-h] [-H] [-i=FN] [-l] [-L] [-m=LEN] [-M=VP] [-n] [-p=PG] [-paramp=PP] [-pcb] [-ppc] [-r] [-R] [-select] [-sp] [-t] [-T] [-u] [-v] [-V] [-?] [-x] DEVICE

## DESCRIPTION
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 which, if known, are decoded by default. When the --reset and/or --select option is given then a SCSI LOG SELECT command is issued to the DEVICE. Alternatively one or more log page responses can be in a file read using the --inhex=FN option; in this case those responses are decoded and the DEVICE argument, if given, is ignored.

In SPC-4 revision 5 the subpage code was introduced to both the LOG SENSE and LOG SELECT command. At the same time a page code field was introduced to the to the LOG SELECT command. The log subpage code can range from 0 to 255 (0xff) inclusive. The subpage code value 255 can be thought of as a wildcard.

The SYNOPSIS section above is divided into five forms. The first form shows the options that can be used to send a LOG SENSE command to the DEVICE and decode its response. The second form fetches data from a file (named FN) and decodes it as if it were a response from a LOG SENSE command. The third form shows the options that can be used to send a LOG SELECT command. The fourth form groups various management options. The last form shows the older, deprecated command line interface which is maintained for backward compatibility.

When no options are given, just a DEVICE, that is equivalent to calling this utility with the --list option. In that case the names of the supported log pages (but not subpages) are listed out.

## OPTIONS
Arguments to long options are mandatory for short options as well. The options are arranged in alphabetical order based on the long option name.

-A, --ALL

fetch and decode all the log pages and subpages supported by the DEVICE. This requires a two stage process: first the "supported log pages and subpages" log page is fetched, then for each entry in its response, the corresponding log page (or subpage) is fetched and displayed. Note that there are many SCSI devices that do not support LOG SENSE subpages and respond to this option with an illegal request sense key. In this case this utility continues by fetching the supported log pages log page instead. In other words if the --ALL option fails then the --all is used instead. The reason is that almost certainly the DEVICE does not have any log subpages to report.

To force an error if the fetch of the supported log pages and subpages log page fails use both the --ALL and --full options.

Since some vendors don't list all log pages in the "supported log pages and subpages" log page, the '-lll' option can be given in addition. This will merge both "supported ..." log pages then, from that resultant merged list, fetch page contents.

This option overrides the --page=PG if the latter is also given.

-a, --all

outputs all the log pages supported by the DEVICE. This requires a two stage process: first the "supported log pages" log page is fetched, then for each entry in its response, the corresponding log page is fetched and displayed. When used twice (e.g. '-aa') all log pages and subpages are fetched.

This option overrides the --page=PG if the latter is also given.

-b, --brief

shorten the amount of output for some log pages. For example the Tape Alert log page only outputs parameters whose flags are set when --brief is given.

-c, --control=PC

accepts 0, 1, 2 or 3 for the PC argument:

0 : current threshold values

1 : current cumulative values

2 : default threshold values

3 : default cumulative values

The default value is 1 (i.e. current cumulative values).

-e, --enumerate

this option is used to output information held in this utility's internal tables about known log pages including their name, acronym and fields. If given, the DEVICE argument is ignored. When given once (e.g. '-e') all known pages are listed, sorted in ascending alphabetical acronym order.

When given twice, vendor pages are excluded. When given three times, all known pages are listed, sorted in ascending numeric order listed; when given four times, vendor pages are excluded from the numeric order.

The --filter=FL and --verbose options reduce the output of the enumeration.

-E, --exclude

this option excludes vendor specific pages and parameters from the output. Trying to decode vendor specific pages and parameters does not necessarily work well for many reasons. This option limits the output to pages and parameters defined by T10.

Only parameter fields identified in the drafts as 'vendor specific' are excluded. So parameters codes identified as 'reserved' are shown.

-f, --filter=FL

FL is either a parameter code when DEVICE is given, or a peripheral device type (pdt) (or other) if --enumerate is given.

In the parameter code case FL is a value between 0 and 65535 (0xffff) and only the parameter section matching that code is output. If the --hex option is given the log parameter is output in hexadecimal rather than decoding it. If the --hex option is used twice then the leading address on each line of hex is removed. If the --raw option is given then the log parameter is output in binary. Most log pages contain one or more log parameters. Examples of those that don't follow that convention are those pages that list supported log pages (and subpages).

In the --enumerate case, when FL >= zero it is taken as a pdt value and only log pages associated with that pdt plus generic pages listed in SPC are enumerated. If FL is -1 then the filter does nothing which is the same as not giving this option; when FL is -2 then only generic pages listed in SPC are enumerated. If FL is -10 then only generic direct access like (e.g. disk) pages are enumerated. If FL is -11 then only generic tape like pages (e.g. includes ADC) are enumerated.

-F, --full

this option is only used in two situations: with the Application client (AC) log page and with the --ALL option. Typically the AC log page has more than 16,000 bytes of user supplied data. Rather than print it all out, the default is to print out the first 64 bytes of data. When this option is given, the application client log pages is fully decoded.

When both this option and the --ALL option are given, then this utility will exit with an error if the Supported log pages and subpages log page is not available.

-h, --help

print out the usage message then exit.

-H, --hex

The default action is to decode known log page numbers (and subpage numbers) into text. When this option is used once, the response is output in hexadecimal. When used twice, each line of hex has the ASCII equivalent shown to the right. When used three times, the hex has no leading address nor trailing ASCII making it suitable to be placed in a file (or piped). That file might later be used by another invocation using the --inhex=FN option.

A weaker form of this option, called --undefined, handles the formatting of hexadecimal output for fields that this utility is unable to decode.

-i, --in=FN

Same as --inhex=FN option. Kept for backward compatibility.

-i, --inhex=FN

This option may be used in two different contexts. One is with the --select to send a LOG SELECT command to the given DEVICE; see the LOG SELECT section below.

The other context is with no DEVICE argument given in which case the contents of FN are decoded as if it were the response of a LOG SENSE command (i.e. one or more log page). For decoding, the page and subpage numbers are taken from FN while the peripheral device type is either generic (i.e. from SPC) or the value given by --pdt=DT.

FN is treated as a file name (or '-' for stdin) which contains ASCII hexadecimal or binary representing a log page. The hexadecimal should be arranged as 1 or 2 digits representing a byte each of which is whitespace or comma separated. Anything from and including a hash mark to the end of line is ignored. If the --raw option is also given then FN is treated as binary.

-j[=JO], --json[=JO]

output is in JSON format instead of plain text form. Note that arguments to the short and long form are themselves optional and if present start with "=" and no whitespace is permitted around that "=".

See sg3_utils_json manpage or use '?' for JO to get a summary.

-J, --js-file=JFN

output is in JSON format and it is sent to a file named JFN. If that file exists then it is truncated. By default, the JSON output is sent to stdout.

When this option is given, the --json[=JO] option is implied and need not be given. The --json[=JO] option may still be needed to set the JO parameter to non-default values.

-l, --list

lists the names of the logs sense pages supported by this device. This is done by reading the "supported log pages" log page. When used once only log pages, but not subpages, are listed. When used twice the "supported log pages and subpages" log page is output. Some vendors do not list some log pages (e.g. those without any subpages) in the "supported log pages and subpages" log page. To get a full inventory, this option can be used three times (e.g. '-lll') and the output of the two log pages is merged. Even if the "supported log pages and subpages" log page is not supported using this option three times will yield a list from the "supported log pages" log page. In the absence of other options, the page/subpage names, but not their contents, are shown when this option is given.

The '-lll' form may be useful with the --ALL option to show the contents of all pages referred to in either the "supported log page" or the "supported log page and subpage" log pages.

-m, --maxlen=LEN

sets the "allocation length" field in the LOG SENSE cdb. The is the maximum length in bytes that the response will be. Without this option (or LEN equal to 0) this utility first fetches the 4 byte response then does a second access with the length indicated in the first (4 byte) response. Negative values and 1 for LEN are not accepted. Responses can be quite large (e.g. the background scan results log page) and this option can be used to limit the amount of information returned.

The default LEN is 65532 unless the --in=FN option is given; in that case the default is 262144 .

-n, --name

decode some log pages into 'name=value' entries, one per line. The name contains no space and may be abbreviated and the value is decimal unless prefixed by '0x'. Nesting is indicated by leading spaces. This form is meant to be relatively easy to parse.

This option is superseded by the --json[=JO] option. If both are given then this option is ignored.

-x, --no_inq

suppresses the output of information obtained from an initial call to the INQUIRY command for the standard response. The default (assuming some other options that suppress this output are also not given) is to output several device identification strings.

If this option is given twice (or more) then no INQUIRY command is sent hence there will be no device identification string output either. Also the peripheral device type (PDT) field will not be obtained so this utility will not be able to differentiate between some log pages that are device dependent. The utility will assume a PDT of 0 (i.e. a disk) unless the --pdt=DT option is given.

-O, --old

Switch to older style options. Please use as first option.

-p, --page=PG

log page name/number to access. PG is either an acronym, a page number, or a page, subpage number pair. Available acronyms can be listed with the --enumerate option. Page (0 to 63) and subpage (0 to 255) numbers are comma separated. They are decimal unless a hexadecimal indication is given. A hexadecimal number can be specified by a leading "0x" or a trailing "h".

A few acronyms specify a range of subpage values in which case the acronym may be followed by a comma then a subpage number. This method can also be used to fetch the Supported subpages log page (e.g. --page=temp,0xff).

-P, --paramp=PP

PP is the parameter pointer value to place in a field of that name in the LOG SENSE cdb. A number in the range 0 to 65535 (0x0 to 0xffff) is expected. When a value greater than 0 is given the --ppc option should be selected. The default value is 0.

For log pages that have parameter codes, the DEVICE should return only parameters code equal to PP or higher in its response.

-q, --pcb

show Parameter Control Byte settings (only relevant when log parameters being output in ASCII). This byte includes the DU and TSD bits plus the 'Format and linking' field (2 bits wide).

-D, --pdt=DT

DT is the peripheral device type (PDT) that is used when it is not available from the DEVICE. There are several cases: when the DEVICE is not given (e.g. when the --inhex=FN or --enumerate option is given) and when DEVICE is and is coupled with the --no_inq option. That stops this utility sending the SCSI INQUIRY command which is where this utility usually finds the PDT associated log pages being decoded.

Numerical values between -1 and 31 (inclusive) may be used where -1 implies what is in SPC. SCSI Primary Commands (SPC) are common to all SCSI devices. Names like 'tape', 'disk' and 'processor' may also be given for DT. The default is 0 or 'disk' for SBC (and the associated standard acronym may also be given which is 'sbc' in this case).

-Q, --ppc

sets the Parameter Pointer Control (PPC) bit in the LOG SENSE cdb. Default is 0 (i.e. cleared). This bit was made obsolete in SPC-4 revision 18.

-r, --raw

output the response in binary to stdout. Error messages and warnings are output to stderr.

This option may also be given together with --in=FN in which case the contents of FN are interpreted as binary data (and the response is decoded as normal, not dumped as binary).

-R, --readonly

open the DEVICE read-only (e.g. in Unix with the O_RDONLY flag). The default action is to try and open DEVICE read-write then if that fails try to open again with read-only. However when a read-write open succeeds there may still be unwanted actions on the close (e.g. some OSes try to do a SYNCHRONIZE CACHE command). So this option forces a read-only open on DEVICE and if it fails, this utility will exit. Note that options like --select most likely need a read-write open.

-R, --reset

use SCSI LOG SELECT command (with the PCR bit set) to reset the all log pages (or the given page). Exactly what is reset depends on the accompanying SP bit (i.e. --sp option which defaults to 0) and the PC ("page control") value (which defaults to 1). Supplying this option implies the --select option as well. This option seems to clear error counter log pages but leaves pages like self-test results, start-stop cycle counter and temperature log pages unaffected. This option may be required to clear log pages if a counter reaches its maximum value since the log page in which the counter is found will remain "stuck" at its maximum value until some user interaction (e.g. calling sg_logs with this option).

-S, --select

use a LOG SELECT command. The default action (i.e. when neither this option nor --reset is given) is to do a LOG SENSE command. See the LOG SELECT section.

-s, --sp

sets the Saving Parameters (SP) bit. Default is 0 (i.e. cleared). When set this instructs the device to store the current log page parameters (as indicated by the DS and TSD parameter codes) in some non-volatile location. Hence the log parameters will be preserved across power cycles. This option is typically not needed, especially if the GLTSD flag is clear in the control mode page which causes the DEVICE to periodically save all saveable log parameters to non-volatile storage.

-t, --temperature

outputs the temperature. First looks in the temperature log page and if that is not available tries the Informational Exceptions log page which may also have the current temperature (especially on older disks).

-T, --transport

outputs the transport ('Protocol specific port') log page. Equivalent to setting '--page=18h'.

-u, --undefined

to see fields decoded, the --hex option cannot be used. However some fields are not defined in the T10 documents and in that case they are output in hex. This option controls the format of 'undefined' fields when they output in hex. Multiple uses of this option has the same sense as the --hex option. For example '-uu' will output undefined fields in hexadecimal with an ASCII rendering to the right of each line.

-M, --vendor=VP

where VP is a vendor/manufacturer (e.g. "sea" for Seagate) or product (group) acronym (e.g. "lto5" for the 5th generation LTO (tape) consortium). Either the whole log page is vendor specific (e.g. page numbers 0x30 to 0x3f) or part of a T10 defined log page is vendor specific. For example SPC-5 defines parameter code 0x0 of page 0x2f (the Informational Exceptions log page) and states that the remaining parameter codes (i.e. 0x1 to 0xffff) are vendor specific. Using a VP of "xxx" will list the available acronyms.

If this option is used with --page=PG and PG is an acronym then this option is ignored. If PG is a number (e.g. 0xc0) then VP is used to choose the which vendor specific page (e.g. sharing page number 0xc0) to decode.

-v, --verbose

increase level of verbosity. When used with --enumerate, in the list of known log page names, those that have no associated decode logic are followed by "[hex only]".

-V, --version

print out version string then exit.

## LOG SELECT
The SCSI LOG SELECT command can be used to reset certain parameters to vendor specific defaults, save them to non-volatile storage (i.e. the media), or supply new page contents. This command has changed between SPC-3 and SPC-4 with the addition of the Page and Subpage Code fields which can only be non zero when the Parameter list length is zero.

The --select (or --reset) option is required to issue a LOG SELECT command. If the --in=FN option is not given (or FN is effectively empty) then the Parameter list length field is set to zero. If the --in=FN option is is given then its decoded data is placed in the data-out buffer and its length in bytes is placed in the Parameter list length field.

Other options that are active with the LOG SELECT command are --control=PC, --reset (which sets the PCR bit) and --sp.

## APPLICATION CLIENT
This is the name of a log page that acts as a container for data provided by the user. An application client is a SCSI term for the program that issues commands to a SCSI initiator (often known as a Host Bus Adapter (HBA)). So, for example, this utility is a SCSI application client.

The Application Client log page has 64 log parameters with parameters codes 0 to 63. Each can hold 252 bytes of user binary data. That 252 bytes (or less) of user data, with a 4 byte prefix (for a total of 256 bytes) can be provided with the --in=FN option. A typical prefix would be '0,n,83,fc'. The "n" is the parameter code in hex so the last log parameter would be '0,3f,83,fc'. That log parameter could be read back at some later time with '--page=0xf --filter=0x<n>'.

## INHEX INSTEAD OF DEVICE
This section applies when the --inhex=FN option is used and there is no DEVICE argument. This can be viewed as a replay facility where the FN file was created by a prior invocation of this utility, most likely with the '-HHHHH' option, with command line output redirection used to create FN.

If the --all option is given once then all pages (but not subpages) found in FN will be decoded, or output in hex if this utility is unable to decode some of them. If the --all option is given two or more times then all pages and subpages found in FN will be decoded. In both cases pages are decoded in the order they are found in FN.

Next, if the --page=PG] option is given, then FN is searched for a match on PG and, if found, that log (sub)page is decoded. If the --list option is given once, then the Supported log pages log page [0x0,0x0] is decoded, if present. If the --list option is given two or more times, then the Supported Log Pages and Subpages log page [0x0,0xff] is decoded, if present.

If none of the above selection options are given, then this utility will attempt to decode the first log page found in FN. If there are more log pages following the first one in FN then they are ignored.

## NOTES
This utility will usually do a double fetch of log pages with the SCSI LOG SENSE command. The first fetch requests a 4 byte response (i.e. place 4 in the "allocation length" field in the cdb). From that response it can calculate the actual length of the response which is what it asks for on the second fetch. This is typical practice in SCSI and guaranteed to work in the standards. However some older devices don't comply. For those devices using the --maxlen=LEN option will do a single fetch. A value of 252 should be a safe starting point.

Various log pages hold information error rates, device temperature, start stop cycles since the device was produced and the results of the last 20 self tests. Self tests can be initiated by the sg_senddiag(8) utility. The smartmontools package provides much of the information found with sg_logs in a form suitable for monitoring the health of SCSI disks and tape drives.

The simplest way to find which log pages can be decoded by this utility is to use the --enumerate option. Some page names are known but there is no decode logic; such cases have "[hex only]" after the log page name when the --verbose option is given with --enumerate.

Vendors are specifically permitted by the SPC-6 to _not_ report all pages and subpages supported by a device. That weakens the usefulness of the pages that report a list of supported pages and subpages. One guarantee which is given is that the pages reported shall be in ascending order.

## EXIT STATUS
The exit status of sg_logs is 0 when it is successful. Otherwise see the sg3_utils(8) man page.

## OLDER COMMAND LINE OPTIONS
The options in this section were the only ones available prior to sg3_utils version 1.23 . Since then this utility defaults to the newer command line options which can be overridden by using --old (or -O) as the first option. See the ENVIRONMENT VARIABLES section for another way to force the use of these older command line options.

Options with arguments or with two or more letters can have an extra '-' prepended. For example: both '-pcb' and '--pcb' are acceptable.

-a

outputs all the log pages supported by the DEVICE. Equivalent to --all in the main description.

-A

outputs all the log pages and subpages supported by the DEVICE. Equivalent to --ALL in the main description.

-c=PC

Equivalent to --control=PC in the main description.

-D=DT

Equivalent to --pdt=DT in the main description.

-e

enumerate internal tables to show information about known log pages. Equivalent to --enumerate in the main description.

-E

Equivalent to --exclude in the main description.

-h

suppresses decoding of known log sense pages and prints out the response in hex instead.

-i=FN

FN is treated as a file name (or '-' for stdin) which contains ASCII hexadecimal representing a log page that will be sent as parameter data of a LOG SELECT command. See the LOG SELECT section.

-H

same action as '-h' in this section and equivalent to --hex in the main description.

-l

lists the names of all logs sense pages supported by this DEVICE. Equivalent to --list in the main description.

-L

lists the names of all logs sense pages and subpages supported by this DEVICE. Equivalent to '--list --list' in the main description.

-m=LEN

request only LEN bytes of response data. Default is 0 which is interpreted as all that is available. LEN is decimal unless it has a leading '0x' or trailing 'h'. Equivalent to --maxlen=LEN in the main description.

-M=VP

Equivalent to --vendor=VP in the main description.

-n

Equivalent to --name in the main description.

-N, --new

Switch to the newer style options.

-p=PG

log page code to access. PG is either an acronym, a page number, or a page, subpage pair. Available acronyms can be listed with the --enumerate option. Page (0 to 3f) and subpage (0 to ff) numbers are comma separated. The numbers are assumed to be hexadecimal.

-paramp=PP

PP is the parameter pointer value (in hex) to place in command. Should be a number between 0 and ffff inclusive.

-pcb

show Parameter Control Byte settings (only relevant when log parameters being output in ASCII).

-ppc

sets the Parameter Pointer Control (PPC) bit. Default is 0 (i.e. cleared).

-r

use SCSI LOG SELECT command (PCR bit set) to reset the all log pages (or the given page). Equivalent to --reset in the main description.

-R

Equivalent to --readonly in the main description.

-select

use a LOG SELECT command. Equivalent to --select in the main description.

-sp

sets the Saving Parameters (SP) bit. Default is 0 (i.e. cleared). Equivalent to --sp in the main description.

-t

outputs the temperature. Equivalent to --temperature in the main description.

-T

outputs the transport ('Protocol specific port') log page. Equivalent to --transport in the main description.

-v

increase level of verbosity.

-V

print out version string then exit.

-x

suppress the INQUIRY command. Equivalent to --no_inq in the main description.

-?

output usage message then exit.

## ENVIRONMENT VARIABLES
Since sg3_utils version 1.23 the environment variable SG3_UTILS_OLD_OPTS can be given. When it is present this utility will expect the older command line options. So the presence of this environment variable is equivalent to using --old (or -O) as the first command line option.

## AUTHOR
Written by Douglas Gilbert

## REPORTING BUGS
Report bugs to <dgilbert at interlog dot com>.

## COPYRIGHT
Copyright © 2002-2023 Douglas Gilbert

This software is distributed under the GPL version 2. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

## SEE ALSO
smartctl(smartmontools), sg_senddiag(8)


title: sg_luns(8)

text:
# sg_luns(8)

## NAME
sg_luns - send SCSI REPORT LUNS command or decode given LUN

## SYNOPSIS
sg_luns [--decode] [--help] [--hex] [--inhex=FN] [--inner-hex] [--json[=JO]] [--js-file=JFN] [--linux] [--lu_cong] [--maxlen=LEN] [--quiet] [--raw] [--readonly] [--select=SR] [--sinq_inraw=RFN] [--verbose] [--version] DEVICE

sg_luns --test=ALUN [--decode] [--hex] [--inner-hex] [--lu_cong] [--verbose]

## DESCRIPTION
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 LUNs ("a LUN inventory") for the I_T nexus associated with the DEVICE. Roughly speaking that is all LUNs that share the target device that the REPORT LUNS command is sent through. This command is defined in the SPC-3 and SPC-4 SCSI standards and its support is mandatory. The most recent draft if SPC-6 revision 1.

When the --test=ALUN option is given (the second form in the SYNOPSIS), then the ALUN value is decoded as outlined in various SCSI Architecture Model (SAM) standards and recent drafts (e.g. SAM-6 revision 2, section 4.7) .

Where required below the first form shown in the SYNOPSIS is called "device mode" and the second form is called "test mode".

## OPTIONS
Arguments to long options are mandatory for short options as well.

-d, --decode

decode LUNs into their component parts, as described in the LUN section of SAM-3, SAM-4 and SAM-5.

[test mode] ALUN is decoded irrespective of whether this option is given or not. If this option is given once then the given ALUN is output in T10 preferred format (which is 8 pairs of hex digits, each separated by a space). If given twice then the given ALUN is output in an alternate T10 format made up of four quads of hex digits with each quad separated by a "-" (e.g. C101-0000-0000-0000).

-h, --help

output the usage message then exit.

-H, --hex

[device mode] when given once this utility will output the SCSI response (i.e. the data-out buffer) to the REPORT LUNS command in ASCII hex then exit. When given twice it causes --decode to output component fields in hex rather than decimal. Notice that this (i.e. how '-HH' is processed) differs from the description in sg3_utils(8). The --inner-hex option has the same action as '-HH'. When this option is used three (or more) times the hex output is suitable for placing in a file and using it with a later sg_luns invocation with the --inhex=FN option.

[test mode] when this option is given, then decoded component fields of ALUN are output in hex.

When this option is given three or more times, ASCII hex bytes are output (up to 16 per line) with no leading address or index. This output is suitable for placing in a file and later invocation of this utility decoding it with the --inhex=FN option. When this option is used four times, a comment line (starting with '#' is added before the hex) describing what the hex was generated by. A file containing such comments is still parsable by the --inhex=FN option.

-i, --inhex=FN

FN is expected to be a file name (or '-' for stdin) which contains ASCII hexadecimal or binary representing a REPORT LUNS response. This utility will then decode that response. See the "HEX, BINARY AND JSON FORMATS" section in the sg3_utils manpage for more information. If the --raw option is also given then FN is treated as binary.

-I, --inner-hex

used together with the --decode option so that the decoded values are shown in hexadecimal. The default action is to show decoded values in decimal. This option has the same action as '-HH' but the intent is a little clearer with this option.

-j[=JO], --json[=JO]

output is in JSON format instead of plain text form. Note that arguments to the short and long form are themselves optional and if present start with "=" and no whitespace is permitted around that "=".

See sg3_utils_json manpage or use '?' for JO to get a summary.

-J, --js-file=JFN

output is in JSON format and it is sent to a file named JFN. If that file exists then it is truncated. By default, the JSON output is sent to stdout.

When this option is given, the --json[=JO] option is implied and need not be given. The --json[=JO] option may still be needed to set the JO parameter to non-default values.

-l, --linux

this option is only available in Linux. After the T10 representation of each 64 bit LUN (in 16 hexadecimal digits), if this option is given then to the right, in square brackets, is the Linux LUN integer in decimal. If the --hex option is given twice (e.g. -HH) as well then the Linux LUN integer is output in hexadecimal.

-L, --lu_cong

this option is only considered with --decode. When given once then the list of LUNs is decoded as if the LU_CONG bit was set in each LU's corresponding INQUIRY response. When given twice the list of LUNs is decoded as if the LU_CONG bit was clear in each LU's corresponding INQUIRY response. When this option is not given and --decode is given then an INQUIRY is sent to the DEVICE and the setting of its LU_CONG bit is used to decode the list of LUNs.

[test mode] decode ALUN as if the LU_CONG bit is set in its corresponding standard INQUIRY response. In other words treat ALUN as if it is a conglomerate LUN. If not given (or given twice) then decode ALUN as if the LU_CONG bit is clear.

-m, --maxlen=LEN

where LEN is the (maximum) response length in bytes. It is placed in the cdb's "allocation length" field. If not given (or LEN is zero) then 8192 is used. The maximum allowed value of LEN is 1048576.

-q, --quiet

output only the ASCII hex rendering of each report LUN, one per line. Without the --quiet option, there is header information printed before the LUN listing.

-r, --raw

output the SCSI response (i.e. the data-out buffer) in binary (to stdout).

-R, --readonly

open the DEVICE read-only (e.g. in Unix with the O_RDONLY flag). The default is to open it read-write.

-s, --select=SR

SR is placed in the SELECT REPORT field of the SCSI REPORT LUNS command. The default value is 0. Hexadecimal values may be given with a leading "0x" or a trailing "h". For detailed information see the REPORT LUNS command in SPC (most recent is SPC-4 revision 37 in section 6.33). To simplify, for the I_T nexus associated with the DEVICE, the meanings of the SR values defined to date for SPC-4 are:

0 : most luns excluding well known logical unit numbers

1 : well known logical unit numbers

2 : all luns accessible to this I_T nexus

0x10 : only accessible administrative luns

0x11 : administrative luns plus non-conglomerate luns (see SPC-4)

0x12 : if DEVICE is an administrative LU, then report its

lun plus its subsidiary luns

For SR values 0x10 and 0x11, the DEVICE must be either LUN 0 or the REPORT LUNS well known logical unit. Values between 0xf8 and 0xff (inclusive) are vendor specific, other values are reserved. This utility will accept any value between 0 and 255 (0xff) for SR .

-Q, --sinq_inraw=RFN

where RFN is a filename containing binary standard INQUIRY response data that matches either DEVICE or FN. Linux places this standard INQUIRY response in its sysfs pseudo filesystem. A typical location is at /sys/class/scsi_device/<hctl>/device/inquiry where <hctl> is a four part numeric tuple separated by colons. This tuple distinguishes the device from any others on the system.

Currently the LU_CONG field is read from the standard INQUIRY response when this option is given. The --raw option has no effect on this option. The DEVICE argument may be given with this option.

-t, --test=ALUN

ALUN is assumed to be a hexadecimal number in ASCII hex or the letter 'L' followed by a decimal number (see below). The hexadecimal number can be up to 64 bits in size (i.e. 16 hexadecimal digits) and is padded to the right if less than 16 hexadecimal digits are given (e.g. --test=0122003a represents T10 LUN: 01 22 00 3a 00 00 00 00). ALUN may be prefixed by '0x' or '0X' (e.g. the previous example could have been --test=0x0122003a). ALUN may also be given with spaces, tabs, or a '-' between each byte (or other grouping (e.g. c101-0000-0000-0000)). However in the case of space or tab separators the ALUN would need to be surrounded by single or double quotes.

In the leading 'L' case the, following decimal number (hex if preceded by '0x') is assumed to be a Linux "word flipped" LUN which is converted into a T10 LUN representation and printed. In both cases the number is interpreted as a LUN and decoded as if the --decode option had been given. Also when ALUN is a hexadecimal number it can have a trailing 'L' in which case the corresponding Linux "word flipped" LUN value is output. The LUN is decoded in all cases.

The action when used with --decode is explained under that option.

-v, --verbose

increase the level of verbosity, (i.e. debug output).

-V, --version

print the version string and then exit.

## NOTES
The SCSI REPORT LUNS command is important for Logical Unit (LU) discovery. After a target device is discovered (usually via some transport specific mechanism) and after sending an INQUIRY command (to determine the LU_CONG setting), a REPORT LUNS command should either be sent to LUN 0 (which is Peripheral device addressing method with bus_id=0 and target/lun=0) or to the REPORT LUNS well known LUN (i.e. 0xc101000000000000). SAM-5 requires that one of these responds with an inventory of LUNS that are contained in this target device.

In test mode, if the --hex option is given once then in the decoded output, some of the component fields are printed in hex with leading zeros. The leading zeros are to indicate the size of the component field. For example: in the Peripheral device addressing method (16 bits overall), the bus ID is 6 bits wide and the target/LUN field is 8 bits wide; so both are shown with two hex digits (e.g. bus_id=0x02, target=0x3a).

## EXAMPLES
Typically by the time user space programs get to run, SCSI LUs have been discovered. In Linux the lsscsi utility lists the LUs that are currently present. The LUN of a device (LU) is the fourth element in the tuple at the beginning of each line. Below we see a target (or "I_T Nexus": "6:0:0") has two LUNS: 1 and 49409. If 49409 is converted into T10 LUN format it is 0xc101000000000000 which is the REPORT LUNS well known LUN.

\# lsscsi -g

[6:0:0:1] disk Linux scsi_debug 0004 /dev/sdb /dev/sg1

[6:0:0:2] disk Linux scsi_debug 0004 /dev/sdc /dev/sg2

[6:0:0:49409]wlun Linux scsi_debug 0004 - /dev/sg3

We could send a REPORT LUNS command (with SR 0x0, 0x1 or 0x2) to any of those file device nodes and get the same result. Below we use /dev/sg1 :

\# sg_luns /dev/sg1

Lun list length = 16 which implies 2 lun entries

Report luns [select_report=0x0]:

0001000000000000

0002000000000000

That is a bit noisy so cut down the clutter with --quiet:

\# sg_luns -q /dev/sg1

0001000000000000

0002000000000000

Now decode that LUN into its component parts:

\# sg_luns -d -q /dev/sg1

0001000000000000

Peripheral device addressing: lun=1

0002000000000000

Peripheral device addressing: lun=2

Now use --select=1 to find out if there are any well known LUNs:

\# sg_luns -q -s 1 /dev/sg1

c101000000000000

So how many LUNs do we have all together (associated with the current I_T Nexus):

\# sg_luns -q -s 2 /dev/sg1

0001000000000000

0002000000000000

c101000000000000

\# sg_luns -q -s 2 -d /dev/sg1

0001000000000000

Peripheral device addressing: lun=1

0002000000000000

Peripheral device addressing: lun=1

c101000000000000

REPORT LUNS well known logical unit

The following example uses the --linux option and is not available in other operating systems. The extra number in square brackets is the Linux version of T10 LUN shown at the start of the line.

\# sg_luns -q -s 2 -l /dev/sg1

0001000000000000 [1]

0002000000000000 [2]

c101000000000000 [49409]

Now we use the --test= option to decode LUNS input on the command line (rather than send a REPORT LUNS command and act on the response):

\# sg_luns --test=0002000000000000

Decoded LUN:

Peripheral device addressing: lun=2

\# sg_luns --test="c1 01"

Decoded LUN:

REPORT LUNS well known logical unit

\# sg_luns -t 0x023a004b -H

Decoded LUN:

Peripheral device addressing: bus_id=0x02, target=0x3a

>>Second level addressing:

Peripheral device addressing: lun=0x4b

The next example is Linux specific as we try to find out what the Linux LUN 49409 translates to in the T10 world:

\# sg_luns --test=L49409

64 bit LUN in T10 preferred (hex) format: c1 01 00 00 00 00 00 00

Decoded LUN:

REPORT LUNS well known logical unit

And the mapping between T10 and Linux LUN representations can be done the other way:

\# sg_luns -t c101L

Linux 'word flipped' integer LUN representation: 49409

Decoded LUN:

REPORT LUNS well known logical unit

## EXIT STATUS
The exit status of sg_luns is 0 when it is successful. Otherwise see the sg3_utils(8) man page.

## AUTHORS
Written by Douglas Gilbert.

## REPORTING BUGS
Report bugs to <dgilbert at interlog dot com>.

## COPYRIGHT
Copyright © 2004-2023 Douglas Gilbert

This software is distributed under a BSD-2-Clause license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

## SEE ALSO
sg_inq(8),sg3_utils(8)


title: sg_map(8)

text:
# sg_map(8)

## NAME
sg_map - displays mapping between Linux sg and other SCSI devices

## SYNOPSIS
sg_map [-a] [-h] [-i] [-n] [-scd] [-sd] [-sr] [-st] [-V] [-x]

## DESCRIPTION
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 corresponding SCSI disk, cdrom or tape device name (if any). Scanners are an example of SCSI devices that have no alternate SCSI device name apart from their sg device name.

This utility is deprecated and has not been updated for years, only very obvious bugs will be fixed. Unless a very old version of Linux is being used (e.g. 2.4 series or earlier), then please use a utility like lsscsi(8) or the facilities offered by udev(8).

## OPTIONS
-a

assume the sg devices have alphabetical device names and loop through /dev/sga, /dev/sgb, etc. Default is numeric scan. Note that sg device nodes with an alphabetical index have been deprecated since the Linux kernel 2.2 series.

-h

print usage message then exit.

-i

in addition do a standard INQUIRY and output vendor, product and revision strings for devices that are found.

-n

assume the sg devices have numeric device names and loop through /dev/sg0, /dev/sg1, etc. Default is numeric scan

-scd

display mappings to SCSI cdrom device names of the form /dev/scd0, /dev/scd1 etc

-sd

display mappings to SCSI disk device names

-sr

display mappings to SCSI cdrom device names of the form /dev/sr0, /dev/sr1 etc

-st

display mappings to SCSI tape device names

-V

print out version string then exit (without further ado).

-x

after each active sg device name is displayed there are five digits: <host_number> <bus> <scsi_id> <lun> <scsi_type>

## NOTES
If no options starting with "-s" are given then the mapping to all SCSI disk, cdrom and tape device names is shown.

If the device file system (devfs) is present a line noting this is output. The "native" devfs scsi hierarchy makes the relationship between a sg device name and any corresponding disk, cdrom or tape device name easy to establish. This replaces the need for this command. However many applications will continue to look for Linux SCSI device names in their traditional places. [Devfs supplies a compatibility daemon called devfsd whose default configuration adds back the Linux device names in their traditional positions.

Quite often the mapping information can be derived by observing the output of the command: "sg_map". However if devices have been added since boot this can be deceptive.

In the Linux kernel 2.6 series something close to the mapping shown by this utility can be found by analysing sysfs. The main difference is that sysfs analysis will show the mapping between sg nodes and other SCSI device nodes in terms of major and minor numbers. While major 8, minor 16 will usually be /dev/sdb this is not necessarily so. Facilities associated with udev may assign major 8, minor 16 some other device node name. This version of sg_map has been extended to cope with sparse disk device node names of the form "/dev/sd<str>" where <str> can be one of [a-z,aa-zz,aaa-zzz]. See the sg_map26 utility for a more precise way (i.e. less directory scanning) for mapping between sg device names and higher level names; including finding user defined names.

This utility was written at a time when hotplugging of SCSI devices was not supported in Linux. It used a simple algorithm to scan sg device nodes in ascending numeric or alphabetical order, stopping after there were 5 consecutive errors.

In the Linux kernel 2.6 series, this utility uses sysfs to find which sg device nodes are active and only checks those. Hence there can be large "holes" in the numbering of sg device nodes (e.g. after an adapter has been removed) and still all active sg device nodes will be listed. This utility assumes that sg device nodes are named using the normal conventions and searches from /dev/sg0 to /dev/sg4095 inclusive.

## EXAMPLES
My system has a SCSI disk, a cd writer and a dvd player:

$ sg_map

\# Note: the devfs pseudo file system is present

/dev/sg0 /dev/sda

/dev/sg1 /dev/sr0

/dev/sg2 /dev/sr1

In order to find which sg device name corresponds to the disk:

$ sg_map -sd

\# Note: the devfs pseudo file system is present

/dev/sg0 /dev/sda

/dev/sg1

/dev/sg2

The "-x" option gives the following output:

sg_map -x

\# Note: the devfs pseudo file system is present

/dev/sg0 1 0 1 0 0 /dev/sda

/dev/sg1 2 0 4 0 5 /dev/sr0

/dev/sg2 2 0 6 0 5 /dev/sr1

When a SCSI scanner is added the output becomes:

$ sg_map

\# Note: the devfs pseudo file system is present

/dev/sg0 /dev/sda

/dev/sg1 /dev/sr0

/dev/sg2 /dev/sr1

/dev/sg3

By process of elimination /dev/sg3 must be the scanner.

## EXIT STATUS
The exit status of sg_map is 0 when it is successful. Otherwise see the sg3_utils(8) man page.

## AUTHOR
Written by Douglas Gilbert

## REPORTING BUGS
Report bugs to <dgilbert at interlog dot com>.

## COPYRIGHT
Copyright © 2000-2013 Douglas Gilbert

This software is distributed under the GPL version 2. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

## SEE ALSO
sg_map26(8) , scsi_info(8) , scsidev(8) , devfsd(8) , lsscsi(8) , udev(7)


title: sg_map26(8)

text:
# sg_map26(8)

## NAME
sg_map26 - map SCSI generic (sg) device to corresponding device names

## SYNOPSIS
sg_map26 [--dev_dir=DIR] [--given_is=0|1] [--help] [--result=0|1|2|3] [--symlink] [--verbose] [--version] DEVICE

## DESCRIPTION
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, for example '/sys/block/sda' or '/sys/block/sda/dev'.

Rather than map to or from a sg device, the sysfs file name matching a given device special file (or vice versa) can be requested. This is done with '--result=2' and '--result=3'. This feature works on ATA devices (e.g. 'dev/hdc') as well as SCSI devices.

In this utility, "mapped" refers to finding the relationship between a SCSI generic (sg) node and the higher level SCSI device name; or vice versa. For example '/dev/sg0' may "map" to '/dev/sda'. Mappings may not exist, if a relevant module is not loaded, for example. Also there are SCSI devices that can only be accessed via a sg node (e.g. SAF-TE and some SES devices).

In this utility, "matching" refers to different representations of the same device accessed via the same driver. For example, '/dev/hdc' and '/sys/block/hdc' usually refer to the same device and thus would be considered matching. A related example is that '/dev/cdrom' and '/dev/hdc' are also considered matching if '/dev/cdrom' is a symlink to '/dev/hdc'.

Note that this utility requires root permissions to access the storage device nodes in the /dev directory. The lsscsi utility may be used instead in many cases, and lsscsi does not require root permission as it "data-mines" the sysfs pseudo file system for the information it needs.

For notes on bsg and nvme device nodes see the section on BSG and NVME DEVICES below.

## OPTIONS
Arguments to long options are mandatory for short options as well.

-d, --dev_dir=DIR

where DIR is the directory to search for resultant device special files in (or symlinks to same). Only active when '--result=0' (the default) or '--result=2'. If this option is not given and DEVICE is a device special file then the directory part of DEVICE is assumed. If this option is not given and DEVICE is a sysfs name, then if necessary '/dev' is assumed as the directory.

-g, --given_is=0 | 1

specifies the DEVICE is either a device special file (when the argument is 0), or a sysfs 'dev' file (when the argument is 1). The parent directory of a sysfs 'dev' file is also accepted (e.g. either '/sys/block/sda/dev' or '/sys/block/sda' are accepted). Usually there is no need to give this option since this utility first checks for special files (or symlinks to special files) and if not, assumes it has been given a sysfs 'dev' file (or its parent). Generates an error if given and disagrees with variety of DEVICE.

-h, --help

output the usage message then exit.

-r, --result=0 | 1 | 2 | 3

specifies what variety of file (or files) that this utility tries to find. The default is a "mapped" device special file, when the argument is 0. When the argument is 1, this utility tries to find the "mapped" sysfs node name. When the argument is 2, this utility tries to find the "matching" device special file. When the argument is 3, this utility tries to find the "matching" sysfs node name.

-s, --symlink

when a device special file is being sought (i.e. when '--result=0' (the default) or '--result=2') then also look for symlinks to that device special file in the same directory.

-v, --verbose

increase the level of verbosity, (i.e. debug output).

-V, --version

print the version string and then exit.

## BSG and NVME DEVICES
The bsg driver (Block Scsi Generic) presents alternate Unix character devices of the form: /dev/bsg/<h:c:t:l>. <h:c:t:l> is a 4 element tuple where 'h' is the host number, 'c' is the controller number, 't' is the target identifier and 'l' is the LUN (Logical Unit Number). Other than the bsg device names, each device, once open()-ed, operates in a similar fashion to a sg device: a generic interface at the SCSI command level.

If a bsg device is given to this utility, it will first try to map it to a SCSI block device. This will either be of the form /dev/sd<letter_s> for a disk or /dev/sr<number> for a BD/DVD or CD drive. If no match is found, then a check is made for a SCSI tape drive with a name of the form /dev/st<number>. If that fails, the mapping to the corresponding sg device is made. If the --result=2 option is given, the block device and tape davice checks are bypassed and the mapping to the corresponding sg device is made.

Note that this utility makes no mapping to a bsg device. That is pretty easy to establish using the lsscsi utility as the 4 element <h:c:t:l> tuple is shown at the beginning of each line (by default) and it uniquely identifies each SCSI device. Each line will also show the primary device name and, if the --generic option is given, the sg device node.

Currently NVMe device nodes come in several varieties, block devices of the form: /dev/nvme<c>n<n>[p<pn>] where <c> is the controller number (starting at 0), <n> is the namespace identifier (starting at 1), and <pn> is the partition number (starting at 1). There are two forms of NVMe character device nodes: one of the form /dev/nvme<c> and the other of the form /dev/ng<c>n<n> where "ng" is newer and termed as 'nvme-generic' in the /proc/devices output. This utility identifies but does not map NVMe devices. Their naming is more consistent so a utility like this is less needed. Udev might be used to remap the kernel's naming scheme for NVMe, removing its inherent naming consistency.

## NOTES
This utility is designed for the Linux 2.6 (and later) kernel series. It uses special file major and minor numbers (and whether the special is block or character) together with sysfs to do its mapping or matching. In the absence of any other information, device special files are assumed to be in the '/dev' directory while sysfs is assumed to be mounted at '/sys'. Device names in sysfs are predictable, given the corresponding major and minor number of the device. However, due to udev rules, the name of device special files can be anything the user desires (e.g. '/dev/sda' could be named '/dev/my_boot_disk'). When trying to find a resultant device special file, this utility uses the major and minor numbers (and whether a block or char device is sought) to search the device directory.

This utility only shows one relationship at a time. To get an overview of all SCSI devices, with special file names and optionally the "mapped" sg device name, see the lsscsi utility.

Even though lsscsi is a functional replacement for this utility, it has been reported that this utility runs faster in systems that have a lot of disks connected. Theoretically a Linux system may have up to 16383 SCSI disks connected to it.

## EXAMPLES
Assume sg2 maps to sdb while dvd, cdrom and hdc are all matching.

\# sg_map26 /dev/sg2

/dev/sdb

\# sg_map26 /dev/sdb

/dev/sg2

\# sg_map26 --result=0 /dev/sdb

/dev/sg2

\# sg_map26 --result=3 /dev/sdb

/sys/block/sda

\# sg_map26 --result=1 /dev/sdb

/sys/class/scsi_generic/sg0

Now look at '/dev/hdc' and friends

\# sg_map26 /dev/hdc

<error: a hd device does not map to a sg device>

\# sg_map26 --result=3 /dev/hdc

/sys/block/hdc

\# sg_map26 --result=2 /dev/hdc

/dev/hdc

\# sg_map26 --result=2 --symlink /dev/hdc

/dev/cdrom

/dev/dvd

/dev/hdc

\# sg_map26 --result=2 --symlink /sys/block/hdc

/dev/cdrom

/dev/dvd

/dev/hdc

## EXIT STATUS
The exit status of sg_map26 is 0 when it is successful. Otherwise see the sg3_utils(8) man page.

## AUTHORS
Written by Douglas Gilbert.

## REPORTING BUGS
Report bugs to <dgilbert at interlog dot com>.

## COPYRIGHT
Copyright © 2005-2023 Douglas Gilbert

This software is distributed under a BSD-2-Clause license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

## SEE ALSO
udev(7), lsscsi(lsscsi)