{
    "content": [
        {
            "type": "text",
            "text": "# sg_readcap (man)\n\n## NAME\n\nsgreadcap - send SCSI READ CAPACITY command\n\n## SYNOPSIS\n\nsgreadcap  [--16]  [--brief]  [--help] [--hex] [--lba=LBA] [--long] [--pmi] [--raw] [--read‐\nonly] [--verbose] [--version] [--zbc] DEVICE\nsgreadcap [-16] [-b] [-h] [-H] [-lba=LBA] [-pmi] [-r] [-R] [-v] [-V] [-z] DEVICE\n\n## DESCRIPTION\n\nThe normal action of the SCSI READ CAPACITY command is to fetch the  number  of  blocks  (and\nblock size) from the DEVICE.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **OPTIONS** (11 subsections)\n- **NOTES**\n- **EXIT STATUS**\n- **OLDER COMMAND LINE OPTIONS** (12 subsections)\n- **ENVIRONMENT VARIABLES**\n- **AUTHORS**\n- **COPYRIGHT**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "sg_readcap",
        "section": "",
        "mode": "man",
        "summary": "sgreadcap - send SCSI READ CAPACITY command",
        "synopsis": "sgreadcap  [--16]  [--brief]  [--help] [--hex] [--lba=LBA] [--long] [--pmi] [--raw] [--read‐\nonly] [--verbose] [--version] [--zbc] DEVICE\nsgreadcap [-16] [-b] [-h] [-H] [-lba=LBA] [-pmi] [-r] [-R] [-v] [-V] [-z] DEVICE",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [
            {
                "flag": "-h",
                "long": "--help",
                "arg": null,
                "description": "print out the usage message then exit."
            },
            {
                "flag": "-H",
                "long": "--hex",
                "arg": null,
                "description": "output the response to the READ CAPACITY command (either the 10 or 16 byte cdb vari‐ ant) in ASCII hexadecimal on stdout."
            },
            {
                "flag": "-L",
                "long": "--lba",
                "arg": null,
                "description": "used in conjunction with --pmi option. This variant of READ CAPACITY will yield the last block address after LBA prior to a delay. For a disk, given a LBA it yields the highest numbered block on the same cylinder (i.e. before the heads need to move). LBA is assumed to be decimal unless prefixed by \"0x\" or it has a trailing \"h\". Defaults to 0. This option was made obsolete in SBC-3 revision 26."
            },
            {
                "flag": "-l",
                "long": "--long",
                "arg": null,
                "description": "Use the 16 byte cdb variant of the READ CAPACITY command. The default action is to use the 10 byte cdb variant which limits the maximum block address to (232 - 2). When a 10 byte cdb READ CAPACITY command is used on a device whose size is too large then a last block address of 0xffffffff is returned (if the device complies with SBC-2 or later)."
            },
            {
                "flag": "-O",
                "long": "--old",
                "arg": null,
                "description": "Switch to older style options. Please use as first option."
            },
            {
                "flag": "-p",
                "long": "--pmi",
                "arg": null,
                "description": "partial medium indicator: for finding the next block address prior to some delay (e.g. head movement). In the absence of this option, the total number of blocks and the block size of the device are output. Used in conjunction with the --lba=LBA option. This option was made obsolete in SBC-3 revision 26."
            },
            {
                "flag": "-r",
                "long": "--raw",
                "arg": null,
                "description": "output response in binary to stdout."
            },
            {
                "flag": "-R",
                "long": "--readonly",
                "arg": null,
                "description": "open the DEVICE read-only (e.g. in Unix with the ORDONLY flag). The default for READ CAPACITY(16) is to open it read-write. The default for READ CAPACITY(10) is to open it read-only so this option does not change anything for this case."
            },
            {
                "flag": "-v",
                "long": "--verbose",
                "arg": null,
                "description": "increase level of verbosity. Can be used multiple times."
            },
            {
                "flag": "-V",
                "long": "--version",
                "arg": null,
                "description": "outputs version string then exits."
            },
            {
                "flag": "-z",
                "long": "--zbc",
                "arg": null,
                "description": "additionally prints out the extra ZBC field (RCBASIS) in the READ CAPACITY response. Using the option implicitly sets the --16 option."
            }
        ],
        "examples": [],
        "see_also": [
            {
                "name": "sginq",
                "section": "sg3utils",
                "url": "https://www.chedong.com/phpMan.php/man/sginq/sg3utils/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 28,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 9,
                "subsections": [
                    {
                        "name": "-h --help",
                        "lines": 2,
                        "flag": "-h",
                        "long": "--help"
                    },
                    {
                        "name": "-H --hex",
                        "lines": 3,
                        "flag": "-H",
                        "long": "--hex"
                    },
                    {
                        "name": "-L --lba",
                        "lines": 6,
                        "flag": "-L",
                        "long": "--lba"
                    },
                    {
                        "name": "-l --long",
                        "lines": 6,
                        "flag": "-l",
                        "long": "--long"
                    },
                    {
                        "name": "-O --old",
                        "lines": 2,
                        "flag": "-O",
                        "long": "--old"
                    },
                    {
                        "name": "-p --pmi",
                        "lines": 5,
                        "flag": "-p",
                        "long": "--pmi"
                    },
                    {
                        "name": "-r --raw",
                        "lines": 2,
                        "flag": "-r",
                        "long": "--raw"
                    },
                    {
                        "name": "-R --readonly",
                        "lines": 4,
                        "flag": "-R",
                        "long": "--readonly"
                    },
                    {
                        "name": "-v --verbose",
                        "lines": 2,
                        "flag": "-v",
                        "long": "--verbose"
                    },
                    {
                        "name": "-V --version",
                        "lines": 2,
                        "flag": "-V",
                        "long": "--version"
                    },
                    {
                        "name": "-z --zbc",
                        "lines": 3,
                        "flag": "-z",
                        "long": "--zbc"
                    }
                ]
            },
            {
                "name": "NOTES",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "EXIT STATUS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "OLDER COMMAND LINE OPTIONS",
                "lines": 5,
                "subsections": [
                    {
                        "name": "-16",
                        "lines": 2
                    },
                    {
                        "name": "-b",
                        "lines": 5,
                        "flag": "-b"
                    },
                    {
                        "name": "-h",
                        "lines": 2,
                        "flag": "-h"
                    },
                    {
                        "name": "-H",
                        "lines": 2,
                        "flag": "-H"
                    },
                    {
                        "name": "-lba",
                        "lines": 4
                    },
                    {
                        "name": "-N --new",
                        "lines": 2,
                        "flag": "-N",
                        "long": "--new"
                    },
                    {
                        "name": "-pmi",
                        "lines": 3
                    },
                    {
                        "name": "-r",
                        "lines": 1,
                        "flag": "-r"
                    },
                    {
                        "name": "-R",
                        "lines": 1,
                        "flag": "-R"
                    },
                    {
                        "name": "-v",
                        "lines": 2,
                        "flag": "-v"
                    },
                    {
                        "name": "-V",
                        "lines": 1,
                        "flag": "-V"
                    },
                    {
                        "name": "-R",
                        "lines": 1,
                        "flag": "-R"
                    }
                ]
            },
            {
                "name": "ENVIRONMENT VARIABLES",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "sgreadcap - send SCSI READ CAPACITY command\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "sgreadcap  [--16]  [--brief]  [--help] [--hex] [--lba=LBA] [--long] [--pmi] [--raw] [--read‐\nonly] [--verbose] [--version] [--zbc] DEVICE\n\nsgreadcap [-16] [-b] [-h] [-H] [-lba=LBA] [-pmi] [-r] [-R] [-v] [-V] [-z] DEVICE\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The normal action of the SCSI READ CAPACITY command is to fetch the  number  of  blocks  (and\nblock size) from the DEVICE.\n\nThe SCSI READ CAPACITY command (both 10 and 16 byte cdbs) actually yield the block address of\nthe last block and the block size. The number of blocks is thus one plus the block address of\nthe last block (as blocks are counted origin zero (i.e. starting at block zero)). This is the\nsource of many \"off by one\" errors.\n\nThe READ CAPACITY(16) response provides additional information not found in the  READ  CAPAC‐\nITY(10)  response.  This includes protection and logical block provisioning information, plus\nthe number of logical blocks per physical block. So even though the media size may not exceed\nwhat  READ  CAPACITY(10) can show, it may still be useful to examine the response to READ CA‐\nPACITY(16). Sadly there are horrible SCSI command set implementations in the wild that  crash\nwhen the READ CAPACITY(16) command is sent to them.\n\nDevice  capacity is the product of the number of blocks by the block size.  This utility out‐\nputs this figure in bytes, MiB (1048576 bytes per MiB), GB (1000000000 bytes per GB) and,  if\nlarge enough, TB (1000 GB).\n\nIf sgreadcap is called without the --long option then the 10 byte cdb version (i.e. READ CA‐\nPACITY (10)) is sent to the DEVICE. If the number of blocks in the response  is  reported  as\n0xffffffff  (i.e.  (232  - 1) ) and the --hex option has not been given, then READ CAPACITY\n(16) is called and its response is output.\n\nThis utility supports two command line syntaxes, the preferred one is shown first in the syn‐\nopsis  and explained in this section. A later section on the old command line syntax outlines\nthe second group of options.\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\n--16   Use  the  16  byte  cdb variant of the READ CAPACITY command. See the '--long' option.\n-b, --brief outputs two hex numbers (prefixed with '0x' and space separated)  to  std‐\nout. The first number is the maximum number of blocks on the device (which is one plus\nthe lba of the last accessible block). The second number is the size in bytes of  each\nblock. If the operation fails then \"0x0 0x0\" is written to stdout.\n",
                "subsections": [
                    {
                        "name": "-h --help",
                        "content": "print out the usage message then exit.\n",
                        "flag": "-h",
                        "long": "--help"
                    },
                    {
                        "name": "-H --hex",
                        "content": "output  the  response to the READ CAPACITY command (either the 10 or 16 byte cdb vari‐\nant) in ASCII hexadecimal on stdout.\n",
                        "flag": "-H",
                        "long": "--hex"
                    },
                    {
                        "name": "-L --lba",
                        "content": "used in conjunction with --pmi option. This variant of READ CAPACITY  will  yield  the\nlast  block  address after LBA prior to a delay. For a disk, given a LBA it yields the\nhighest numbered block on the same cylinder (i.e. before the heads need to move).  LBA\nis assumed to be decimal unless prefixed by \"0x\" or it has a trailing \"h\". Defaults to\n0.  This option was made obsolete in SBC-3 revision 26.\n",
                        "flag": "-L",
                        "long": "--lba"
                    },
                    {
                        "name": "-l --long",
                        "content": "Use the 16 byte cdb variant of the READ CAPACITY command. The default action is to use\nthe  10 byte cdb variant which limits the maximum block address to (232 - 2). When a\n10 byte cdb READ CAPACITY command is used on a device whose size is too large  then  a\nlast  block  address  of  0xffffffff is returned (if the device complies with SBC-2 or\nlater).\n",
                        "flag": "-l",
                        "long": "--long"
                    },
                    {
                        "name": "-O --old",
                        "content": "Switch to older style options. Please use as first option.\n",
                        "flag": "-O",
                        "long": "--old"
                    },
                    {
                        "name": "-p --pmi",
                        "content": "partial medium indicator: for finding the next block address prior to some delay (e.g.\nhead  movement).  In  the  absence  of this option, the total number of blocks and the\nblock size of the device are output.  Used in conjunction with the  --lba=LBA  option.\nThis option was made obsolete in SBC-3 revision 26.\n",
                        "flag": "-p",
                        "long": "--pmi"
                    },
                    {
                        "name": "-r --raw",
                        "content": "output response in binary to stdout.\n",
                        "flag": "-r",
                        "long": "--raw"
                    },
                    {
                        "name": "-R --readonly",
                        "content": "open the DEVICE read-only (e.g. in Unix with the ORDONLY flag).  The default for READ\nCAPACITY(16) is to open it read-write. The default for READ CAPACITY(10) is to open it\nread-only so this option does not change anything for this case.\n",
                        "flag": "-R",
                        "long": "--readonly"
                    },
                    {
                        "name": "-v --verbose",
                        "content": "increase level of verbosity. Can be used multiple times.\n",
                        "flag": "-v",
                        "long": "--verbose"
                    },
                    {
                        "name": "-V --version",
                        "content": "outputs version string then exits.\n",
                        "flag": "-V",
                        "long": "--version"
                    },
                    {
                        "name": "-z --zbc",
                        "content": "additionally  prints out the extra ZBC field (RCBASIS) in the READ CAPACITY response.\nUsing the option implicitly sets the --16 option.\n",
                        "flag": "-z",
                        "long": "--zbc"
                    }
                ]
            },
            "NOTES": {
                "content": "The response to READ CAPACITY(16) contains a LBPRZ bit in the  SBC-3  standard  (ANSI  INCITS\n514-2014). There was also a LBPRZ bit with the same meaning in the Logical block provisioning\nVPD page (0xb2). Then somewhat confusingly T10 expanded the LBPRZ bit to a  3  bit  field  in\nSBC-4  draft  revision 7, but only in the LB provisioning VPD page. The reason for the expan‐\nsion was to report a new \"provisioning initialization pattern\" state (when an unmapped  logi‐\ncal  block  is  read). The new state has been assigned LBPRZ=2 in the VPD page and it re-uses\nLBPRZ=0 in the READ CAPACITY(16) response. LBPRZ=1 retains the same meaning  for  both  vari‐\nants, namely that a block of zeroes will be returned when an unmapped logical block is read.\n",
                "subsections": []
            },
            "EXIT STATUS": {
                "content": "The  exit status of sgreadcap 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": "-16",
                        "content": "main description.\n"
                    },
                    {
                        "name": "-b",
                        "content": "The  first number is the maximum number of blocks on the device (which is one plus the\nlba of the last accessible block). The second number is the size of each block. If the\noperation  fails  then  \"0x0  0x0\" is written to stdout.  Equivalent to --brief in the\nmain description.\n",
                        "flag": "-b"
                    },
                    {
                        "name": "-h",
                        "content": "sage then exits.\n",
                        "flag": "-h"
                    },
                    {
                        "name": "-H",
                        "content": "ant) in ASCII hexadecimal on stdout.\n",
                        "flag": "-H"
                    },
                    {
                        "name": "-lba",
                        "content": "used in conjunction with -pmi option. This variant of READ  CAPACITY  will  yield  the\nlast  block  address  after LBA prior to a delay.  Equivalent to --lba=LBA in the main\ndescription.\n"
                    },
                    {
                        "name": "-N --new",
                        "content": "Switch to the newer style options.\n",
                        "flag": "-N",
                        "long": "--new"
                    },
                    {
                        "name": "-pmi",
                        "content": "head  movement).  In  the  absence  of this switch, the total number of blocks and the\nblock size of the device are output.  Equivalent to --pmi in the main description.\n"
                    },
                    {
                        "name": "-r",
                        "content": "",
                        "flag": "-r"
                    },
                    {
                        "name": "-R",
                        "content": "",
                        "flag": "-R"
                    },
                    {
                        "name": "-v",
                        "content": "also accepted yielding greater verbosity.\n",
                        "flag": "-v"
                    },
                    {
                        "name": "-V",
                        "content": "",
                        "flag": "-V"
                    },
                    {
                        "name": "-R",
                        "content": "",
                        "flag": "-R"
                    }
                ]
            },
            "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": []
            },
            "AUTHORS": {
                "content": "Written by Douglas Gilbert\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright © 1999-2020 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": "sginq(sg3utils)\n\n\n\nsg3utils-1.45                              January 2020                               SGREADCAP(8)",
                "subsections": []
            }
        }
    }
}