~ubuntu-branches/ubuntu/intrepid/sg3-utils/intrepid

« back to all changes in this revision

Viewing changes to sgp_dd.8

  • Committer: Bazaar Package Importer
  • Author(s): Luk Claes
  • Date: 2006-11-05 17:23:29 UTC
  • mfrom: (1.1.4 upstream) (3.1.2 edgy)
  • Revision ID: james.westby@ubuntu.com-20061105172329-l4loha00sk36qz6k
* Non-maintainer upload.
* Fix FTBFS due to old syscall usage (Closes: #395512).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
.TH SGP_DD "8" "August 2004" "sg3_utils-1.08" SG3_UTILS
 
1
.TH SGP_DD "8" "June 2006" "sg3_utils-1.21" SG3_UTILS
2
2
.SH NAME
3
3
sgp_dd \- copies data to and from files and devices. Specialised for
4
4
devices that understand the SCSI command set.
5
5
.SH SYNOPSIS
6
6
.B sgp_dd
7
 
[\fIbpt=<n>\fR] [\fIbs=<n>\fR] [\fIcdbsz=6|10|12|16\fR] [\fIcoe=0|1\fR]
8
 
[\fIcount=<n>\fR] [\fIdeb=<n>\fR] [\fIdio=0|1\fR] [\fIfua=0|1|2|3\fR]
9
 
[\fIibs=<n>\fR] [\fIif=<ifile>\fR] [\fIobs=<n>\fR] [\fIof=<ofile>\fR]
10
 
[\fIseek=<n>\fR] [\fIskip=<n>\fR] [\fIsync=0|1\fR] [\fIthr=<n>\fR]
11
 
[\fItime=0|1\fR] [\fI--version\fR]
 
7
[\fIbs=<n>\fR] [\fIcount=<n>\fR] [\fIibs=<n>\fR] [\fIif=<ifile>\fR]
 
8
[\fIiflag=<flags>\fR] [\fIobs=<n>\fR] [\fIof=<ofile>\fR]
 
9
[\fIoflag=<flags>\fR] [\fIseek=<n>\fR] [\fIskip=<n>\fR]
 
10
[\fI--help\fR] [\fI--version\fR]
 
11
.PP
 
12
[\fIbpt=<n>\fR] [\fIcdbsz=6|10|12|16\fR] [\fIdeb=<n>\fR] [\fIdio=0|1\fR]
 
13
[\fIsync=0|1\fR] [\fIthr=<n>\fR] [\fItime=0|1\fR]
12
14
.SH DESCRIPTION
13
15
.\" Add any additional description here
14
16
.PP
17
19
.B dd(1) 
18
20
but does not perform any conversions. Uses POSIX threads to increase
19
21
the amount of parallelism. This improves speed in some cases.
 
22
.PP
 
23
The first group in the synopsis above are "standard" Unix
 
24
.B dd(1)
 
25
arguments. The second group are extra arguments added by this utility.
 
26
Both groups are defined below.
20
27
.TP
21
28
bpt=BLOCKS
22
 
each IO transaction will be made using this number of blocks (or less if 
23
 
near the end of count). Default is 128.
 
29
each IO transaction will be made using this number of blocks (or less if
 
30
near the end of count). Default is 128 for block sizes less that 2048
 
31
bytes, otherwise the default is 32. So for bs=512 the reads and writes
 
32
will each convey 64 KiB of data by default (less if near the end of the
 
33
transfer or memory restrictions). When cd/dvd drives are accessed, the
 
34
block size is typically 2048 bytes and bpt defaults to 32 which again
 
35
implies 64 KiB transfers.
24
36
.TP
25
37
bs=BYTES
26
38
this 
27
39
.B must 
28
40
be the block size of the physical device. Note that this differs from
29
41
.B dd(1) 
30
 
which permits "bs" to be an integral multiple. Default is 512 which 
31
 
is usually correct for disks but incorrect for cdroms (which normally
32
 
have 2048 byte blocks).
 
42
which permits 'bs' to be an integral multiple of the actual device block
 
43
size. Default is 512 which is usually correct for disks but incorrect for
 
44
cdroms (which normally have 2048 byte blocks).
 
45
.TP
33
46
cdbsz=6 | 10 | 12 | 16
34
47
size of SCSI READ and/or WRITE commands issued on sg device names.
35
 
Default is 10 byte SCSI command blocks
36
 
.TP
37
 
coe=0 | 1
38
 
continue on error is 0 (off) by default. When it is 1 read errors
39
 
are stepped over (with a block (or blocks) of zeroes being output).
40
 
When 1, write errors are ignored (and alignment is maintained)
41
 
Similar to "conv=noerror" in
42
 
.B dd(1)
43
 
utility. Default is 0 which implies stop on error
 
48
Default is 10 byte SCSI command blocks (unless calculations indicate
 
49
that a 4 byte block number may be exceeded, in which case it defaults
 
50
to 16 byte SCSI commands).
44
51
.TP
45
52
count=BLOCKS
46
 
copy this number of blocks from 'if' to 'of'. Default is the
47
 
minimum (of 'if' and 'of') number of blocks that sg devices return from
48
 
READ CAPACITY SCSI commands or that block devices report.
 
53
copy this number of blocks from 'if' to 'of'. Default is the minimum (
 
54
of 'if' and 'of') number of blocks that sg devices return from READ
 
55
CAPACITY SCSI commands or that block devices (or their partitions) report.
49
56
Normal files are not probed for their size. If 'skip'
50
 
or 'seek' are given and the count is derived (i.e. not explicitly given)
51
 
then the derived count is scaled back so that the copy will not overrun the
 
57
or 'seek' are given and the count is deduced (i.e. not explicitly given)
 
58
then that count is scaled back so that the copy will not overrun the
52
59
device. If the file name is a block device partition and count is not given
53
60
then the size of the partition rather than the size of the whole device is
54
 
used. If count is not given and cannot be derived then an error message
 
61
used. If count is not given and cannot be deduced then an error message
55
62
is issued and no copy takes place.
56
63
.TP
57
64
deb=NUM
64
71
at completion. If direct IO is selected and /proc/scsi/sg/allow_dio
65
72
has the value of 0 then a warning is issued (and indirect IO is performed)
66
73
.TP
67
 
fua=0 | 1 | 2 | 3
68
 
force unit access bit. When 3, fua is set on both "if" and "of", when 2, fua
69
 
is set on "if", when 1, fua is set on "of", when 0 (the default), fua is
70
 
cleared on both. 6 byte SCSI READ and WRITE commands (cdbsz=6) do not
71
 
support the fua bit. Only active for sg device file names.
72
 
.TP
73
74
ibs=BYTES
74
 
if given must be the same as bs
 
75
if given must be the same value as 'bs'.
75
76
.TP
76
77
if=FILE
77
78
read from FILE instead of stdin. A file name of - is taken to be stdin.
78
 
Starts reading at the beginning of FILE unless "skip" is given.
 
79
Starts reading at the beginning of FILE unless 'skip=<n>' is given.
 
80
.TP
 
81
iflag=FLAGS
 
82
where FLAGS is a comma separated list of one or more flags outlined below.
 
83
These flags are associated with <ifile> and are ignored when <ifile> is
 
84
stdin.
79
85
.TP
80
86
obs=BYTES
81
 
if given must be the same as bs
 
87
if given must be the same as 'bs'.
82
88
.TP
83
89
of=FILE
84
90
write to FILE instead of stdout. A file name of - is taken to be stdout.
85
91
If FILE is /dev/null then no actual writes are performed. If FILE is .
86
92
(period) then it is treated the same way as /dev/null (this is a
87
 
shorthand notation)
 
93
shorthand notation). Starts (over-)writing at the beginning of FILE
 
94
unless either 'seek=<n>' or 'oflag=append' is given (it is not permitted
 
95
to give both).
 
96
.TP
 
97
oflag=FLAGS
 
98
where FLAGS is a comma separated list of one or more flags outlined below.
 
99
These flags are associated with <ofile> and are ignored when <ofile>
 
100
is /dev/null, . (period), or stdout.
88
101
.TP
89
102
seek=BLOCKS
90
103
start writing BLOCKS bs-sized blocks from the start of the output file.
95
108
Default is block 0 (i.e. start of file).
96
109
.TP
97
110
sync=0 | 1
98
 
when 1, does SYNCHRONIZE CACHE command on "of" at the end of the transfer.
99
 
Only active when "of" is a sg device file name
 
111
when 1, does SYNCHRONIZE CACHE command on 'of' at the end of the transfer.
 
112
Only active when 'of' is a sg device file name
100
113
.TP
101
114
thr=NUM
102
115
this is the number or worker threads (default 4) that attempt to
103
116
copy in parallel. Minimum is 0 and maximum is 16
104
117
.TP
105
118
time=0 | 1
106
 
when 1, times transfer and does throughput calculation, outputting the
107
 
results (to stderr) at completion. When 0 (default) doesn't perform timing
 
119
when 1, the transfer is timed and throughput calculation is
 
120
performed, outputting the results (to stderr) at completion. When
 
121
0 (default) no timing is performed.
 
122
.TP
 
123
--help
 
124
outputs usage message and exits
108
125
.TP
109
126
--version
110
127
outputs version number information and exits
111
 
.PP
 
128
.SH FLAGS
 
129
Here is a list of flags and their meanings:
 
130
.TP
 
131
append
 
132
causes the O_APPEND flag to be added to the open of <ofile>. For normal
 
133
files this will lead to data appended to the end of any existing data.
 
134
Cannot be used together with the 'seek=<n>' option as they conflict.
 
135
The default action of this utility is to overwrite any existing data
 
136
from the beginning of the file or, if 'seek=<n>' is given, starting at
 
137
block <n>. Note that attempting to "append" to a device file will
 
138
usually be ignored or may cause an error to be reported.
 
139
.TP
 
140
coe
 
141
continue on error. When given with 'iflag=', an error that is detected
 
142
in a single SCSI command (typically 'bpt' blocks) is noted (by an error
 
143
message sent to stderr), then zeroes are substituted into the buffer
 
144
for the corresponding write operation and the copy continues. Note that the 
 
145
.B sg_dd
 
146
utility is more sophisticated in such error situations when 'iflag=coe'.
 
147
When given with 'oflag=', any error reported by a SCSI WRITE command is
 
148
reported to stderr and the copy continues (as if nothing went wrong).
 
149
.TP
 
150
direct
 
151
causes the O_DIRECT flag to be added to the open of <ifile> and/or <ofile>.
 
152
This flag requires some memory alignment on IO. Hence user memory buffers
 
153
are aligned to the page size. Has no effect on sg, normal or raw files.
 
154
.TP
 
155
dpo
 
156
set the DPO bit (disable page out) in READ and WRITE SCSI commands. Not
 
157
supported for 6 byte cdb variants of READ and WRITE. Indicates that
 
158
data is unlikely to be required to stay in device (e.g. disk) cache.
 
159
May speed media copy and/or cause a media copy to have less impact
 
160
on other device users.
 
161
.TP
 
162
dsync
 
163
causes the O_SYNC flag to be added to the open of <ifile> and/or <ofile>.
 
164
The "d" is prepended to lower confusion with the 'sync=0|1' option which
 
165
has another action (i.e. a synchronisation to media at the end of the
 
166
transfer).
 
167
.TP
 
168
excl
 
169
causes the O_EXCL flag to be added to the open of <ifile> and/or <ofile>.
 
170
.TP
 
171
fua
 
172
causes the FUA (force unit access) bit to be set in READ and/or WRITE
 
173
SCSI commands. This only has effect with sg devices. The 6 byte variants
 
174
of the READ and WRITE SCSI commands do not support the FUA bit.
 
175
Only active for sg device file names.
 
176
.SH RETIRED OPTIONS
 
177
Here are some retired options that are still present:
 
178
.TP
 
179
coe=0 | 1
 
180
continue on error is 0 (off) by default. When it is 1, it is
 
181
equivalent to 'iflag=coe oflag=coe' described in the FLAGS section
 
182
above.  Similar to 'conv=noerror' in
 
183
.B dd(1)
 
184
utility. Default is 0 which implies stop on error. More advanced
 
185
coe=1 processing on reads is performed by the sg_dd utility.
 
186
.TP
 
187
fua=0 | 1 | 2 | 3
 
188
force unit access bit. When 3, fua is set on both 'if' and 'of'; when 2, fua
 
189
is set on 'if'; when 1, fua is set on 'of'; when 0 (default), fua is cleared
 
190
on both. See the 'fua' flag.
 
191
.SH NOTES
112
192
A raw device must be bound to a block device prior to using sgp_dd.
113
193
See
114
194
.B raw(8)
115
195
for more information about binding raw devices. To be safe, the sg device
116
 
mapping to SCSI block devices should be checked with "cat /proc/scsi/scsi"
 
196
mapping to SCSI block devices should be checked with 'cat /proc/scsi/scsi'
117
197
before use.
118
198
.PP
119
 
The count is only deduced for sg devices (minimum > 0 if both input and
120
 
output are sg devices) otherwise it defaults to 0. This is for safety!
121
199
Raw device partition information can often be found with
122
200
.B fdisk(8)
123
201
[the "-ul" argument is useful in this respect].
124
202
.PP
125
 
BYTES and BLOCKS may be followed by the following multiplicative suffixes:
126
 
c C *1; b B *512; k *1,024; K *1,000; m *1,048,576; M *1,000,000;
127
 
g *1,073,741,824; G *1,000,000,000; t *1,099,511,627,776 and
128
 
T *1,000,000,000,000 (the latter two can only be used for count, skip
129
 
and seek values).
 
203
BYTES and BLOCKS may be followed by one of these multiplicative suffixes:
 
204
c C *1; w W *2; b B *512; k K KiB *1,024; KB *1,000; m M MiB *1,048,576;
 
205
MB *1,000,000 . This pattern continues for "G", "T" and "P". The latter two
 
206
suffixes can only be used for count, skip and seek values). Also a suffix of
 
207
the form "x<n>" multiplies the leading number by <n>. These multiplicative
 
208
suffixes are compatible with GNU's dd command (since 2002) which claims
 
209
compliance with SI and with IEC 60027-2.
130
210
.PP
131
211
Alternatively numerical values can be given in hexadecimal preceded by
132
 
either "0x" or "0X". When hex numbers are given multipliers cannot be
 
212
either "0x" or "0X". When hex numbers are given, multipliers cannot be
133
213
used.
134
214
.PP
135
215
The count, skip and seek parameters can take 64 bit values (i.e. very
139
219
Data usually gets to the user space in a 2 stage process: first the
140
220
SCSI adapter DMAs into kernel buffers and then the sg driver copies
141
221
this data into user memory (write operations reverse this sequence).
142
 
This is called "indirect IO" and there is a "dio" option to select
 
222
This is called "indirect IO" and there is a 'dio' option to select
143
223
"direct IO" which will DMA directly into user memory. Due to some
144
224
issues "direct IO" is disabled in the sg driver and needs a
145
225
configuration change to activate it.
152
232
(mainly with sg devices, raw devices give some improvement).
153
233
Another reason is that big copies fill the block device caches
154
234
which has a negative impact on other machine activity.
 
235
.SH SIGNALS
 
236
The signal handling has been borrowed from dd: SIGINT, SIGQUIT and
 
237
SIGPIPE output the number of remaining blocks to be transferred and
 
238
the records in + out counts; then they have their default action.
 
239
SIGUSR1 causes the same information to be output yet the copy continues.
 
240
All output caused by signals is sent to stderr.
155
241
.SH EXAMPLES
156
242
.PP
157
243
Looks quite similar in usage to dd:
158
244
.PP
159
 
   sgp_dd if=/dev/sg0 of=t bs=512 count=1M
 
245
   sgp_dd if=/dev/sg0 of=t bs=512 count=1MB
160
246
.PP
161
247
This will copy 1 million 512 byte blocks from the device associated with
162
248
/dev/sg0 (which should have 512 byte blocks) to a file called t.
165
251
.PP
166
252
   dd if=/dev/sda of=t bs=512 count=1000000
167
253
.PP
168
 
although dd's speed may improve if bs was larger and count was suitably
169
 
reduced. Using a raw device to do something similar on a IDE disk:
 
254
although dd's speed may improve if bs was larger and count was
 
255
correspondingly scaled. Using a raw device to do something similar on a
 
256
ATA disk:
170
257
.PP
171
258
   raw /dev/raw/raw1 /dev/hda
172
259
.br
173
 
   sgp_dd if=/dev/raw/raw1 of=t bs=512 count=1M
 
260
   sgp_dd if=/dev/raw/raw1 of=t bs=512 count=1MB
174
261
.PP
175
 
To copy a SCSI disk partition to an IDE disk partition:
 
262
To copy a SCSI disk partition to an ATA disk partition:
176
263
.PP
177
264
   raw /dev/raw/raw2 /dev/hda3
178
265
.br
187
274
geometry (stepping over errors on the source disk):
188
275
.PP
189
276
   sgp_dd if=/dev/sg0 of=/dev/sg1 bs=512 coe=1
 
277
.SH EXIT STATUS
 
278
The exit status of sgp_dd is 0 when it is successful. Otherwise see
 
279
the sg3_utils(8) man page. Since this utility works at a higher level
 
280
than individual commands, and there are 'coe' and 'retries' flags,
 
281
individual SCSI command failures do not necessary cause the process
 
282
to exit.
190
283
.SH AUTHORS
191
284
Written by Doug Gilbert and Peter Allworth.
192
285
.SH "REPORTING BUGS"
193
286
Report bugs to <dgilbert at interlog dot com>.
194
287
.SH COPYRIGHT
195
 
Copyright \(co 2000-2004 Douglas Gilbert
 
288
Copyright \(co 2000-2006 Douglas Gilbert
196
289
.br
197
290
This software is distributed under the GPL version 2. There is NO
198
291
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
199
292
.SH "SEE ALSO"
200
 
A simpler, non-threaded version of this utility called
 
293
A simpler, non-threaded version of this utility but with more
 
294
advanced "continue on error" logic is called
201
295
.B sg_dd
202
 
is in the sg3_utils package. The lmbench package contains
 
296
and is also found in the sg3_utils package. The lmbench package contains
203
297
.B lmdd
204
298
which is also interesting.
205
299
.B raw(8), dd(1)