{
    "mode": "man",
    "parameter": "sg_rbuf",
    "section": "8",
    "url": "https://www.chedong.com/phpMan.php/man/sg_rbuf/8/json",
    "generated": "2026-10-04T14:11:14Z",
    "synopsis": "sgrbuf  [--buffer=EACH]  [--dio]  [--help]  [--mmap]  [--quick] [--size=OVERALL] [--verbose]\n[--version] DEVICE\nsgrbuf [-b=EACHKIB] [-d] [-m] [-q] [-s=OVERALLMIB] [-t] [-v] [-V] DEVICE",
    "sections": {
        "NAME": {
            "content": "sgrbuf - reads data using SCSI READ BUFFER command\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "sgrbuf  [--buffer=EACH]  [--dio]  [--help]  [--mmap]  [--quick] [--size=OVERALL] [--verbose]\n[--version] DEVICE\n\nsgrbuf [-b=EACHKIB] [-d] [-m] [-q] [-s=OVERALLMIB] [-t] [-v] [-V] DEVICE\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This command reads data with the SCSI READ BUFFER command and then discards it. Typically the\ndata being read is from a disk's memory cache. It is assumed that the data is sourced quickly\n(although this is not guaranteed by the SCSI standards) so that it  is  faster  than  reading\ndata  from  the  media.   This  command  is designed for timing transfer speeds across a SCSI\ntransport.\n\nTo fetch the data with  a  SCSI  READ  BUFFER  command  and  optionally  decode  it  see  the\nsgreadbuffer  utility.  There  is  also  a  sgwritebuffer  utility useful for downloading\nfirmware amongst other things.\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\nThis  is  a  Linux only utility and only works when DEVICE is an sg device (e.g. \"/dev/sg1\").\nThe sgreadbuffer utility has similar functionality and is ported to other OSes  and  within\nLinux can use bsg and normal block device names (e.g. \"/dev/sdc\").\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "Arguments to long options are mandatory for short options as well.\n",
            "subsections": [
                {
                    "name": "-b --buffer",
                    "content": "where  EACH  is the number of bytes to be transferred by each READ BUFFER command. The\ndefault is the actual available buffer size returned by the READ  BUFFER  (descriptor)\ncommand.  The maximum is the same as the default, hence this argument can only be used\nto reduce the size of each transfer to less than the device's actual available  buffer\nsize.\n",
                    "flag": "-b",
                    "long": "--buffer"
                },
                {
                    "name": "-d --dio",
                    "content": "use direct IO if available. This option is only available if the DEVICE is a sg driver\ndevice  node (e.g. /dev/sg1). In this case the sg driver will attempt to configure the\nDMA from the SCSI adapter to transfer directly into user memory. This  will  eliminate\nthe  copy via kernel buffers. If not available then this will be reported and indirect\nIO will be done instead.\n",
                    "flag": "-d",
                    "long": "--dio"
                },
                {
                    "name": "-h --help",
                    "content": "print usage message then exit.\n",
                    "flag": "-h",
                    "long": "--help"
                },
                {
                    "name": "-m --mmap",
                    "content": "use memory mapped IO if available. This option is only available if the DEVICE is a sg\ndriver device node (e.g. /dev/sg1). In this case the sg driver will attempt to config‐\nure the DMA from the SCSI adapter to transfer directly into  user  memory.  This  will\neliminate the copy via kernel buffers.\n",
                    "flag": "-m",
                    "long": "--mmap"
                },
                {
                    "name": "-O --old",
                    "content": "Switch to older style options. Please use as first option.\n",
                    "flag": "-O",
                    "long": "--old"
                },
                {
                    "name": "-q --quick",
                    "content": "only  transfer  the  data  into kernel buffers (typically by DMA from the SCSI adapter\ncard) and do not move it into the user space. This option is only available if the DE‐\nVICE is a sg driver device node (e.g. /dev/sg1).\n",
                    "flag": "-q",
                    "long": "--quick"
                },
                {
                    "name": "-s --size",
                    "content": "where OVERALL is the size  of  total  transfer  in  bytes.  The  default  is  200  MiB\n(200*1024*1024  bytes).  The  actual  number of bytes transferred may be slightly less\nthan requested since all transfers are the same size (and an integer division  is  in‐\nvolved rounding towards zero).\n",
                    "flag": "-s",
                    "long": "--size"
                },
                {
                    "name": "-t --time",
                    "content": "times  the  bulk  data transfer component of this command. The elapsed time is printed\nout plus a MB/sec calculation. In this case \"MB\" is 1,000,000  bytes.  The  gettimeof‐\nday() system call is used internally for the time calculation.\n",
                    "flag": "-t",
                    "long": "--time"
                },
                {
                    "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"
                }
            ]
        },
        "NOTES": {
            "content": "This  command  is  typically  used on modern SCSI disks which have a RAM cache in their drive\nelectronics. If no IO to the magnetic media, or slower devices like flash  RAM,  is  involved\nthen  the  disk  may be able to source data fast enough to saturate the bandwidth of the SCSI\ntransport. The bottleneck may then be the DMA element in the HBA, the Linux  drivers  or  the\nhost machine's hardware (e.g. speed of RAM).\n\nVarious  numeric  arguments (e.g. OVERALL) may include multiplicative suffixes or be given in\nhexadecimal. See the \"NUMERIC ARGUMENTS\" section in the sg3utils(8) man page.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "On the test system /dev/sg0 corresponds to a fast disk on a U2W SCSI bus (max 80 MB/sec). The\ndisk specifications state that its cache is 4 MB.\n$ time ./sgrbuf /dev/sg0\nREAD BUFFER reports: buffer capacity=3434944,\noffset boundary=6\nRead 200 MiB (actual 199 MiB, 209531584 bytes),\nbuffer size=3354 KiB\nreal 0m5.072s, user 0m0.000s, sys 0m2.280s\n\nSo that is approximately 40 MB/sec at 40 % utilization. Now with the addition of the \"-q\" op‐\ntion this throughput improves and the utilization drops to 0%.\n$ time ./sgrbuf -q /dev/sg0\nREAD BUFFER reports: buffer capacity=3434944,\noffset boundary=6\nRead 200 MiB (actual 199 MiB, 209531584 bytes),\nbuffer size=3354 KiB\nreal 0m2.784s, user 0m0.000s, sys 0m0.000s\n",
            "subsections": []
        },
        "EXIT STATUS": {
            "content": "The exit status of sgrbuf 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": "-b",
                    "content": "where  EACHKIB is the number of Kilobytes (i.e. 1024 byte units) to be transferred by\neach READ BUFFER command. Similar to the --buffer=EACH option in the main  description\nbut the units are different.\n",
                    "flag": "-b"
                },
                {
                    "name": "-d",
                    "content": "",
                    "flag": "-d"
                },
                {
                    "name": "-m",
                    "content": "scription.\n",
                    "flag": "-m"
                },
                {
                    "name": "-N --new",
                    "content": "Switch to the newer style options.\n",
                    "flag": "-N",
                    "long": "--new"
                },
                {
                    "name": "-q",
                    "content": "card) and do not move it into the user space.  Equivalent to the --quick option in the\nmain description.\n",
                    "flag": "-q"
                },
                {
                    "name": "-s",
                    "content": "where  OVERALLMIB is the size of total transfer in Megabytes (1048576 bytes). Similar\nto the --size=OVERALL option in the main description but the units are different.\n",
                    "flag": "-s"
                },
                {
                    "name": "-t",
                    "content": "tion in the main description.\n",
                    "flag": "-t"
                },
                {
                    "name": "-v",
                    "content": "",
                    "flag": "-v"
                },
                {
                    "name": "-V",
                    "content": "",
                    "flag": "-V"
                }
            ]
        },
        "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 © 2000-2017 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": "",
            "subsections": [
                {
                    "name": "sg_read_buffer, sg_write_buffer, sg_test_rwbuf(all in sg3_utils)",
                    "content": "sg3utils-1.43                              October 2017                                  SGRBUF(8)"
                }
            ]
        }
    },
    "summary": "sgrbuf - reads data using SCSI READ BUFFER command",
    "flags": [
        {
            "flag": "-b",
            "long": "--buffer",
            "arg": null,
            "description": "where EACH is the number of bytes to be transferred by each READ BUFFER command. The default is the actual available buffer size returned by the READ BUFFER (descriptor) command. The maximum is the same as the default, hence this argument can only be used to reduce the size of each transfer to less than the device's actual available buffer size."
        },
        {
            "flag": "-d",
            "long": "--dio",
            "arg": null,
            "description": "use direct IO if available. This option is only available if the DEVICE is a sg driver device node (e.g. /dev/sg1). In this case the sg driver will attempt to configure the DMA from the SCSI adapter to transfer directly into user memory. This will eliminate the copy via kernel buffers. If not available then this will be reported and indirect IO will be done instead."
        },
        {
            "flag": "-h",
            "long": "--help",
            "arg": null,
            "description": "print usage message then exit."
        },
        {
            "flag": "-m",
            "long": "--mmap",
            "arg": null,
            "description": "use memory mapped IO if available. This option is only available if the DEVICE is a sg driver device node (e.g. /dev/sg1). In this case the sg driver will attempt to config‐ ure the DMA from the SCSI adapter to transfer directly into user memory. This will eliminate the copy via kernel buffers."
        },
        {
            "flag": "-O",
            "long": "--old",
            "arg": null,
            "description": "Switch to older style options. Please use as first option."
        },
        {
            "flag": "-q",
            "long": "--quick",
            "arg": null,
            "description": "only transfer the data into kernel buffers (typically by DMA from the SCSI adapter card) and do not move it into the user space. This option is only available if the DE‐ VICE is a sg driver device node (e.g. /dev/sg1)."
        },
        {
            "flag": "-s",
            "long": "--size",
            "arg": null,
            "description": "where OVERALL is the size of total transfer in bytes. The default is 200 MiB (200*1024*1024 bytes). The actual number of bytes transferred may be slightly less than requested since all transfers are the same size (and an integer division is in‐ volved rounding towards zero)."
        },
        {
            "flag": "-t",
            "long": "--time",
            "arg": null,
            "description": "times the bulk data transfer component of this command. The elapsed time is printed out plus a MB/sec calculation. In this case \"MB\" is 1,000,000 bytes. The gettimeof‐ day() system call is used internally for the time calculation."
        },
        {
            "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."
        }
    ],
    "examples": [
        "On the test system /dev/sg0 corresponds to a fast disk on a U2W SCSI bus (max 80 MB/sec). The",
        "disk specifications state that its cache is 4 MB.",
        "$ time ./sgrbuf /dev/sg0",
        "READ BUFFER reports: buffer capacity=3434944,",
        "offset boundary=6",
        "Read 200 MiB (actual 199 MiB, 209531584 bytes),",
        "buffer size=3354 KiB",
        "real 0m5.072s, user 0m0.000s, sys 0m2.280s",
        "So that is approximately 40 MB/sec at 40 % utilization. Now with the addition of the \"-q\" op‐",
        "tion this throughput improves and the utilization drops to 0%.",
        "$ time ./sgrbuf -q /dev/sg0",
        "READ BUFFER reports: buffer capacity=3434944,",
        "offset boundary=6",
        "Read 200 MiB (actual 199 MiB, 209531584 bytes),",
        "buffer size=3354 KiB",
        "real 0m2.784s, user 0m0.000s, sys 0m0.000s"
    ],
    "see_also": []
}