OS Manuals

/usr/bin/sg_write_same

SCSI utilities for Linux, Unix and Windows

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

Usage: sg_write_same [--10] [--16] [--32] [--anchor] [--ff] [--grpnum=GN]
                     [--help] [--in=IF] [--lba=LBA] [--lbdata] [--ndob]
                     [--num=NUM] [--pbdata] [--timeout=TO] [--unmap]
                     [--verbose] [--version] [--wrprotect=WRP] [xferlen=LEN]
                     DEVICE
  where:
    --10|-R              send WRITE SAME(10) (even if '--unmap' is given)
    --16|-S              send WRITE SAME(16) (def: 10 unless '--unmap' given,
                         LBA+NUM > 32 bits, or NUM > 65535; then def 16)
    --32|-T              send WRITE SAME(32) (def: 10 or 16)
    --anchor|-a          set ANCHOR field in cdb
    --ff|-f              use buffer of 0xff bytes for fill (def: 0x0 bytes)
    --grpnum=GN|-g GN    GN is group number field (def: 0)
    --help|-h            print out usage message
    --in=IF|-i IF        IF is file to fetch one block of data from (use LEN
                         bytes or whole file). Block written to DEVICE
    --lba=LBA|-l LBA     LBA is the logical block address to start (def: 0)
    --lbdata|-L          set LBDATA bit (obsolete)
    --ndob|-N            set NDOB (no data-out buffer) bit in cdb
    --num=NUM|-n NUM     NUM is number of logical blocks to write (def: 1)
                         [Beware NUM==0 may mean: 'rest of device']
    --pbdata|-P          set PBDATA bit (obsolete)
    --timeout=TO|-t TO    command timeout (unit: seconds) (def: 60)
    --unmap|-U           set UNMAP bit in cdb
    --verbose|-v         increase verbosity
    --version|-V         print version string then exit
    --wrprotect=WPR|-w WPR    WPR is the WRPROTECT field value (def: 0)
    --xferlen=LEN|-x LEN    LEN is number of bytes from IF to send to
                            DEVICE (def: IF file length)

Performs a SCSI WRITE SAME (10, 16 or 32) command. NDOB bit is only
supported by the 16 and 32 byte variants. When set the specified blocks
will be filled with zeros or the 'provisioning initialization pattern'
as indicated by the LBPRZ field. As a precaution one of the '--in=',
'--lba=' or '--num=' options is required.
Another implementation of WRITE SAME is found in the sg_write_x utility.
Options (19)
OptionDescriptionSource
--grpnum, -g GN|-gsets the 'Group number' field to GN.help + man
--in, -i IF|-iread data (binary) from file named IF and use it as the data-out buffer for the SCSI WRITE SAME command.help + man
--lba, -l LBA|-lwhere LBA is the logical block address to start the WRITE SAME command.help + man
--num, -n NUM|-nNUM is number of logical blocks to write (def: 1) [Beware NUM==0 may mean: 'rest of device']help + man
--timeout, -t TO|-twhere TO is the command timeout value in seconds.help + man
--wrprotect, -w WPR|-wsets the "Write protect" field in the WRITE SAME cdb to WPR.help + man
--xferlen, -x LEN|-xLEN is number of bytes from IF to send to DEVICE (def: IF file length)help + man
-R, --10send a SCSI WRITE SAME (10) command to DEVICE. (in the manual page but not in --help)man
-S, --16send a SCSI WRITE SAME (16) command to DEVICE. (in the manual page but not in --help)man
-T, --32send a SCSI WRITE SAME (32) command to DEVICE. (in the manual page but not in --help)man
-a, --anchorsets the ANCHOR bit in the cdb. (in the manual page but not in --help)man
-f, --ffthe data-out buffer sent with this command is initialized with 0xff bytes when this option is given. (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
-L, --lbdatasets the LBDATA bit in the WRITE SAME cdb. (in the manual page but not in --help)man
-N, --ndobsets the NDOB bit in the WRITE SAME (16 and 32 byte) commands. (in the manual page but not in --help)man
-P, --pbdatasets the PBDATA bit in the WRITE SAME cdb. (in the manual page but not in --help)man
-U, --unmapsets the UNMAP bit in the WRITE SAME(10, 16 and 32) cdb. (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

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