{
    "content": [
        {
            "type": "text",
            "text": "# sg_raw(8) (man)\n\n## TLDR\n\n> Send arbitrary SCSI command to a connected device.\n\n- Send a command to an optical SCSI device assigned to `sr0` to load the media in its tray:\n  `sg_raw /dev/sr0 EA 00 00 00 00 01`\n- Read data from `IFILE` instead of `stdin`:\n  `sg_raw {{-i|--infile}} {{path/to/IFILE}} {{/dev/sgX}} {{scsi_command}}`\n- Skip the first `LEN` bytes of input data:\n  `sg_raw {{-k|--skip}} {{LEN}} {{/dev/sgX}} {{scsi_command}}`\n- Read `SLEN` bytes of data and send to the device:\n  `sg_raw {{-s|--send}} {{SLEN}} {{/dev/sgX}} {{scsi_command}}`\n- Wait up to `SEC` seconds for `sg_raw` to finish processing:\n  `sg_raw {{-t|--timeout}} {{SEC}} {{/dev/sgX}} {{scsi_command}}`\n- Increase verbosity level by 1:\n  `sg_raw {{-v|--verbose}} {{/dev/sgX}} {{scsi_command}}`\n- Dump returned data in binary form:\n  `sg_raw {{-b|--binary}} {{/dev/sgX}} {{scsi_command}}`\n- Write data received from the specified device to an `OFILE`:\n  `sg_raw {{-o|--outfile}} {{path/to/OFILE}} {{/dev/sgX}} {{scsi_command}}`\n\n*Source: tldr-pages*\n\n---\n\n**Summary:** sgraw - send arbitrary SCSI or NVMe command to a device\n\n**Synopsis:** sgraw   [--binary]  [--cmdfile=CF]  [--cmdset=CS]  [--enumerate]  [--help]  [--infile=IFILE]\n[--nosense] [--nvm] [--outfile=OFILE] [--raw]  [--readonly]  [--request=RLEN]  [--scan=FO,LO]\n[--send=SLEN] [--skip=KLEN] [--timeout=SECS] [--verbose] [--version] DEVICE [CDB0 CDB1 ...]\n\n## Flags\n\n| Flag | Long | Arg | Description |\n|------|------|-----|-------------|\n| -b | --binary | — | Dump data in binary form, even when writing to stdout. |\n| -c | --cmdfile | — | CF is the name of a file which contains the command to be executed. Without this op‐ tion the command must be given on t |\n| -C | --cmdset | — | CS is a number to indicate which command set (i.e. SCSI or NVMe) to use. 0, the de‐ fault, causes a heuristic based on c |\n| -h | --help | — | Display usage information and exit. |\n| -i | --infile | — | Read data from IFILE instead of stdin. This option is ignored if --send is not speci‐ fied. |\n| -n | --nosense | — | Don't display SCSI Sense information. |\n| -N | --nvm | — | When sending NVMe commands, the Admin command set is assumed. To send the NVM command set (e.g. the Read and Write (user |\n| -o | --outfile | — | Write data received from the DEVICE to OFILE. The data is written in binary. By de‐ fault, data is dumped in hex format  |\n| -w | --raw | — | interpret CF (i.e. the command file) as containing binary. The default is to assume that it contains ASCII hexadecimal. |\n| -R | --readonly | — | Open DEVICE read-only. The default (without this option) is to open it read-write. |\n| -r | --request | — | Expect to receive up to RLEN bytes of data from the DEVICE. RLEN may be suffixed with 'k' to use kilobytes (1024 bytes)  |\n| -Q | --scan | — | Scan a range of opcodes (i.e. first byte of each command). The first opcode in the scan is FO (which is decimal unless i |\n| -s | --send | — | Read SLEN bytes of data, either from stdin or from a file, and send them to the DE‐ VICE. In the SCSI transport, SLEN be |\n| -k | --skip | — | Skip the first KLEN bytes of the input file or stream. This option is ignored if --send is not specified. If --send is g |\n| -t | --timeout | — | Wait up to SECS seconds for command completion (default: 20). Note that if a command times out the operating system may  |\n| -v | --verbose | — | Increase level of verbosity. Can be used multiple times. |\n| -V | --version | — | Display version and license information and exit. |\n\n## Examples\n\n- `These examples, apart from the last one, use Linux device names. For suitable device names in`\n- `other supported Operating Systems see the sg3utils(8) man page.`\n- `sgraw /dev/scd0 1b 00 00 00 02 00`\n- `Eject the medium in CD drive /dev/scd0.`\n- `sgraw -r 1k /dev/sg0 12 00 00 00 60 00`\n- `Perform  an  INQUIRY on /dev/sg0 and dump the response data (up to 1024 bytes) to std‐`\n- `out.`\n- `sgraw -s 512 -i i512.bin /dev/sda 3b 02 00 00 00 00 00 02 00 00`\n- `Showing an example of writing 512 bytes to a sector on a disk is a  little  dangerous.`\n- `Instead  this  example  will  read i512.bin (assumed to be 512 bytes long) and use the`\n- `SCSI WRITE BUFFER command to send it to the \"data\" buffer (that is mode 2). This is  a`\n- `safe operation.`\n- `sgraw -r 512 -o o512.bin /dev/sda 3c 02 00 00 00 00 00 02 00 00`\n- `This  will  use  the SCSI READ BUFFER command to read 512 bytes from the \"data\" buffer`\n- `(i.e. mode 2) then write it to the o512.bin file.  When used in conjunction  with  the`\n- `previous  example,  if  both  commands work then 'cmp i512.bin o512.bin' should show a`\n- `match.`\n- `sgraw --infile=urandom.bin --send=512 --request=512 --outfile=out.bin \"/dev/bsg/7:0:0:0\"  53`\n- `00 00 00 00 00 00 00 01 00`\n- `This  is  a  bidirectional  XDWRITEREAD(10) command being sent via a Linux bsg device.`\n- `Note that data is being read from \"urandom.bin\" and  sent  to  the  device  (data-out)`\n- `while  resulting  data (data-in) is placed in the \"out.bin\" file. Also note the length`\n- `of both is 512 bytes which corresponds to the transfer length of 1 (block) in the  cdb`\n- `(i.e.  the second last byte). urandom.bin can be produced like this:`\n- `dd if=/dev/urandom bs=512 count=1 of=urandom.bin`\n- `sgraw.exe PhysicalDrive1 a1 0c 0e 00 00 00 00 00 00 e0 00 00`\n- `This  example  is from Windows and shows a ATA STANDBY IMMEDIATE command being sent to`\n- `PhysicalDrive1. That ATA command is contained within  the  SCSI  ATA  PASS-THROUGH(12)`\n- `command (see the SAT or SAT-2 standard at http://www.t10.org). Notice that the STANDBY`\n- `IMMEDIATE command does not send or receive any additional data, however  if  it  fails`\n- `sense data should be returned and displayed.`\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **SYNOPSIS** (4 lines)\n- **DESCRIPTION** (19 lines)\n- **OPTIONS** (3 lines) — 17 subsections\n  - -b --binary (2 lines)\n  - -c --cmdfile (3 lines)\n  - -C --cmdset (5 lines)\n  - -h --help (2 lines)\n  - -i --infile (3 lines)\n  - -n --nosense (2 lines)\n  - -N --nvm (3 lines)\n  - -o --outfile (4 lines)\n  - -w --raw (3 lines)\n  - -R --readonly (2 lines)\n  - -r --request (11 lines)\n  - -Q --scan (9 lines)\n  - -s --send (8 lines)\n  - -k --skip (4 lines)\n  - -t --timeout (4 lines)\n  - -v --verbose (2 lines)\n  - -V --version (2 lines)\n- **NOTES** (19 lines)\n- **NVME SUPPORT** (38 lines)\n- **EXAMPLES** (38 lines)\n- **EXIT STATUS** (3 lines)\n- **AUTHOR** (2 lines)\n- **REPORTING BUGS** (2 lines)\n- **COPYRIGHT** (4 lines)\n- **SEE ALSO** (5 lines)\n\n## Full Content\n\n### NAME\n\nsgraw - send arbitrary SCSI or NVMe command to a device\n\n### SYNOPSIS\n\nsgraw   [--binary]  [--cmdfile=CF]  [--cmdset=CS]  [--enumerate]  [--help]  [--infile=IFILE]\n[--nosense] [--nvm] [--outfile=OFILE] [--raw]  [--readonly]  [--request=RLEN]  [--scan=FO,LO]\n[--send=SLEN] [--skip=KLEN] [--timeout=SECS] [--verbose] [--version] DEVICE [CDB0 CDB1 ...]\n\n### DESCRIPTION\n\nThis  utility  sends an arbitrary SCSI command (between 6 and 256 bytes) to the DEVICE. There\nmay be no associated data transfer; or data may be read from a file and sent to  the  DEVICE;\nor data may be received from the DEVICE and then displayed or written to a file. If supported\nby the pass through, bidirectional commands may be sent (i.e. containing both data to be sent\nto the DEVICE and received from the DEVICE).\n\nThe SCSI command may be between 6 and 256 bytes long. Each command byte is specified in plain\nhex format (00..FF) without a prefix or suffix. The command can be given either on  the  com‐\nmand line or via the --cmdfile=CF option. See EXAMPLES section below.\n\nThe commands pass through a generic SCSI interface which is implemented for several operating\nsystems including Linux, FreeBSD and Windows.\n\nExperimental support has been added to send NVMe Admin and NVM commands to the DEVICE.  Since\nall  NVMe  commands  are  64  bytes long it is more convenient to use the --cmdfile=CF option\nrather than type the 64 bytes of the NVMe command on the command line.  See  the  section  on\nNVME  below.  A  heuristic  based on command length is used to decide if the given command is\nSCSI or NVMe, to override this heuristic use the --cmdset=CS option.\n\n### OPTIONS\n\nArguments to long options are mandatory for short options as well.  The options are  arranged\nin alphabetical order based on the long option name.\n\n#### -b --binary\n\nDump data in binary form, even when writing to stdout.\n\n#### -c --cmdfile\n\nCF  is the name of a file which contains the command to be executed.  Without this op‐\ntion the command must be given on the command line, after the options and the DEVICE.\n\n#### -C --cmdset\n\nCS is a number to indicate which command set (i.e. SCSI or NVMe) to use.  0,  the  de‐\nfault,  causes  a heuristic based on command length to be used. Use a CS of 1 to over‐\nride that heuristic and choose the SCSI command set. Use a CS of 2  to  override  that\nheuristic and choose the NVMe command set.\n\n#### -h --help\n\nDisplay usage information and exit.\n\n#### -i --infile\n\nRead  data from IFILE instead of stdin. This option is ignored if --send is not speci‐\nfied.\n\n#### -n --nosense\n\nDon't display SCSI Sense information.\n\n#### -N --nvm\n\nWhen sending NVMe commands, the Admin command set is assumed. To send the NVM  command\nset (e.g. the Read and Write (user data) commands) this option needs to be given.\n\n#### -o --outfile\n\nWrite  data  received  from the DEVICE to OFILE. The data is written in binary. By de‐\nfault, data is dumped in hex format to stdout.  If OFILE is '-' then data is dumped in\nbinary to stdout.  This option is ignored if --request is not specified.\n\n#### -w --raw\n\ninterpret  CF  (i.e.  the command file) as containing binary. The default is to assume\nthat it contains ASCII hexadecimal.\n\n#### -R --readonly\n\nOpen DEVICE read-only. The default (without this option) is to open it read-write.\n\n#### -r --request\n\nExpect to receive up to RLEN bytes of data from the DEVICE.  RLEN may be suffixed with\n'k'  to  use  kilobytes (1024 bytes) instead of bytes. RLEN is decimal unless it has a\nleading '0x' or a trailing 'h'.\nIf RLEN is too small (i.e. either smaller than indicated by  the  cdb  (typically  the\n\"allocation length\" field) and/or smaller than the DEVICE tries to send back) then the\nHBA driver may complain. Making RLEN larger than required should  cause  no  problems.\nMost  SCSI \"data-in\" commands return a data block that contains (in its early bytes) a\nlength that the DEVICE would \"like\" to send back if the \"allocation length\"  field  in\nthe  cdb is large enough. In practice, the DEVICE will return no more bytes than indi‐\ncated in the \"allocation length\" field of the cdb.\n\n#### -Q --scan\n\nScan a range of opcodes (i.e. first byte of each command). The  first  opcode  in  the\nscan  is FO (which is decimal unless it has a '0x' prefix or 'h' suffix). The last op‐\ncode in the scan is LO. The maximum value of LO is 255. The  remaining  bytes  of  the\nSCSI/NVMe command are as supplied at invocation.\nWarning:  this  option can be dangerous.  Sending somewhat arbitrary commands to a de‐\nvice can have unexpected results.  It is recommended that this option is used with the\n--cmdset=CS option where CS is 1 or 2 in order to stop the command set possibly chang‐\ning during the scan.\n\n#### -s --send\n\nRead SLEN bytes of data, either from stdin or from a file, and send them  to  the  DE‐\nVICE. In the SCSI transport, SLEN becomes the length (in bytes) of the \"data-out\" buf‐\nfer. SLEN is decimal unless it has a leading '0x' or a trailing 'h'.\nIt is the responsibility of the user to make sure that the \"data-out\"  length  implied\nor  stated  in  the  cdb  matches  SLEN.  Note  that some common SCSI commands such as\nWRITE(10) have a \"transfer length\" field whose units are  logical  blocks  (which  are\nusually 512 or 4096 bytes long).\n\n#### -k --skip\n\nSkip  the  first  KLEN  bytes  of  the input file or stream. This option is ignored if\n--send is not specified. If --send is given and this option is not  given,  then  zero\nbytes are skipped.\n\n#### -t --timeout\n\nWait  up to SECS seconds for command completion (default: 20).  Note that if a command\ntimes out the operating system may start by aborting the command and if that is unsuc‐\ncessful it may attempt to reset the device.\n\n#### -v --verbose\n\nIncrease level of verbosity. Can be used multiple times.\n\n#### -V --version\n\nDisplay version and license information and exit.\n\n### NOTES\n\nThe  sginq  utility  can be used to send an INQUIRY command to a device to determine its pe‐\nripheral device type (e.g. '1' for a streaming device (tape drive))  which  determines  which\nSCSI  command  sets  a device should support (e.g. SPC and SSC). The sgvpd utility reads and\ndecodes a device's Vital Product Pages which may contain useful information.\n\nThe ability to send more than a 16 byte CDB (in some cases 12 byte CDB) may be restricted  by\nthe pass-through interface, the low level driver or the transport. In the Linux series 3 ker‐\nnels, the bsg driver can handle longer CDBs, block devices (e.g. /dev/sdc) accessed  via  the\nSGIO ioctl cannot handle CDBs longer than 16 bytes, and the sg driver can handle longer CDBs\nfrom lk 3.17 .\n\nThe CDB command name defined by T10 for the given CDB is shown if the '-vv' option is  given.\nThe  command  line  syntax still needs to be correct, so /dev/null may be used for the DEVICE\nsince the CDB command name decoding is done before the DEVICE is checked.\n\nThe intention of the --scan=FO,LO option is to slightly simplify the process of finding  hid‐\nden  or  undocumented  commands. It should be used with care; for example checking for vendor\nspecific SCSI commands: 'sgraw --cmdset=1 --scan=0xc0,0xff /dev/sg1 0 0 0 0 0 0'.\n\n### NVME SUPPORT\n\nSupport for NVMe (a.k.a. NVM Express) is currently experimental. NVMe concepts map reasonably\nwell  to  the SCSI architecture. A SCSI logical unit (LU) is similar to a NVMe namespace (al‐\nthough LUN 0 is very common in SCSI while namespace IDs start at 1). A SCSI target device  is\nsimilar to a NVMe controller. SCSI commands vary from 6 to 260 bytes long (although SCSI com‐\nmand descriptor blocks (cdbs) longer than 32 bytes are uncommon) while all NVMe commands are\ncurrently 64 bytes long. The SCSI architecture makes a clear distinction between an initiator\n(often called a HBA) and a target (device) while (at least on the PCIe  transport)  the  NVMe\ncontroller  plays  both  roles.   This utility defaults to assuming the user provided 64 byte\ncommand belongs to NVMe's Admin command set. To issue commands from the  \"NVM\"  command  set,\nthe --nvm option must be given. Admin and NVM commands are sent to submission queue 0.\n\nOne  significant  difference  is that SCSI uses a big endian representation for integers that\nare longer than 8 bits (i.e. longer than 1 byte) while NVMe uses a little endian  representa‐\ntion (like most things that have originated from the Intel organisation). NVMe specifications\ntalk about Words (16 bits), Double Words (32 bits) and sometimes Quad Words (64 bits) and has\ntighter alignment requirements than SCSI.\n\nOne  difference  that impacts this utility is that NVMe places pointers to host memory in its\ncommands while SCSI leaves this detail to whichever transport it is using (e.g.  SAS,  iSCSI,\nSRP).  Since this utility takes the command from the user (either on the command line or in a\nfile named CF) but this utility allocates a data-in or data-out buffer as required, the  user\ndoes not know in advance what the address of that buffer will be. Some special addresses have\nbeen introduced to help with this problem: the address 0xfffffffffffffffe is  interpreted  as\n\"use  the  data-in  buffer's  address\"  while  0xfffffffffffffffd  is interpreted as \"use the\ndata-out buffer's address\". Since NVMe uses little endian notation then  that  first  address\nappears  in  the NVMe command byte stream as \"fe\" followed by seven \"ff\"s. A similar arrange‐\nment is made for the length of that buffer (in bytes), but since that is a 32 byte  quantity,\nthe first 4 bytes (all \"ff\"s) are removed.\n\nSeveral command file examples can be found in the examples directory of this package's source\ntarball:     nvmeidentifyctl.hex,     nvmedevselftest.hex,     nvmereadctl.hex     and\nnvmewritectl.hex .\n\nBeware:  the NVMe standard often refers to some of its fields as \"0's based\".  They are typi‐\ncally counts of something like the number of blocks to be read.  For  example  in  NVMe  Read\ncommand,  a \"0's based\" number of blocks field containing the value 3 means to read 4 blocks!\nNo, this is not a joke.\n\n### EXAMPLES\n\nThese examples, apart from the last one, use Linux device names. For suitable device names in\nother supported Operating Systems see the sg3utils(8) man page.\n\nsgraw /dev/scd0 1b 00 00 00 02 00\nEject the medium in CD drive /dev/scd0.\n\nsgraw -r 1k /dev/sg0 12 00 00 00 60 00\nPerform  an  INQUIRY on /dev/sg0 and dump the response data (up to 1024 bytes) to std‐\nout.\n\nsgraw -s 512 -i i512.bin /dev/sda 3b 02 00 00 00 00 00 02 00 00\nShowing an example of writing 512 bytes to a sector on a disk is a  little  dangerous.\nInstead  this  example  will  read i512.bin (assumed to be 512 bytes long) and use the\nSCSI WRITE BUFFER command to send it to the \"data\" buffer (that is mode 2). This is  a\nsafe operation.\n\nsgraw -r 512 -o o512.bin /dev/sda 3c 02 00 00 00 00 00 02 00 00\nThis  will  use  the SCSI READ BUFFER command to read 512 bytes from the \"data\" buffer\n(i.e. mode 2) then write it to the o512.bin file.  When used in conjunction  with  the\nprevious  example,  if  both  commands work then 'cmp i512.bin o512.bin' should show a\nmatch.\n\nsgraw --infile=urandom.bin --send=512 --request=512 --outfile=out.bin \"/dev/bsg/7:0:0:0\"  53\n00 00 00 00 00 00 00 01 00\nThis  is  a  bidirectional  XDWRITEREAD(10) command being sent via a Linux bsg device.\nNote that data is being read from \"urandom.bin\" and  sent  to  the  device  (data-out)\nwhile  resulting  data (data-in) is placed in the \"out.bin\" file. Also note the length\nof both is 512 bytes which corresponds to the transfer length of 1 (block) in the  cdb\n(i.e.  the second last byte). urandom.bin can be produced like this:\ndd if=/dev/urandom bs=512 count=1 of=urandom.bin\n\nsgraw.exe PhysicalDrive1 a1 0c 0e 00 00 00 00 00 00 e0 00 00\nThis  example  is from Windows and shows a ATA STANDBY IMMEDIATE command being sent to\nPhysicalDrive1. That ATA command is contained within  the  SCSI  ATA  PASS-THROUGH(12)\ncommand (see the SAT or SAT-2 standard at http://www.t10.org). Notice that the STANDBY\nIMMEDIATE command does not send or receive any additional data, however  if  it  fails\nsense data should be returned and displayed.\n\n### EXIT STATUS\n\nThe  exit  status  of  sgraw  is 0 when it is successful. Otherwise see the sg3utils(8) man\npage.\n\n### AUTHOR\n\nWritten by Ingo van Lil\n\n### REPORTING BUGS\n\nReport bugs to <inguin at gmx dot de> or to <dgilbert at interlog dot com>.\n\n### COPYRIGHT\n\nCopyright © 2001-2021 Ingo van Lil\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\n### SEE ALSO\n\nsginq, sgvpd, sg3utils (sg3utils), plscsi\n\n\n\nsg3utils-1.46                              January 2021                                   SGRAW(8)\n\n"
        }
    ],
    "structuredContent": {
        "command": "sg_raw",
        "section": "8",
        "mode": "man",
        "summary": "sgraw - send arbitrary SCSI or NVMe command to a device",
        "synopsis": "sgraw   [--binary]  [--cmdfile=CF]  [--cmdset=CS]  [--enumerate]  [--help]  [--infile=IFILE]\n[--nosense] [--nvm] [--outfile=OFILE] [--raw]  [--readonly]  [--request=RLEN]  [--scan=FO,LO]\n[--send=SLEN] [--skip=KLEN] [--timeout=SECS] [--verbose] [--version] DEVICE [CDB0 CDB1 ...]",
        "tldr_summary": "Send arbitrary SCSI command to a connected device.",
        "tldr_examples": [
            {
                "description": "Send a command to an optical SCSI device assigned to `sr0` to load the media in its tray",
                "command": "sg_raw /dev/sr0 EA 00 00 00 00 01"
            },
            {
                "description": "Read data from `IFILE` instead of `stdin`",
                "command": "sg_raw {{-i|--infile}} {{path/to/IFILE}} {{/dev/sgX}} {{scsi_command}}"
            },
            {
                "description": "Skip the first `LEN` bytes of input data",
                "command": "sg_raw {{-k|--skip}} {{LEN}} {{/dev/sgX}} {{scsi_command}}"
            },
            {
                "description": "Read `SLEN` bytes of data and send to the device",
                "command": "sg_raw {{-s|--send}} {{SLEN}} {{/dev/sgX}} {{scsi_command}}"
            },
            {
                "description": "Wait up to `SEC` seconds for `sg_raw` to finish processing",
                "command": "sg_raw {{-t|--timeout}} {{SEC}} {{/dev/sgX}} {{scsi_command}}"
            },
            {
                "description": "Increase verbosity level by 1",
                "command": "sg_raw {{-v|--verbose}} {{/dev/sgX}} {{scsi_command}}"
            },
            {
                "description": "Dump returned data in binary form",
                "command": "sg_raw {{-b|--binary}} {{/dev/sgX}} {{scsi_command}}"
            },
            {
                "description": "Write data received from the specified device to an `OFILE`",
                "command": "sg_raw {{-o|--outfile}} {{path/to/OFILE}} {{/dev/sgX}} {{scsi_command}}"
            }
        ],
        "tldr_source": "official",
        "flags": [
            {
                "flag": "-b",
                "long": "--binary",
                "arg": null,
                "description": "Dump data in binary form, even when writing to stdout."
            },
            {
                "flag": "-c",
                "long": "--cmdfile",
                "arg": null,
                "description": "CF is the name of a file which contains the command to be executed. Without this op‐ tion the command must be given on the command line, after the options and the DEVICE."
            },
            {
                "flag": "-C",
                "long": "--cmdset",
                "arg": null,
                "description": "CS is a number to indicate which command set (i.e. SCSI or NVMe) to use. 0, the de‐ fault, causes a heuristic based on command length to be used. Use a CS of 1 to over‐ ride that heuristic and choose the SCSI command set. Use a CS of 2 to override that heuristic and choose the NVMe command set."
            },
            {
                "flag": "-h",
                "long": "--help",
                "arg": null,
                "description": "Display usage information and exit."
            },
            {
                "flag": "-i",
                "long": "--infile",
                "arg": null,
                "description": "Read data from IFILE instead of stdin. This option is ignored if --send is not speci‐ fied."
            },
            {
                "flag": "-n",
                "long": "--nosense",
                "arg": null,
                "description": "Don't display SCSI Sense information."
            },
            {
                "flag": "-N",
                "long": "--nvm",
                "arg": null,
                "description": "When sending NVMe commands, the Admin command set is assumed. To send the NVM command set (e.g. the Read and Write (user data) commands) this option needs to be given."
            },
            {
                "flag": "-o",
                "long": "--outfile",
                "arg": null,
                "description": "Write data received from the DEVICE to OFILE. The data is written in binary. By de‐ fault, data is dumped in hex format to stdout. If OFILE is '-' then data is dumped in binary to stdout. This option is ignored if --request is not specified."
            },
            {
                "flag": "-w",
                "long": "--raw",
                "arg": null,
                "description": "interpret CF (i.e. the command file) as containing binary. The default is to assume that it contains ASCII hexadecimal."
            },
            {
                "flag": "-R",
                "long": "--readonly",
                "arg": null,
                "description": "Open DEVICE read-only. The default (without this option) is to open it read-write."
            },
            {
                "flag": "-r",
                "long": "--request",
                "arg": null,
                "description": "Expect to receive up to RLEN bytes of data from the DEVICE. RLEN may be suffixed with 'k' to use kilobytes (1024 bytes) instead of bytes. RLEN is decimal unless it has a leading '0x' or a trailing 'h'. If RLEN is too small (i.e. either smaller than indicated by the cdb (typically the \"allocation length\" field) and/or smaller than the DEVICE tries to send back) then the HBA driver may complain. Making RLEN larger than required should cause no problems. Most SCSI \"data-in\" commands return a data block that contains (in its early bytes) a length that the DEVICE would \"like\" to send back if the \"allocation length\" field in the cdb is large enough. In practice, the DEVICE will return no more bytes than indi‐ cated in the \"allocation length\" field of the cdb."
            },
            {
                "flag": "-Q",
                "long": "--scan",
                "arg": null,
                "description": "Scan a range of opcodes (i.e. first byte of each command). The first opcode in the scan is FO (which is decimal unless it has a '0x' prefix or 'h' suffix). The last op‐ code in the scan is LO. The maximum value of LO is 255. The remaining bytes of the SCSI/NVMe command are as supplied at invocation. Warning: this option can be dangerous. Sending somewhat arbitrary commands to a de‐ vice can have unexpected results. It is recommended that this option is used with the --cmdset=CS option where CS is 1 or 2 in order to stop the command set possibly chang‐ ing during the scan."
            },
            {
                "flag": "-s",
                "long": "--send",
                "arg": null,
                "description": "Read SLEN bytes of data, either from stdin or from a file, and send them to the DE‐ VICE. In the SCSI transport, SLEN becomes the length (in bytes) of the \"data-out\" buf‐ fer. SLEN is decimal unless it has a leading '0x' or a trailing 'h'. It is the responsibility of the user to make sure that the \"data-out\" length implied or stated in the cdb matches SLEN. Note that some common SCSI commands such as WRITE(10) have a \"transfer length\" field whose units are logical blocks (which are usually 512 or 4096 bytes long)."
            },
            {
                "flag": "-k",
                "long": "--skip",
                "arg": null,
                "description": "Skip the first KLEN bytes of the input file or stream. This option is ignored if --send is not specified. If --send is given and this option is not given, then zero bytes are skipped."
            },
            {
                "flag": "-t",
                "long": "--timeout",
                "arg": null,
                "description": "Wait up to SECS seconds for command completion (default: 20). Note that if a command times out the operating system may start by aborting the command and if that is unsuc‐ cessful it may attempt to reset the device."
            },
            {
                "flag": "-v",
                "long": "--verbose",
                "arg": null,
                "description": "Increase level of verbosity. Can be used multiple times."
            },
            {
                "flag": "-V",
                "long": "--version",
                "arg": null,
                "description": "Display version and license information and exit."
            }
        ],
        "examples": [
            "These examples, apart from the last one, use Linux device names. For suitable device names in",
            "other supported Operating Systems see the sg3utils(8) man page.",
            "sgraw /dev/scd0 1b 00 00 00 02 00",
            "Eject the medium in CD drive /dev/scd0.",
            "sgraw -r 1k /dev/sg0 12 00 00 00 60 00",
            "Perform  an  INQUIRY on /dev/sg0 and dump the response data (up to 1024 bytes) to std‐",
            "out.",
            "sgraw -s 512 -i i512.bin /dev/sda 3b 02 00 00 00 00 00 02 00 00",
            "Showing an example of writing 512 bytes to a sector on a disk is a  little  dangerous.",
            "Instead  this  example  will  read i512.bin (assumed to be 512 bytes long) and use the",
            "SCSI WRITE BUFFER command to send it to the \"data\" buffer (that is mode 2). This is  a",
            "safe operation.",
            "sgraw -r 512 -o o512.bin /dev/sda 3c 02 00 00 00 00 00 02 00 00",
            "This  will  use  the SCSI READ BUFFER command to read 512 bytes from the \"data\" buffer",
            "(i.e. mode 2) then write it to the o512.bin file.  When used in conjunction  with  the",
            "previous  example,  if  both  commands work then 'cmp i512.bin o512.bin' should show a",
            "match.",
            "sgraw --infile=urandom.bin --send=512 --request=512 --outfile=out.bin \"/dev/bsg/7:0:0:0\"  53",
            "00 00 00 00 00 00 00 01 00",
            "This  is  a  bidirectional  XDWRITEREAD(10) command being sent via a Linux bsg device.",
            "Note that data is being read from \"urandom.bin\" and  sent  to  the  device  (data-out)",
            "while  resulting  data (data-in) is placed in the \"out.bin\" file. Also note the length",
            "of both is 512 bytes which corresponds to the transfer length of 1 (block) in the  cdb",
            "(i.e.  the second last byte). urandom.bin can be produced like this:",
            "dd if=/dev/urandom bs=512 count=1 of=urandom.bin",
            "sgraw.exe PhysicalDrive1 a1 0c 0e 00 00 00 00 00 00 e0 00 00",
            "This  example  is from Windows and shows a ATA STANDBY IMMEDIATE command being sent to",
            "PhysicalDrive1. That ATA command is contained within  the  SCSI  ATA  PASS-THROUGH(12)",
            "command (see the SAT or SAT-2 standard at http://www.t10.org). Notice that the STANDBY",
            "IMMEDIATE command does not send or receive any additional data, however  if  it  fails",
            "sense data should be returned and displayed."
        ],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 19,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 3,
                "subsections": [
                    {
                        "name": "-b --binary",
                        "lines": 2,
                        "flag": "-b",
                        "long": "--binary"
                    },
                    {
                        "name": "-c --cmdfile",
                        "lines": 3,
                        "flag": "-c",
                        "long": "--cmdfile"
                    },
                    {
                        "name": "-C --cmdset",
                        "lines": 5,
                        "flag": "-C",
                        "long": "--cmdset"
                    },
                    {
                        "name": "-h --help",
                        "lines": 2,
                        "flag": "-h",
                        "long": "--help"
                    },
                    {
                        "name": "-i --infile",
                        "lines": 3,
                        "flag": "-i",
                        "long": "--infile"
                    },
                    {
                        "name": "-n --nosense",
                        "lines": 2,
                        "flag": "-n",
                        "long": "--nosense"
                    },
                    {
                        "name": "-N --nvm",
                        "lines": 3,
                        "flag": "-N",
                        "long": "--nvm"
                    },
                    {
                        "name": "-o --outfile",
                        "lines": 4,
                        "flag": "-o",
                        "long": "--outfile"
                    },
                    {
                        "name": "-w --raw",
                        "lines": 3,
                        "flag": "-w",
                        "long": "--raw"
                    },
                    {
                        "name": "-R --readonly",
                        "lines": 2,
                        "flag": "-R",
                        "long": "--readonly"
                    },
                    {
                        "name": "-r --request",
                        "lines": 11,
                        "flag": "-r",
                        "long": "--request"
                    },
                    {
                        "name": "-Q --scan",
                        "lines": 9,
                        "flag": "-Q",
                        "long": "--scan"
                    },
                    {
                        "name": "-s --send",
                        "lines": 8,
                        "flag": "-s",
                        "long": "--send"
                    },
                    {
                        "name": "-k --skip",
                        "lines": 4,
                        "flag": "-k",
                        "long": "--skip"
                    },
                    {
                        "name": "-t --timeout",
                        "lines": 4,
                        "flag": "-t",
                        "long": "--timeout"
                    },
                    {
                        "name": "-v --verbose",
                        "lines": 2,
                        "flag": "-v",
                        "long": "--verbose"
                    },
                    {
                        "name": "-V --version",
                        "lines": 2,
                        "flag": "-V",
                        "long": "--version"
                    }
                ]
            },
            {
                "name": "NOTES",
                "lines": 19,
                "subsections": []
            },
            {
                "name": "NVME SUPPORT",
                "lines": 38,
                "subsections": []
            },
            {
                "name": "EXAMPLES",
                "lines": 38,
                "subsections": []
            },
            {
                "name": "EXIT STATUS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "REPORTING BUGS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 5,
                "subsections": []
            }
        ]
    }
}