1SG_WRITE_LONG(8)                   SG3_UTILS                  SG_WRITE_LONG(8)
2
3
4

NAME

6       sg_write_long - send the SCSI WRITE LONG command
7

SYNOPSIS

9       sg_write_long   [--16]   [--cor_dis]   [--help]  [--in=IF]  [--lba=LBA]
10       [--pblock] [--verbose] [--version] [--wr_uncor] [--xfer_len=BTL] DEVICE
11

DESCRIPTION

13       Send the SCSI WRITE LONG (10 or 16 byte) command to DEVICE. The  buffer
14       to  be written to the DEVICE is filled with 0xff bytes or read from the
15       IF file. This buffer includes the logical data (e.g. 512 bytes) and the
16       ECC bytes.
17
18       This utility can be used to generate a MEDIUM ERROR at a specific logi‐
19       cal block address. This can be useful for testing error handling. Prior
20       to  such  a  test, the sg_dd utility could be used to copy the original
21       contents of the logical block address to some safe location. After  the
22       test  the  sg_dd  utility could be used to write back the original con‐
23       tents of the logical block address. An alternate strategy would  be  to
24       read the "long" contents of the logical block address with sg_read_long
25       utility prior to testing and restore it with this utility  after  test‐
26       ing.
27
28       Take care: If recoverable errors are being injected (e.g. only one or a
29       few bits changed so that the ECC is able to correct the data) then care
30       should  be  taken  with the settings in the "read write error recovery"
31       mode page.  Specifically if the  ARRE  (for  reads)  and/or  AWRE  (for
32       writes)  are  set  then recovered errors will cause the lba to be reas‐
33       signed (and the old location to be  added  to  the  grown  defect  list
34       (PLIST)).  This  is not easily reversed and uses the (finite number) of
35       spare sectors set aside for this purpose. If in doubt  it  is  probably
36       safest  to  clear the ARRE and AWRE bits. These bits can be checked and
37       modified with the sdparm utility.  For example:  "sdparm  -c  AWRE,ARRE
38       /dev/sda" will clear the bits until the disk is rebooted.
39

OPTIONS

41       Arguments to long options are mandatory for short options as well.
42
43       -S, --16
44              send  a  SCSI  WRITE  LONG  (16)  command to DEVICE. The default
45              action (in the absence of this option) is to send a  SCSI  WRITE
46              LONG (10) command.
47
48       -c, --cor_dis
49              sets  the correction disabled (i.e 'COR_DIS') bit. This inhibits
50              various other mechanisms such as automatic  block  reallocation,
51              error  recovery  and  various informational exception conditions
52              being triggered.  This bit is new in SBC-3 .
53
54       -h, --help
55              output the usage message then exit.
56
57       -i, --in=IF
58              read data (binary) from file named IF and use it  for  the  SCSI
59              WRITE  LONG  command.  If  IF is "-" then stdin is read. If this
60              option is not given then 0xff bytes are used as fill.
61
62       -l, --lba=LBA
63              where LBA is the logical block address of the  sector  to  over‐
64              write.   Defaults  to  lba 0 which is a dangerous block to over‐
65              write on a disk that is in use. Assumed to be in decimal  unless
66              prefixed  with  '0x' or has a traling 'h'. If LBA is larger than
67              can fit in 32 bits then the --16 option should be used.
68
69       -p, --pblock
70              sets the physical  block  (i.e  'PBLOCK')  bit.  This  instructs
71              DEVICE  to  use the given data (unless --wr_uncor is also given)
72              to write to the physical block specified  by  LBA.  The  default
73              action  is  to  write  to the logical block corresponding to the
74              given lba.  This bit is new in SBC-3 .
75
76       -v, --verbose
77              increase the degree of verbosity (debug messages).
78
79       -V, --version
80              output version string then exit.
81
82       -w, --wr_uncor
83              sets  the  "write  uncorrected"  (i.e  'WR_UNCOR')   bit.   This
84              instructs  the  DEVICE  to  flag  the given lba (or the physical
85              block that contains it if --pblock is also given) as  having  an
86              unrecoverable  error associated with it. Note: no data is trans‐
87              ferred to DEVICE, other than the command  (i.e.  the  cdb).  The
88              default  action  is  to use the provided data (--xfer_len=BTL in
89              length) and write it to DEVICE.  This bit is new in SBC-3 .
90
91       -x, --xfer_len=BTL
92              where BTL is the byte transfer length (default to 520).  If  the
93              given  value  (or  the  default) does not match the "long" block
94              size of the device, nothing is written to DEVICE and the  appro‐
95              priate  xfer_len  value  may  be deduced from the error response
96              which is printed (to stderr).
97

NOTES

99       The LBA and BTL (transfer length) arguments may be followed by the fol‐
100       lowing  multiplicative  suffixes:  c  C  *1;  w W *2; b B *512; k K KiB
101       *1,024; KB  *1,000;  m  M  MiB  *1,048,576;  MB  *1,000,000;  g  G  GiB
102       *1,073,741,824;  and  GB  *1,000,000,000  .  Also  a suffix of the form
103       "x<n>" multiplies the leading number by <n>.
104
105       Alternatively numerical values can be given in hexadecimal preceded  by
106       either  "0x"  or "0X" (or with a trailing "h" or "H"). When hex numbers
107       are given, multipliers cannot be used.
108
109       To read from a defective sector (that, for  example,  has  been  filled
110       with 0xff bytes by this utility) use:
111
112         sg_dd if=DEVICE skip=LBA of=/dev/null bs=512 count=1
113
114       To overwrite to a defective sector use:
115
116         sg_dd of=DEVICE seek=LBA if=/dev/zero bs=512 count=1
117
118       This  will  result  in a sector (block) with 512 bytes of 0x0 without a
119       MEDIUM ERROR since the ECC and associated data will be well formed.
120
121       The 10 byte SCSI WRITE LONG command limits the logical block address to
122       a  32  bit  quantity.  For larger lbas use the --16 option for the SCSI
123       WRITE LONG (16) command.
124

EXIT STATUS

126       The exit status of sg_write_long is 0 when it is successful.  Otherwise
127       see the sg3_utils(8) man page.
128

AUTHORS

130       Written by Saeed Bishara. Further work by Douglas Gilbert.
131

REPORTING BUGS

133       Report bugs to <dgilbert at interlog dot com>.
134
136       Copyright © 2004-2007 Douglas Gilbert
137       This  software is distributed under the GPL version 2. There is NO war‐
138       ranty; not even for MERCHANTABILITY or FITNESS FOR  A  PARTICULAR  PUR‐
139       POSE.
140

SEE ALSO

142       sg_read_long, sg_dd (both in sg3_utils), sdparm(sdparm)
143
144
145
146sg3_utils-1.23                   January 2007                 SG_WRITE_LONG(8)
Impressum