{
    "mode": "man",
    "parameter": "sgm_dd",
    "section": "8",
    "url": "https://www.chedong.com/phpMan.php/man/sgm_dd/8/json",
    "generated": "2026-10-04T20:39:45Z",
    "synopsis": "sgmdd   [bs=BS]   [count=COUNT]   [ibs=BS]   [if=IFILE]  [iflag=FLAGS]  [obs=BS]  [of=OFILE]\n[oflag=FLAGS] [seek=SEEK] [skip=SKIP] [--help] [--version]\n[bpt=BPT]  [cdbsz=6|10|12|16]  [dio=0|1]  [sync=0|1]  [time=0|1]  [verbose=VERB]  [--dry-run]\n[--verbose]",
    "sections": {
        "NAME": {
            "content": "sgmdd - copy data to and from files and devices, especially SCSI devices\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "sgmdd   [bs=BS]   [count=COUNT]   [ibs=BS]   [if=IFILE]  [iflag=FLAGS]  [obs=BS]  [of=OFILE]\n[oflag=FLAGS] [seek=SEEK] [skip=SKIP] [--help] [--version]\n\n[bpt=BPT]  [cdbsz=6|10|12|16]  [dio=0|1]  [sync=0|1]  [time=0|1]  [verbose=VERB]  [--dry-run]\n[--verbose]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Copy data to and from any files. Specialized for \"files\" that are Linux SCSI generic (sg) de‐\nvices  and raw devices. Uses memory mapped transfers on sg devices. Similar syntax and seman‐\ntics to dd(1) but does not perform any conversions.\n\nWill only perform memory mapped transfers when IFILE or OFILE are SCSI generic (sg) devices.\n\nIf both IFILE and OFILE are sg devices then memory mapped transfers are performed  on  IFILE.\nIf  no  other  flags  are specified then indirect IO is performed on OFILE. If 'oflag=dio' is\ngiven then direct IO is attempted on OFILE. If direct IO is not available, then this  utility\nfalls back to indirect IO and reports this at the end of the copy.\n\nThe  first  group  in the synopsis above are \"standard\" Unix dd(1) operands. The second group\nare extra options added by this utility.  Both groups are defined below.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "bpt=BPT\neach IO transaction will be made using BPT blocks (or less if  near  the  end  of  the\ncopy).  Default  is 128 for block sizes less that 2048 bytes, otherwise the default is\n32. So for bs=512 the reads and writes will each convey 64  KiB  of  data  by  default\n(less  if near the end of the transfer or memory restrictions). When cd/dvd drives are\naccessed, the block size is typically 2048 bytes and bpt defaults to  32  which  again\nimplies 64 KiB transfers.\n\nbs=BS  where  BS  must  be the block size of the physical device. Note that this differs from\ndd(1) which permits BS to be an integral multiple. Default is  512  which  is  usually\ncorrect for disks but incorrect for cdroms (which normally have 2048 byte blocks). For\nthis utility the maximum size of each individual IO operation is BS * BPT bytes.\n\ncdbsz=6 | 10 | 12 | 16\nsize of SCSI READ and/or WRITE commands issued on sg device names.  Default is 10 byte\nSCSI  command  blocks  (unless calculations indicate that a 4 byte block number may be\nexceeded, in which case it defaults to 16 byte SCSI commands).\n\ncount=COUNT\ncopy COUNT blocks from IFILE to OFILE. Default is the minimum  (of  IFILE  and  OFILE)\nnumber of blocks that sg devices report from SCSI READ CAPACITY commands or that block\ndevices  (or  their partitions) report. Normal files are not probed for their size. If\nskip=SKIP or seek=SEEK are given and the count is derived (i.e.  not explicitly given)\nthen the derived count is scaled back so that the copy will not overrun the device. If\nthe file name is a block device partition and COUNT is not given then the size of  the\npartition  rather than the size of the whole device is used. If COUNT is not given and\ncannot be derived then an error message is issued and no copy takes place.\n\ndio=0 | 1\npermits direct IO to be selected on the write-side (i.e. on OFILE).  Only allowed when\nthe read-side (i.e. IFILE) is a sg device. When 1 there may  be  a  \"zero  copy\"  copy\n(i.e. mmap-ed transfer on the read into the user space and direct IO from there on the\nwrite, potentially two DMAs and no data copying from the CPU). Default is 0.  The same\naction as 'dio=1' is also available with 'oflag=dio'.\n\nibs=BS if given must be the same as BS given to 'bs=' option.\n\nif=IFILE\nread  from  IFILE instead of stdin. If IFILE is '-' then stdin is read. Starts reading\nat the beginning of IFILE unless SKIP is given.\n\niflag=FLAGS\nwhere FLAGS is a comma separated list of one or  more  flags  outlined  below.   These\nflags are associated with IFILE and are ignored when IFILE is stdin.\n\nobs=BS if given must be the same as BS given to 'bs=' option.\n\nof=OFILE\nwrite  to  OFILE instead of stdout. If OFILE is '-' then writes to stdout. If OFILE is\n/dev/null then no actual writes are performed.  If OFILE is '.' (period)  then  it  is\ntreated the same way as /dev/null (this is a shorthand notation). If OFILE exists then\nit is not truncated; it is overwritten from the start of OFILE unless 'oflag=append'\nor SEEK is given.\n\noflag=FLAGS\nwhere  FLAGS  is  a  comma  separated list of one or more flags outlined below.  These\nflags are associated with OFILE and are ignored when OFILE is /dev/null, '.' (period),\nor stdout.\n\nseek=SEEK\nstart writing SEEK bs-sized blocks from the start of OFILE.  Default is block 0  (i.e.\nstart of file).\n\nskip=SKIP\nstart  reading SKIP bs-sized blocks from the start of IFILE.  Default is block 0 (i.e.\nstart of file).\n\nsync=0 | 1\nwhen 1, does SYNCHRONIZE CACHE command on OFILE at the end of the transfer.  Only  ac‐\ntive when OFILE is a sg device file name.\n\ntime=0 | 1\nwhen  1,  times  transfer  and does throughput calculation, outputting the results (to\nstderr) at completion. When 0 (default) doesn't perform timing.\n\nverbose=VERB\nas VERB increases so does the amount of debug output sent to stderr.  Default value is\nzero which yields the minimum amount of debug output.  A value of 1 reports extra  in‐\nformation  that  is not repetitive. A value 2 reports cdbs and responses for SCSI com‐\nmands that are not repetitive (i.e. other that READ and WRITE).  Error  processing  is\nnot  considered  repetitive. Values of 3 and 4 yield output for all SCSI commands (and\nUnix read() and write() calls) so there can be a lot of output.\n",
            "subsections": [
                {
                    "name": "-d --dry-run",
                    "content": "does all the command line parsing and preparation but  bypasses  the  actual  copy  or\nread.  That preparation may include opening IFILE or OFILE to determine their lengths.\nThis option may be useful for testing the syntax of complex command  line  invocations\nin advance of executing them.\n",
                    "flag": "-d",
                    "long": "--dry-run"
                },
                {
                    "name": "-h --help",
                    "content": "outputs usage message and exits.\n",
                    "flag": "-h",
                    "long": "--help"
                },
                {
                    "name": "-v --verbose",
                    "content": "when  used once, this is equivalent to verbose=1. When used twice (e.g. \"-vv\") this is\nequivalent to verbose=2, etc.\n",
                    "flag": "-v",
                    "long": "--verbose"
                },
                {
                    "name": "-V --version",
                    "content": "outputs version number information and exits.\n",
                    "flag": "-V",
                    "long": "--version"
                }
            ]
        },
        "FLAGS": {
            "content": "Here is a list of flags and their meanings:\n\nappend causes the OAPPEND flag to be added to the open of OFILE. For normal files this  will\nlead  to  data appended to the end of any existing data.  Cannot be used together with\nthe seek=SEEK option as they conflict.  The default action of this utility is to over‐\nwrite any existing data from the beginning of the file or, if SEEK is given,  starting\nat  block  SEEK. Note that attempting to 'append' to a device file (e.g.  a disk) will\nusually be ignored or may cause an error to be reported.\n\ndio    is only active with oflag (i.e. 'oflag=dio'). Its action is described in  the  'dio=1'\noption description above.\n\ndirect causes  the ODIRECT flag to be added to the open of IFILE and/or OFILE. This flag re‐\nquires some memory alignment on IO. Hence user memory buffers are aligned to the  page\nsize. Has no effect on sg, normal or raw files.\n\ndpo    set  the DPO bit (disable page out) in SCSI READ and WRITE commands. Not supported for\n6 byte cdb variants of READ and WRITE. Indicates that data is unlikely to be  required\nto  stay  in device (e.g. disk) cache.  May speed media copy and/or cause a media copy\nto have less impact on other device users.\n\ndsync  causes the OSYNC flag to be added to the open of  IFILE  and/or  OFILE.  The  \"d\"  is\nprepended to lower confusion with the 'sync=0|1' option which has another action (i.e.\na synchronisation to media at the end of the transfer).\n\nexcl   causes the OEXCL flag to be added to the open of IFILE and/or OFILE.\n\nfua    causes  the  FUA (force unit access) bit to be set in SCSI READ and/or WRITE commands.\nThis only has effect with sg devices. The 6 byte variants of the SCSI READ  and  WRITE\ncommands do not support the FUA bit.  Only active for sg device file names.\n\nnull   has no affect, just a placeholder.\n",
            "subsections": []
        },
        "RETIRED OPTIONS": {
            "content": "Here are some retired options that are still present:\n\nfua=0 | 1 | 2 | 3\nforce  unit access bit. When 3, fua is set on both IFILE and OFILE; when 2, fua is set\non IFILE; when 1, fua is set on OFILE; when 0 (default), fua is cleared on  both.  See\nthe 'fua' flag.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "A  raw device must be bound to a block device prior to using sgmdd.  See raw(8) for more in‐\nformation about binding raw devices. To be safe, the sg device mapping to SCSI block  devices\nshould be checked with the lsscsi utility before use.\n\nRaw device partition information can often be found with fdisk(8) [the \"-ul\" argument is use‐\nful in this respect].\n\nVarious  numeric  arguments  (e.g.  SKIP)  may include multiplicative suffixes or be given in\nhexadecimal. See the \"NUMERIC ARGUMENTS\" section in the sg3utils(8) man page.\n\nThe count, skip and seek parameters can take 64 bit values (i.e.  very  big  numbers).  Other\nvalues are limited to what can fit in a signed 32 bit number.\n\nData  usually  gets  to the user space in a 2 stage process: first the SCSI adapter DMAs into\nkernel buffers and then the sg driver copies this data into user memory (write operations re‐\nverse this sequence).  With memory mapped transfers a kernel buffer reserved by sg is  memory\nmapped  (see  the mmap(2) system call) into the user space. When this is done the second (re‐\ndundant) copy from kernel buffers to user space is not needed. Hence the transfer  is  faster\nand requires less \"grunt\" from the CPU.\n\nAll  informative,  warning and error output is sent to stderr so that dd's output file can be\nstdout and remain unpolluted. If no options are given, then the usage message is  output  and\nnothing else happens.\n\nFor  sg  devices this utility issues SCSI READ and WRITE (SBC) commands which are appropriate\nfor disks and reading from CD/DVD/BD drives. Those commands are not formatted  correctly  for\ntape devices so sgmdd should not be used on tape devices.\n\nThis  utility  stops  the copy if any error is encountered. For more advanced \"copy on error\"\nlogic see the sgdd utility (and its 'coe' flag).\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "See the examples given in the man page for sgdd(8).\n",
            "subsections": []
        },
        "SIGNALS": {
            "content": "The signal handling has been borrowed from dd: SIGINT, SIGQUIT and SIGPIPE output the  number\nof  remaining  blocks to be transferred and the records in + out counts; then they have their\ndefault action.  SIGUSR1 causes the same information to be output  yet  the  copy  continues.\nAll output caused by signals is sent to stderr.\n",
            "subsections": []
        },
        "EXIT STATUS": {
            "content": "The  exit  status  of  sgmdd  is 0 when it is successful. Otherwise see the sg3utils(8) man\npage. Since this utility works at a higher level than  individual  commands,  and  there  are\n'coe'  and  'retries'  flags,  individual  SCSI  command  failures do not necessary cause the\nprocess to exit.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Written by Douglas Gilbert and Peter Allworth.\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "Report bugs to <dgilbert at interlog dot com>.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright © 2000-2019 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": "The simplest variant of this utility is called sgdd.  A POSIX threads version of this  util‐\nity  called  sgpdd  is  in the sg3utils package. The lmbench package contains lmdd which is\nalso interesting.  dd(1), ddpt(ddpt), raw(8)\n\nsg3utils-1.45                              February 2019                                  SGMDD(8)",
            "subsections": []
        }
    },
    "summary": "sgmdd - copy data to and from files and devices, especially SCSI devices",
    "flags": [
        {
            "flag": "-d",
            "long": "--dry-run",
            "arg": null,
            "description": "does all the command line parsing and preparation but bypasses the actual copy or read. That preparation may include opening IFILE or OFILE to determine their lengths. This option may be useful for testing the syntax of complex command line invocations in advance of executing them."
        },
        {
            "flag": "-h",
            "long": "--help",
            "arg": null,
            "description": "outputs usage message and exits."
        },
        {
            "flag": "-v",
            "long": "--verbose",
            "arg": null,
            "description": "when used once, this is equivalent to verbose=1. When used twice (e.g. \"-vv\") this is equivalent to verbose=2, etc."
        },
        {
            "flag": "-V",
            "long": "--version",
            "arg": null,
            "description": "outputs version number information and exits."
        }
    ],
    "examples": [
        "See the examples given in the man page for sgdd(8)."
    ],
    "see_also": [
        {
            "name": "dd",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/dd/1/json"
        },
        {
            "name": "ddpt",
            "section": "ddpt",
            "url": "https://www.chedong.com/phpMan.php/man/ddpt/ddpt/json"
        },
        {
            "name": "raw",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/raw/8/json"
        }
    ]
}