{
    "mode": "man",
    "parameter": "SG_INQ",
    "section": "8",
    "url": "https://www.chedong.com/phpMan.php/man/SG_INQ/8/json",
    "generated": "2026-05-30T08:16:50Z",
    "synopsis": "sginq  [--ata]  [--block=0|1]  [--cmddt]  [--descriptors]  [--export] [--extended] [--force]\n[--help]  [--hex]  [--id]  [--inhex=FN]   [--len=LEN]    [--long]   [--maxlen=LEN]   [--only]\n[--page=PG] [--raw] [--vendor] [--verbose] [--version] [--vpd] DEVICE\nsginq  [-36]  [-a]  [-A]  [-b]  [--B=0|1]  [-c]  [-cl] [-d] [-e] [-f] [-h] [-H] [-i] [-I=FN]\n[-l=LEN] [-L] [-m] [-M] [-o] [-p=VPDPG] [-P] [-r] [-s] [-u] [-v] [-V] [-x] [-36] [-?] DEVICE",
    "sections": {
        "NAME": {
            "content": "sginq - issue SCSI INQUIRY command and/or decode its response\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "sginq  [--ata]  [--block=0|1]  [--cmddt]  [--descriptors]  [--export] [--extended] [--force]\n[--help]  [--hex]  [--id]  [--inhex=FN]   [--len=LEN]    [--long]   [--maxlen=LEN]   [--only]\n[--page=PG] [--raw] [--vendor] [--verbose] [--version] [--vpd] DEVICE\n\nsginq  [-36]  [-a]  [-A]  [-b]  [--B=0|1]  [-c]  [-cl] [-d] [-e] [-f] [-h] [-H] [-i] [-I=FN]\n[-l=LEN] [-L] [-m] [-M] [-o] [-p=VPDPG] [-P] [-r] [-s] [-u] [-v] [-V] [-x] [-36] [-?] DEVICE\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This utility, when DEVICE is given, sends a SCSI INQUIRY command to it then outputs  the  re‐\nsponse. All SCSI devices are meant to respond to a \"standard\" INQUIRY command with at least a\n36 byte response (in SCSI 2 and higher). An INQUIRY is termed as  \"standard\"  when  both  the\nEVPD and CmdDt (now obsolete) bits are clear.\n\nAlternatively  the  --inhex=FN  option  can be given. In this case FN is assumed to be a file\nname ('-' for stdin) containing ASCII hexadecimal representing an INQUIRY response.\n\nThis utility supports two command line syntaxes. The preferred one is shown first in the syn‐\nopsis and is described in the main OPTIONS section. A later section titled OLDER COMMAND LINE\nOPTIONS describes the second group of options.\n\nAn important \"non-standard\" INQUIRY page is the  Device  Identification  Vital  Product  Data\n(VPD)  page  [0x83]. Since SPC-3, support for this page is mandatory. The --id option decodes\nthis page. New VPD page information is no longer being added to this utility. To get informa‐\ntion on new VPD pages see the sgvpd(8) or sdparm(8) utilities.\n\nIn  Linux,  if  the DEVICE exists and the SCSI INQUIRY fails (e.g. because the SGIO ioctl is\nnot supported) then an ATA IDENTIFY (PACKET) DEVICE is tried.  If  it  succeeds  then  device\nidentification  strings are output. The --raw and --hex options can be used to manipulate the\noutput.  If the --ata option is given then the SCSI INQUIRY is not performed and  the  DEVICE\nis assumed to be ATA (or ATAPI). For more information see the ATA DEVICES section below.\n\nIn  some  operating systems a NVMe device (e.g. SSD) may be given as the DEVICE. For more in‐\nformation see the NVME DEVICES section below.\n\nThe reference document used for interpreting an INQUIRY is T10/BSR  INCITS  502  Revision  19\nwhich  is draft SPC-5 revision 19, 14 February 2018). It can be found at http://www.t10.org .\nObsolete and reserved items in the standard INQUIRY response output are displayed  in  square\nbrackets.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "Arguments  to long options are mandatory for short options as well.  The options are arranged\nin alphabetical order based on the long option name.\n",
            "subsections": [
                {
                    "name": "-a --ata",
                    "content": "Assume given DEVICE is an ATA or ATAPI device which can receive ATA commands from  the\nhost  operating  system. Skip the SCSI INQUIRY command and use either the ATA IDENTIFY\nDEVICE command (for non-packet devices) or the ATA IDENTIFY PACKET DEVICE command.  To\nshow  the  response in hex, add a '--verbose' option. This option is only available in\nLinux.\n",
                    "flag": "-a",
                    "long": "--ata"
                },
                {
                    "name": "-B --block",
                    "content": "this option controls how the file handle to the DEVICE is opened. If this argument  is\n0  then  the  open is non-blocking. If the argument is 1 then the open is blocking. In\nUnix a non-blocking open is indicated by a ONONBLOCK flag while a  blocking  open  is\nindicated by the absence of that flag. The default value depends on the operating sys‐\ntem and the type of DEVICE node. For Linux pass-throughs (i.e. the sg and bsg drivers)\nthe default is 0.\n",
                    "flag": "-B",
                    "long": "--block"
                },
                {
                    "name": "-c --cmddt",
                    "content": "set  the  Command Support Data (CmdDt) bit (defaults to clear(0)). Used in conjunction\nwith the --page=PG option where PG specifies the SCSI command opcode  to  query.  When\nused  twice  (e.g. '-cc') this utility forms a list by looping over all 256 opcodes (0\nto 255 inclusive) only outputting a line for commands that are found. The CmdDt bit is\nnow  obsolete;  it  has been replaced by the REPORT SUPPORTED OPERATION CODES command,\nsee the sgopcodes(8) utility.\n",
                    "flag": "-c",
                    "long": "--cmddt"
                },
                {
                    "name": "-d --descriptors",
                    "content": "decodes and prints the version descriptors found in a standard INQUIRY response. There\nare  up  to 8 of them. Version descriptors indicate which versions of standards and/or\ndrafts the DEVICE complies with. The normal components of a standard INQUIRY are  out‐\nput  (typically  from  the first 36 bytes of the response) followed by the version de‐\nscriptors if any.\n",
                    "flag": "-d",
                    "long": "--descriptors"
                },
                {
                    "name": "-e",
                    "content": "",
                    "flag": "-e"
                },
                {
                    "name": "-f --force",
                    "content": "As a sanity check, the normal action when fetching VPD pages other than page 0x0  (the\n\"Supported  VPD pages\" VPD page), is to first fetch page 0x0 and only if the requested\npage is one of the supported pages, to go ahead and fetch the requested page.\nWhen this option is given, skip checking of VPD page  0x0  before  accessing  the  re‐\nquested  VPD  page.  The prior check of VPD page 0x0 is known to crash certain USB de‐\nvices, so use with care.\n",
                    "flag": "-f",
                    "long": "--force"
                },
                {
                    "name": "-u --export",
                    "content": "prints out information obtained from the device. The output can be modified by select‐\ning a VPD page with PG (from --page=PG). If the device identification VPD page 0x83 is\ngiven it prints out information in the  form:  \"SCSIIDENT<assoc><type>=<ident>\"  to\nstdout.  If  the device serial number VPD page 0x80 is given it prints out information\nin the form: \"SCSISERIAL=<ident>\". Other VPD pages are not supported. If no VPD  page\nis   given   it   prints   out   information   in  the  form:  \"SCSIVENDOR=<vendor>\",\n\"SCSIMODEL=<model>\", and \"SCSIREVISION=<rev>\", taken from the standard inquiry. This\nmay be useful for tools like udev(7) in Linux.\n",
                    "flag": "-u",
                    "long": "--export"
                },
                {
                    "name": "-E -x --extended",
                    "content": "prints the extended INQUIRY VPD page [0x86].\n",
                    "flag": "-x",
                    "long": "--extended"
                },
                {
                    "name": "-h --help",
                    "content": "print out the usage message then exit. When used twice, after the usage message, there\nis a list of available abbreviations than can be given to the --page=PG option.\n",
                    "flag": "-h",
                    "long": "--help"
                },
                {
                    "name": "-H --hex",
                    "content": "rather than decode a standard INQUIRY response, a VPD page or  command  support  data;\nprint out the response in hex and send the output to stdout.  Error messages and warn‐\nings are typically output to stderr. When used twice with the ATA Information VPD page\n[0x89] decodes the start of the response then outputs the ATA IDENTIFY (PACKET) DEVICE\nresponse in hexadecimal bytes (not 16 bit words). When used three times with  the  ATA\nInformation VPD page [0x89] or the --ata option, this utility outputs the ATA IDENTIFY\n(PACKET) DEVICE response in hexadecimal words suitable for input to 'hdparm --Istdin'.\nSee note below.\nTo  generate output suitable for placing in a file that can be used by a later invoca‐\ntion with the --inhex=FN option, use the '-HHHH' option  (e.g.  'sginq  -p  di  -HHHH\n/dev/sg3 > devid.hex').\n",
                    "flag": "-H",
                    "long": "--hex"
                },
                {
                    "name": "-i --id",
                    "content": "prints the device identification VPD page [0x83].\n",
                    "flag": "-i",
                    "long": "--id"
                },
                {
                    "name": "-I --inhex",
                    "content": "FN  is  expected to be a file name (or '-' for stdin) which contains ASCII hexadecimal\nor binary representing an INQUIRY (including VPD page)  response.  This  utility  will\nthen  decode  that  response. It is preferable to also supply the --page=PG option, if\nnot this utility will attempt to guess which VPD page (or standard INQUIRY)  that  the\nresponse  is associated with. The hexadecimal should be arranged as 1 or 2 digits rep‐\nresenting a byte each of which is whitespace or comma separated. Anything from and in‐\ncluding a hash mark to the end of a line is ignored. If the --raw option is also given\nthen FN is treated as binary.\n",
                    "flag": "-I",
                    "long": "--inhex"
                },
                {
                    "name": "-l --len",
                    "content": "the number LEN is the \"allocation length\" field in the INQUIRY cdb.  This is the (max‐\nimum)  length  of  the  response returned by the device. The default value of LEN is 0\nwhich is interpreted as: first request is for 36 bytes and if  necessary  execute  an‐\nother  INQUIRY  if  the  \"additional length\" field in the response indicates that more\nthan 36 bytes is available.\nIf LEN is greater than 0 then only one INQUIRY command is performed.  This means  that\nthe Serial Number (obtained from the Serial Number VPD pgae (0x80)) is not fetched and\ntherefore not printed.  See the NOTES section below about \"36 byte INQUIRYs\".\n",
                    "flag": "-l",
                    "long": "--len"
                },
                {
                    "name": "-L --long",
                    "content": "this option causes more information to be decoded from the Identify command sent to  a\nNVMe DEVICE.\n",
                    "flag": "-L",
                    "long": "--long"
                },
                {
                    "name": "-m --maxlen",
                    "content": "this  option  has the same action as the --len=LEN option above. It has been added for\ncompatibility with the sgvpd, sgmodes and sglogs utilities.\n",
                    "flag": "-m",
                    "long": "--maxlen"
                },
                {
                    "name": "-O --old",
                    "content": "Switch to older style options. Please use as first option on the command line.\n",
                    "flag": "-O",
                    "long": "--old"
                },
                {
                    "name": "-o --only",
                    "content": "Do not attempt to additionally retrieve the serial number VPD page (0x80)  to  enhance\nthe  output of a standard INQUIRY. So with this option given and no others, this util‐\nity will send a standard INQUIRY SCSI command and decode its response. No  other  SCSI\ncommands  will  be sent to the DEVICE.  Without this option an additional SCSI command\nis sent: a (non-standard) SCSI INQUIRY to fetch the Serial Number  VPD  page.  However\nthe  Serial  Number VPD page is not mandatory (while the Device Identification page is\nmandatory but a billion USB keys ignore that) and may cause nuisance error reports.\nFor NVMe devices only the Identify controller is performed, even  if  the  DEVICE  in‐\ncludes   a  namespace  identifier.  For  example  in  FreeBSD  given  a  DEVICE  named\n/dev/nvme0ns1 then an Identify controller is sent to /dev/nvme0 and nothing is sent to\nits \"ns1\" (first namespace).\n",
                    "flag": "-o",
                    "long": "--only"
                },
                {
                    "name": "-p --page",
                    "content": "the PG argument can be either a number of an abbreviation for a VPD page. To enumerate\nthe available abbreviations for VPD pages  use  '-hh'  or  a  bad  abbreviation  (e.g,\n'--page=xxx').  When  the  --cmddt option is given (once) then PG is interpreted as an\nopcode number (so VPD page abbreviations make little sense).\nIf PG is a negative number, then a standard INQUIRY is performed. This can be used  to\noverride some guessing logic associated with the --inhex=FN option.\nIf  PG is not found in the 'Supported VPD pages' VPD page (0x0) then EDOM is returned.\nTo bypass this check use the --force option.\n",
                    "flag": "-p",
                    "long": "--page"
                },
                {
                    "name": "-r --raw",
                    "content": "in the absence of --inhex=FN then the output response is in binary.  The output should\nbe  piped to a file or another utility when this option is used. The binary is sent to\nstdout, and errors are sent to stderr.\nIf used with --inhex=FN then the contents of FN is treated as binary.\n",
                    "flag": "-r",
                    "long": "--raw"
                },
                {
                    "name": "-s --vendor",
                    "content": "output a standard INQUIRY response's vendor specific fields from offset 36  to  55  in\nASCII.  When used twice (i.e. '-ss') also output the vendor specific field from offset\n96 in ASCII. This is only done if the data passes some simple sanity checks.\n",
                    "flag": "-s",
                    "long": "--vendor"
                },
                {
                    "name": "-v --verbose",
                    "content": "increase level of verbosity. Can be used multiple times.\n",
                    "flag": "-v",
                    "long": "--verbose"
                },
                {
                    "name": "-V --version",
                    "content": "print out version string then exit.\n",
                    "flag": "-V",
                    "long": "--version"
                },
                {
                    "name": "-e --vpd",
                    "content": "set the Enable Vital Product Data (EVPD) bit (defaults to clear(0)). Used in  conjunc‐\ntion with the --page=PG option where PG specifies the VPD page number to query. If the\n--page=PG is not given then PG defaults to zero which is the \"Supported VPD pages\" VPD\npage. A more up to date decoding of VPD pages can be found in the sgvpd(8) utility.\n",
                    "flag": "-e",
                    "long": "--vpd"
                }
            ]
        },
        "NOTES": {
            "content": "Some  devices  with  weak SCSI command set implementations lock up when they receive commands\nthey don't understand (and some lock up if they receive response lengths that they don't  ex‐\npect). Such devices need to be treated carefully, use the '--len=36' option. Without this op‐\ntion this utility will issue an initial standard INQUIRY  requesting  36  bytes  of  response\ndata.  If  the device indicates it could have supplied more data then a second INQUIRY is is‐\nsued to fetch the longer response. That second command may lock up faulty devices.\n\nATA or ATAPI devices that use a SCSI to ATA Translation layer (see SAT  at  www.t10.org)  may\nsupport the SCSI ATA INFORMATION VPD page. This returns the IDENTIFY (PACKET) DEVICE response\namongst other things.  The ATA Information VPD page can be fetched with '--page=ai'.\n\nIn the INQUIRY standard response there is a 'MultiP' flag which is set when the device has  2\nor  more  ports.  Some vendors use the preceding vendor specific ('VS') bit to indicate which\nport is being accessed by the INQUIRY command (0 -> relative port 1 (port \"a\"), 1 -> relative\nport 2 (port \"b\")). When the 'MultiP' flag is set, the preceding vendor specific bit is shown\nin parentheses. SPC-3 compliant devices should use the device identification VPD page  (0x83)\nto  show  which  port is being used for access and the SCSI ports VPD page (0x88) to show all\navailable ports on the device.\n\nIn the 2.4 series of Linux kernels the DEVICE must be a SCSI generic (sg) device. In the  2.6\nseries  and later block devices (e.g.  disks and ATAPI DVDs) can also be specified. For exam‐\nple \"sginq /dev/sda\" will work in the 2.6 series kernels. From lk 2.6.6  other  SCSI  \"char\"\ndevice names may be used as well (e.g. \"/dev/st0m\").\n\nThe  number  of  bytes output by --hex and --raw is 36 bytes or the number given to --len=LEN\n(or --maxlen=LEN). That number is reduced if the \"resid\" returned by the HBA  indicates  less\nbytes were sent back from DEVICE.\n\nThe DEVICE is opened with a read-only flag (e.g. in Unix with the ORDONLY flag).\n",
            "subsections": []
        },
        "ATA DEVICES": {
            "content": "There  are two major types of ATA devices: non-packet devices (e.g. ATA disks) and packet de‐\nvices (ATAPI). The majority of ATAPI devices are CD/DVD/BD drives in which the  ATAPI  trans‐\nport  carries  the MMC set (i.e.  a SCSI command set). Further, both types of ATA devices can\nbe connected to a host computer via a \"SCSI\" (or some other) transport. When an ATA  disk  is\ncontrolled  via  a  SCSI  (or  non-ATA) transport then two approaches are commonly used: tun‐\nnelling (e.g. STP in Serial Attached SCSI (SAS)) or by emulating a SCSI device (e.g.  with  a\nSCSI  to ATA translation layer, see SAT at www.t10.org ). Even when the physical transport to\nthe host computer is ATA (especially in the case of SATA) the operating system may choose  to\nput a SAT layer in the driver \"stack\" (e.g. libata in Linux).\n\nThe main identifying command for any SCSI device is an INQUIRY. The corresponding command for\nan ATA non-packet device is IDENTIFY DEVICE while for an ATA packet  device  it  is  IDENTIFY\nPACKET DEVICE.\n\nWhen  this  utility  is  invoked  for  an  ATAPI  device (e.g. a CD/DVD/BD drive with \"sginq\n/dev/hdc\") then a SCSI INQUIRY is sent to the device and if it responds then the response  to\ndecoded and output and this utility exits. To see the response for an ATA IDENTIFY PACKET DE‐\nVICE command add the --ata option (e.g. \"sginq --ata /dev/hdc).\n\nThis utility doesn't decode the response to an ATA IDENTIFY (PACKET) DEVICE  command,  hdparm\ndoes  a good job at that. The '-HHH' option has been added for use with either the '--ata' or\n'--page=ai' option to produce a format acceptable to \"hdparm --Istdin\".  An example:  'sginq\n--ata -HHH /dev/hdc | hdparm --Istdin'. See hdparm.\n",
            "subsections": []
        },
        "NVME DEVICES": {
            "content": "Currently  these  device  are typically SSDs (Solid State Disks) directly connected to a PCIe\nconnector or via a specialized connector such as a M2 connector. Linux and FreeBSD treat NVMe\nstorage  devices as separate from SCSI storage with device names like /dev/nvme0n1 (in Linux)\nand /dev/nvme0ns1 (in FreeBSD). The NVM Express group has a  document  titled  \"NVM  Express:\nSCSI  Translation  Reference\"  which defines a partial \"SCSI to NVMe Translation Layer\" often\nknown by its acronym: SNTL.\n\nOn operating systems where it is supported by this package, this  utility  will  detect  NVMe\nstorage devices directly connected and send an Identify controller NVMe Admin command and de‐\ncode its response. A NVMe controller is architecturally similar to a SCSI target  device.  If\nthe  NVMe  DEVICE indicates a namespace then an Identify namespace NVMe Admin command is sent\nto that namespace and its response is decoded. Namespaces are numbered sequentially  starting\nfrom  1.  Namespaces  are similar to SCSI Logical Units and their identifiers (nsids) can be\nthought of as SCSI LUNs. In the Linux and FreeBSD example device names above the \"n1\" and the\n\"ns1\"  parts  indicate  nsid  1  . If no namespace is given in the DEVICE then all namespaces\nfound in the controller are sent Identify namespace commands and the responses are decoded.\n\nTo get more details in the response use the --long option. To only get the controller's Iden‐\ntify decoded use the --only option.\n\nIt  is  possible that even though the DEVICE presents as a NVMe device, it has a SNTL and ac‐\ncepts SCSI commands. In this case to send a SCSI INQUIRY command (and fetch  its  VPD  pages)\nuse 'sgvpd -p sinq <dev>' (or to get VPD pages: 'sgvpd -p <vpdpage> <dev>').\n",
            "subsections": []
        },
        "EXIT STATUS": {
            "content": "The  exit  status  of  sginq  is 0 when it is successful. Otherwise see the sg3utils(8) man\npage.\n",
            "subsections": []
        },
        "OLDER COMMAND LINE OPTIONS": {
            "content": "The options in this section were the only ones available prior to sg3utils  version  1.23  .\nSince then this utility defaults to the newer command line options which can be overridden by\nusing --old (or -O) as the first option. See the ENVIRONMENT VARIABLES  section  for  another\nway to force the use of these older command line options.\n",
            "subsections": [
                {
                    "name": "-36",
                    "content": "indicates in its response it can supply more data, a second (longer)  INQUIRY  is  not\nperformed.  This  is a paranoid setting.  Equivalent to '--len=36' in the OPTIONS sec‐\ntion.\n"
                },
                {
                    "name": "-a",
                    "content": "section. This page is defined in SAT (see at www.t10.org).\n",
                    "flag": "-a"
                },
                {
                    "name": "-A",
                    "content": "section.\n",
                    "flag": "-A"
                },
                {
                    "name": "-b",
                    "content": "section. This page is defined in SBC-2 (see www.t10.org) and later.\n",
                    "flag": "-b"
                },
                {
                    "name": "-B",
                    "content": "",
                    "flag": "-B"
                },
                {
                    "name": "-c",
                    "content": "with the -p=VPDPG option to specify the SCSI command opcode to query.  Equivalent  to\n--cmddt in the OPTIONS section.\n",
                    "flag": "-c"
                },
                {
                    "name": "-cl",
                    "content": "looping through all 256 opcodes. This option uses the CmdDt bit which is now obsolete.\nSee  the  sgopcodes(8)  utility.  Equivalent to '--cmddt --cmddt' in the OPTIONS sec‐\ntion.\n"
                },
                {
                    "name": "-d",
                    "content": "(e.g.  '-i'  or '-p=80'), then this utility attempts to decode the indicated VPD page.\nOtherwise the version descriptors (if any) are listed following a standard INQUIRY re‐\nsponse.  In  the version descriptors sense, equivalent to --descriptors in the OPTIONS\nsection.\n",
                    "flag": "-d"
                },
                {
                    "name": "-e",
                    "content": "conjunction  with  the -p=VPDPG option to specify the VPD page to fetch. If -p=VPDPG\nis not given then VPD page 0 (list supported VPD pages) is assumed.\n",
                    "flag": "-e"
                },
                {
                    "name": "-f",
                    "content": "",
                    "flag": "-f"
                },
                {
                    "name": "-h",
                    "content": "in the OPTIONS section.\n",
                    "flag": "-h"
                },
                {
                    "name": "-H",
                    "content": "",
                    "flag": "-H"
                },
                {
                    "name": "-i",
                    "content": "section. This page is made up of several \"designation descriptors\".  If  -h  is  given\nthen  each descriptor header is decoded and the identifier itself is output in hex. To\nsee the whole VPD 0x83 page response in hex use '-p=83 -h'.\n",
                    "flag": "-i"
                },
                {
                    "name": "-I",
                    "content": "",
                    "flag": "-I"
                },
                {
                    "name": "-l",
                    "content": "",
                    "flag": "-l"
                },
                {
                    "name": "-L",
                    "content": "",
                    "flag": "-L"
                },
                {
                    "name": "-m",
                    "content": "in the OPTIONS section.\n",
                    "flag": "-m"
                },
                {
                    "name": "-M",
                    "content": "TIONS section.\n",
                    "flag": "-M"
                },
                {
                    "name": "-N --new",
                    "content": "Switch to the newer style options.\n",
                    "flag": "-N",
                    "long": "--new"
                },
                {
                    "name": "-o",
                    "content": "",
                    "flag": "-o"
                },
                {
                    "name": "-p",
                    "content": "used in conjunction with the -e or -c option. If neither given then the -e option  as‐\nsumed.  When the -e option is also given (or assumed) then the argument to this option\nis the VPD page number.  The argument is interpreted as hexadecimal and is expected to\nbe  in  the range 0 to ff inclusive. Only VPD page 0 is decoded and it lists supported\nVPD pages and their names (if known). To decode the  mandatory  device  identification\npage  (0x83) use the -i option. A now obsolete usage is when the -c option is given in\nwhich case the argument to this option is assumed to be a command opcode  number.  Re‐\ncent  SCSI  draft standards have moved this facility to a separate command (see sgop‐\ncodes(8)). Defaults to 0 so if -e is given without this option then VPD page 0 is out‐\nput.\n",
                    "flag": "-p"
                },
                {
                    "name": "-P",
                    "content": "'--page=upr' in the OPTIONS section.\n",
                    "flag": "-P"
                },
                {
                    "name": "-r",
                    "content": "Can be used twice (i.e. '-rr' (and '-HHH' has same effect)) and if used with the -A or\n-a option yields output with the same format as \"cat /proc/ide/hd<x>/identify\" so that\nit can then be piped to \"hdparm --Istdin\".\n",
                    "flag": "-r"
                },
                {
                    "name": "-s",
                    "content": "tion.\n",
                    "flag": "-s"
                },
                {
                    "name": "-u",
                    "content": "",
                    "flag": "-u"
                },
                {
                    "name": "-v",
                    "content": "",
                    "flag": "-v"
                },
                {
                    "name": "-V",
                    "content": "",
                    "flag": "-V"
                },
                {
                    "name": "-x",
                    "content": "OPTIONS section.\n\n-?     output usage message and exit. Ignore all other parameters.\n",
                    "flag": "-x"
                }
            ]
        },
        "EXAMPLES": {
            "content": "The  examples  in  this  page use Linux device names. For suitable device names in other sup‐\nported Operating Systems see the sg3utils(8) man page.\n\nTo view the standard inquiry response use without options:\n\nsginq /dev/sda\n\nSome SCSI devices include version descriptors  indicating  the  various  SCSI  standards  and\ndrafts they support. They can be viewed with:\n\nsginq -d /dev/sda\n\nModern  SCSI  devices include Vital Product Data (VPD)pages which can be viewed with the SCSI\nINQUIRY command. To list the supported VPD pages (but not their contents) try:\n\nsginq -e /dev/sda\n\nSome VPD pages can be read with the sginq utility but a newer utility called sgvpd special‐\nizes  in  showing their contents. The sdparm utility can also be used to show the contents of\nVPD pages.\n\nFurther  examples  of  sginq  together  with  some  typical   output   can   be   found   on\nhttp://sg.danny.cz/sg/sg3utils.html web page.\n",
            "subsections": []
        },
        "ENVIRONMENT VARIABLES": {
            "content": "Since  sg3utils  version 1.23 the environment variable SG3UTILSOLDOPTS can be given. When\nit is present this utility will expect the older command line options.  So  the  presence  of\nthis  environment variable is equivalent to using --old (or -O) as the first command line op‐\ntion.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Written by Douglas Gilbert\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "Report bugs to <dgilbert at interlog dot com>.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright © 2001-2021 Douglas Gilbert\nThis software is distributed under the GPL version 2. There is NO warranty; not even for MER‐\nCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "sgopcodes(8), sgvpd(8), sglogs(8), sgmodes(8), sdparm(8), hdparm(8), sgdiag(scsirastools)\n\n\n\nsg3utils-1.46                               March 2021                                    SGINQ(8)",
            "subsections": []
        }
    },
    "summary": "sginq - issue SCSI INQUIRY command and/or decode its response",
    "flags": [
        {
            "flag": "-a",
            "long": "--ata",
            "arg": null,
            "description": "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."
        },
        {
            "flag": "-B",
            "long": "--block",
            "arg": null,
            "description": "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 ONONBLOCK flag while a blocking open is indicated by the absence of that flag. The default value depends on the operating sys‐ tem and the type of DEVICE node. For Linux pass-throughs (i.e. the sg and bsg drivers) the default is 0."
        },
        {
            "flag": "-c",
            "long": "--cmddt",
            "arg": null,
            "description": "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 sgopcodes(8) utility."
        },
        {
            "flag": "-d",
            "long": "--descriptors",
            "arg": null,
            "description": "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 out‐ put (typically from the first 36 bytes of the response) followed by the version de‐ scriptors if any."
        },
        {
            "flag": "-e",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-f",
            "long": "--force",
            "arg": null,
            "description": "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 re‐ quested VPD page. The prior check of VPD page 0x0 is known to crash certain USB de‐ vices, so use with care."
        },
        {
            "flag": "-u",
            "long": "--export",
            "arg": null,
            "description": "prints out information obtained from the device. The output can be modified by select‐ ing a VPD page with PG (from --page=PG). If the device identification VPD page 0x83 is given it prints out information in the form: \"SCSIIDENT<assoc><type>=<ident>\" to stdout. If the device serial number VPD page 0x80 is given it prints out information in the form: \"SCSISERIAL=<ident>\". Other VPD pages are not supported. If no VPD page is given it prints out information in the form: \"SCSIVENDOR=<vendor>\", \"SCSIMODEL=<model>\", and \"SCSIREVISION=<rev>\", taken from the standard inquiry. This may be useful for tools like udev(7) in Linux."
        },
        {
            "flag": "-x",
            "long": "--extended",
            "arg": null,
            "description": "prints the extended INQUIRY VPD page [0x86]."
        },
        {
            "flag": "-h",
            "long": "--help",
            "arg": null,
            "description": "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."
        },
        {
            "flag": "-H",
            "long": "--hex",
            "arg": null,
            "description": "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 warn‐ ings 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 invoca‐ tion with the --inhex=FN option, use the '-HHHH' option (e.g. 'sginq -p di -HHHH /dev/sg3 > devid.hex')."
        },
        {
            "flag": "-i",
            "long": "--id",
            "arg": null,
            "description": "prints the device identification VPD page [0x83]."
        },
        {
            "flag": "-I",
            "long": "--inhex",
            "arg": null,
            "description": "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 rep‐ resenting a byte each of which is whitespace or comma separated. Anything from and in‐ cluding a hash mark to the end of a line is ignored. If the --raw option is also given then FN is treated as binary."
        },
        {
            "flag": "-l",
            "long": "--len",
            "arg": null,
            "description": "the number LEN is the \"allocation length\" field in the INQUIRY cdb. This is the (max‐ imum) 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 an‐ other 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\"."
        },
        {
            "flag": "-L",
            "long": "--long",
            "arg": null,
            "description": "this option causes more information to be decoded from the Identify command sent to a NVMe DEVICE."
        },
        {
            "flag": "-m",
            "long": "--maxlen",
            "arg": null,
            "description": "this option has the same action as the --len=LEN option above. It has been added for compatibility with the sgvpd, sgmodes and sglogs utilities."
        },
        {
            "flag": "-O",
            "long": "--old",
            "arg": null,
            "description": "Switch to older style options. Please use as first option on the command line."
        },
        {
            "flag": "-o",
            "long": "--only",
            "arg": null,
            "description": "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 util‐ ity 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. For NVMe devices only the Identify controller is performed, even if the DEVICE in‐ cludes 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)."
        },
        {
            "flag": "-p",
            "long": "--page",
            "arg": null,
            "description": "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."
        },
        {
            "flag": "-r",
            "long": "--raw",
            "arg": null,
            "description": "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."
        },
        {
            "flag": "-s",
            "long": "--vendor",
            "arg": null,
            "description": "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."
        },
        {
            "flag": "-v",
            "long": "--verbose",
            "arg": null,
            "description": "increase level of verbosity. Can be used multiple times."
        },
        {
            "flag": "-V",
            "long": "--version",
            "arg": null,
            "description": "print out version string then exit."
        },
        {
            "flag": "-e",
            "long": "--vpd",
            "arg": null,
            "description": "set the Enable Vital Product Data (EVPD) bit (defaults to clear(0)). Used in conjunc‐ tion 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. A more up to date decoding of VPD pages can be found in the sgvpd(8) utility."
        }
    ],
    "examples": [
        "The  examples  in  this  page use Linux device names. For suitable device names in other sup‐",
        "ported Operating Systems see the sg3utils(8) man page.",
        "To view the standard inquiry response use without options:",
        "sginq /dev/sda",
        "Some SCSI devices include version descriptors  indicating  the  various  SCSI  standards  and",
        "drafts they support. They can be viewed with:",
        "sginq -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:",
        "sginq -e /dev/sda",
        "Some VPD pages can be read with the sginq utility but a newer utility called sgvpd special‐",
        "izes  in  showing their contents. The sdparm utility can also be used to show the contents of",
        "VPD pages.",
        "Further  examples  of  sginq  together  with  some  typical   output   can   be   found   on",
        "http://sg.danny.cz/sg/sg3utils.html web page."
    ],
    "see_also": [
        {
            "name": "sgopcodes",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/sgopcodes/8/json"
        },
        {
            "name": "sgvpd",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/sgvpd/8/json"
        },
        {
            "name": "sglogs",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/sglogs/8/json"
        },
        {
            "name": "sgmodes",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/sgmodes/8/json"
        },
        {
            "name": "sdparm",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/sdparm/8/json"
        },
        {
            "name": "hdparm",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/hdparm/8/json"
        },
        {
            "name": "sgdiag",
            "section": "scsirastools",
            "url": "https://www.chedong.com/phpMan.php/man/sgdiag/scsirastools/json"
        }
    ]
}