OS Manuals

/usr/bin/sg_write_x

SCSI utilities for Linux, Unix and Windows

From sg3-utils 1.49-r3 (enterprise-packages), captured 2026-11-08 by running sg_write_x --help (exit 0). permalink

Usage:
sg_write_x [--16] [--32] [--app-tag=AT] [--atomic=AB] [--bmop=OP,PGP]
           [--bs=BS] [--combined=DOF] [--dld=DLD] [--dpo] [--dry-run]
           [--fua] [--generation=EOG,NOG] [--grpnum=GN] [--help] --in=IF
           [--lba=LBA,LBA...] [--normal] [--num=NUM,NUM...]
           [--offset=OFF[,DLEN]] [--or] [--quiet] [--ref-tag=RT]
           [--same=NDOB] [--scat-file=SF] [--scat-raw] [--scattered=RD]
           [--stream=ID] [--strict] [--tag-mask=TM] [--timeout=TO]
           [--unmap=U_A] [--verbose] [--version] [--wrprotect=WRP]
           DEVICE
  where:
    --16|-6            send 16 byte cdb variant (this is default action)
    --32|-3            send 32 byte cdb variant of command (def: 16 byte)
    --app-tag=AT|-a AT    expected application tag field (def: 0xffff)
    --atomic=AB|-A AB    send WRITE ATOMIC command with AB being its
                         Atomic Boundary field (0 to 0xffff)
    --bmop=OP,PGP|-p OP,PGP    set BMOP field to OP and  Previous
                               Generation Processing field to PGP
    --bs=BS|-b BS      block size (def: use READ CAPACITY), if power of
                       2: logical block size, otherwise: actual block size
    --combined=DOF|-c DOF    scatter list and data combined for WRITE
                             SCATTERED, data starting at offset DOF which
                             has units of sizeof(LB+PI); sizeof(PI)=8n or 0
    --dld=DLD|-D DLD    set duration limit descriptor (dld) bits (def: 0)
    --dpo|-d           set DPO (disable page out) field (def: clear)
    --dry-run|-x       exit just before sending SCSI write command
    --fua|-f           set FUA (force unit access) field (def: clear)
    --generation=EOG,NOG    set Expected ORWgeneration field to EOG
        |-G EOG,NOG         and New ORWgeneration field to NOG
    --grpnum=GN|-g GN    GN is group number field (def: 0, range: 0 to 63)
    --help|-h          use multiple times for different usage messages
    --in=IF|-i IF      IF is file to fetch NUM blocks of data from.
                       Blocks written to DEVICE. 1 or no blocks read
                       in the case of WRITE SAME
    --lba=LBA,LBA...     list of LBAs (Logical Block Addresses) to start
        |-l LBA,LBA...   writes (def: --lba=0). Alternative is --scat-file=SF
    --normal|-N        send 'normal' WRITE command (default when no other
                       command option given)
    --num=NUM,NUM...     NUM is number of logical blocks to write (def:
        |-n NUM,NUM...   --num=0). Number of block sent is sum of NUMs
    --offset=OFF[,DLEN]    OFF is byte offset in IF to start reading from
        |-o OFF[,DLEN]     (def: 0), then read DLEN bytes(def: rest of IF)
    --or|-O            send ORWRITE command
    --quiet|-Q         suppress some informational messages
    --ref-tag=RT|-r RT     expected reference tag field (def: 0xffffffff)
    --same=NDOB|-M NDOB    send WRITE SAME command. NDOB (no data out buffer)
                           can be either 0 (do send buffer) or 1 (don't)
    --scat-file=SF|-q SF    file containing LBA, NUM pairs, see manpage
    --scat-raw|-R      read --scat_file=SF as binary (def: ASCII hex)
    --scattered=RD|-S RD    send WRITE SCATTERED command with RD range
                            descriptors (RD can be 0 when --combined= given)
    --stream=ID|-T ID    send WRITE STREAM command with its STR_ID
                         field set to ID
    --strict|-s        exit if read less than requested from IF ;
                       require variety of WRITE to be given as option
    --tag-mask=TM|-t TM    tag mask field (def: 0xffff)
    --timeout=TO|-I TO    command timeout (unit: seconds) (def: 120)
    --unmap=U_A|-u U_A    0 clears both UNMAP and ANCHOR bits (default),
                          1 sets UNMAP, 2 sets ANCHOR, 3 sets both
    --verbose|-v       increase verbosity
    --version|-V       print version string then exit
    --wrprotect=WPR|-w WPR    WPR is the WRPROTECT field value (def: 0)

Performs a SCSI WRITE (normal), ORWRITE, WRITE ATOMIC, WRITE SAME, WRITE
SCATTERED, or WRITE STREAM command. A 16 or 32 byte cdb variant can be
selected. The --in=IF option (data to be written) is required apart from
when --same=1 (i.e. when NDOB is set). If no WRITE variant option is given
then, in the absence of --strict, a (normal) WRITE is performed. Only WRITE
SCATTERED uses multiple LBAs and NUMs, or a SF file with multiple pairs.
The --num=NUM field defaults to 0 (do nothing) for safety. Using '-h'
multiple times shows the applicable options for each command variant.
Options (34)
OptionDescriptionSource
--app-tag, -a AT|-awhere AT is the "expected logical block application tag" field found in most of the 32 byte cdb variants (the exception is ORWRITE(32)).help + man
--atomic, -A AB|-Aselects the WRITE ATOMIC command and AB is placed in the Atomic Boundary field of its cdb.help + man
--bmop, -B OPwhere OP and PGP are the values to be placed in ORWRITE(32)'s BMOP and 'Previous Generation Processing' fields respectively.help + man
--bs, -b BS|-bblock size (def: use READ CAPACITY), if power of 2: logical block size, otherwise: actual block sizehelp + man
--combined, -c DOF|-cThis option only applies to WRITE SCATTERED and assumes the whole data-out buffer can be read from IF given by the --in=IF option.help + man
--dld, -D DLD|-Dwhere DLD is the duration limits descriptor spread across 3 bits in the SCSI WRITE(16) and the WRITE SCATTERED(16) cdbs.help + man
--generation, -G EOGset Expected ORWgeneration field to EOG |-G EOG,NOG and New ORWgeneration field to NOGhelp + man
--grpnum, -g GN|-gGN is group number field (def: 0, range: 0 to 63)help + man
--in, -i IF|-iread data (in binary) from a file named IF in a single OS system call (in Unix: read(2)).help + man
--lba LBAlist of LBAs (Logical Block Addresses) to start |-l LBA,LBA...help
--num NUMNUM is number of logical blocks to write (def: |-n NUM,NUM...help
--offset OFFOFF is byte offset in IF to start reading from |-o OFF[,DLEN] (def: 0), then read DLEN bytes(def: rest of IF)help
--ref-tag, -r RT|-rwhere RT is the "expected initial logical block reference tag" field found in the 32 byte cdb variants of WRITE, WRITE ATOMIC, WRITE SAME and WRITE STREAM.help + man
--same, -S NDOB|-Mselects the WRITE SAME command with the NDOB field set to NDOB which stands for No Data-Out Buffer.help + man
--scat-file, -q SF|-qwhere SF is the name of an auxiliary file containing the scatter list for the WRITE SCATTERED command.help + man
--scattered RD|-Ssend WRITE SCATTERED command with RD range descriptors (RD can be 0 when --combined= given)help
--stream, -T ID|-Tselects the WRITE STREAM command with the STR_ID field set to ID.help + man
--tag-mask, -t TM|-twhere TM is the "logical block application tag mask" field found in the 32 byte cdb variants of WRITE, WRITE ATOMIC, WRITE SAME and WRITE STREAM.help + man
--timeout, -I TO|-Iwhere TO is the command timeout value in seconds.help + man
--unmap, -u U_A|-uwhere U_A is OR-ed bit values used to set the UNMAP and ANCHOR bit fields in the WRITE SAME (16 or 32) cdb.help + man
--wrprotect, -w WPR|-wsets the WRPROTECT field (3 bits) in all sg_write_x commands apart from ORWRITE which has a 3 bit ORPROTECT field (and the synopsis shows OPR to highlight the difference).help + man
-6, --16send the 16 byte cdb variant of the selected SCSI command. (in the manual page but not in --help)man
-3, --32send the 32 byte cdb variant of the selected SCSI command. (in the manual page but not in --help)man
-d, --dpoif this option is given then the DPO (disable page out) bit field in the cdb is set. (in the manual page but not in --help)man
-x, --dry-runthis option exits (with a status of 0) just before it would otherwise send the selected SCSI write command. (in the manual page but not in --help)man
-f, --fuaif this option is given then the FUA (force unit access) bit field in the cdb is set. (in the manual page but not in --help)man
-h, --helpoutput the usage message then exit. (in the manual page but not in --help)man
-N, --normalthe choice of a "normal" WRITE (16 or 32) command can be made explicitly with this option. (in the manual page but not in --help)man
-O, --orselects the ORWRITE command. (in the manual page but not in --help)man
-Q, --quietsuppress some informational messages such as the ones associated with detected errors when this utility is about to exit. (in the manual page but not in --help)man
-R, --scat-rawthis option only effects the way that the file named SF from the --scat-file=SF option for WRITE SCATTERED is interpreted. (in the manual page but not in --help)man
-s, --strictwhen this option is present, more things (e.g. that reserved fields contain zeros) and any irregularities will terminate the utility with a message to stderr and an indicative exit status. (in the manual page but not in --help)man
-v, --verboseincrease the degree of verbosity (debug messages). (in the manual page but not in --help)man
-V, --versionoutput version string then exit. (in the manual page but not in --help)man
Exit status (1) from the manual page
0it is successful
Examples (1) from the manual page, untested

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.