]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - bin/dd/dd.1
kern: cpuset: allow jails to modify child jails' roots
[FreeBSD/FreeBSD.git] / bin / dd / dd.1
1 .\"-
2 .\" Copyright (c) 1990, 1993
3 .\"     The Regents of the University of California.  All rights reserved.
4 .\"
5 .\" This code is derived from software contributed to Berkeley by
6 .\" Keith Muller of the University of California, San Diego.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\" 3. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)dd.1        8.2 (Berkeley) 1/13/94
33 .\" $FreeBSD$
34 .\"
35 .Dd June 4, 2020
36 .Dt DD 1
37 .Os
38 .Sh NAME
39 .Nm dd
40 .Nd convert and copy a file
41 .Sh SYNOPSIS
42 .Nm
43 .Op Ar operands ...
44 .Sh DESCRIPTION
45 The
46 .Nm
47 utility copies the standard input to the standard output.
48 Input data is read and written in 512-byte blocks.
49 If input reads are short, input from multiple reads are aggregated
50 to form the output block.
51 When finished,
52 .Nm
53 displays the number of complete and partial input and output blocks
54 and truncated input records to the standard error output.
55 .Pp
56 The following operands are available:
57 .Bl -tag -width "of=file"
58 .It Cm bs Ns = Ns Ar n
59 Set both input and output block size to
60 .Ar n
61 bytes, superseding the
62 .Cm ibs
63 and
64 .Cm obs
65 operands.
66 If no conversion values other than
67 .Cm noerror ,
68 .Cm notrunc
69 or
70 .Cm sync
71 are specified, then each input block is copied to the output as a
72 single block without any aggregation of short blocks.
73 .It Cm cbs Ns = Ns Ar n
74 Set the conversion record size to
75 .Ar n
76 bytes.
77 The conversion record size is required by the record oriented conversion
78 values.
79 .It Cm count Ns = Ns Ar n
80 Copy only
81 .Ar n
82 input blocks.
83 .It Cm files Ns = Ns Ar n
84 Copy
85 .Ar n
86 input files before terminating.
87 This operand is only applicable when the input device is a tape.
88 .It Cm fillchar Ns = Ns Ar c
89 When padding a block in conversion mode or due to use of
90 .Cm noerror
91 and
92 .Cm sync
93 modes, fill with the specified
94 .Tn ASCII
95 character, rather than using a space or
96 .Dv NUL .
97 .It Cm ibs Ns = Ns Ar n
98 Set the input block size to
99 .Ar n
100 bytes instead of the default 512.
101 .It Cm if Ns = Ns Ar file
102 Read input from
103 .Ar file
104 instead of the standard input.
105 .It Cm iflag Ns = Ns Ar value Ns Op , Ns Ar value ...
106 Where
107 .Cm value
108 is one of the symbols from the following list.
109 .Bl -tag -width "fullblock"
110 .It Cm fullblock
111 Reading from the input file may not obtain a full block.
112 When a read returns short, continue reading to fill the block.
113 Without this flag,
114 .Cm count
115 limits the number of times
116 .Xr read 2
117 is called on the input rather than the number of blocks copied in full.
118 May not be combined with
119 .Cm conv=sync .
120 .It Cm direct
121 Set the O_DIRECT flag on the input file to make reads bypass any local caching.
122 .El
123 .It Cm iseek Ns = Ns Ar n
124 Seek on the input file
125 .Ar n
126 blocks.
127 This is synonymous with
128 .Cm skip Ns = Ns Ar n .
129 .It Cm obs Ns = Ns Ar n
130 Set the output block size to
131 .Ar n
132 bytes instead of the default 512.
133 .It Cm of Ns = Ns Ar file
134 Write output to
135 .Ar file
136 instead of the standard output.
137 Any regular output file is truncated unless the
138 .Cm notrunc
139 conversion value is specified.
140 If an initial portion of the output file is seeked past (see the
141 .Cm oseek
142 operand),
143 the output file is truncated at that point.
144 .It Cm oflag Ns = Ns Ar value Ns Op , Ns Ar value ...
145 Where
146 .Cm value
147 is one of the symbols from the following list.
148 .Bl -tag -width "direct"
149 .It Cm fsync
150 Set the O_FSYNC flag on the output file to make writes synchronous.
151 .It Cm sync
152 Set the O_SYNC flag on the output file to make writes synchronous.
153 This is synonymous with the
154 .Cm fsync
155 value.
156 .It Cm direct
157 Set the O_DIRECT flag on the output file to make writes bypass any local caching.
158 .El
159 .It Cm oseek Ns = Ns Ar n
160 Seek on the output file
161 .Ar n
162 blocks.
163 This is synonymous with
164 .Cm seek Ns = Ns Ar n .
165 .It Cm seek Ns = Ns Ar n
166 Seek
167 .Ar n
168 blocks from the beginning of the output before copying.
169 On non-tape devices, an
170 .Xr lseek 2
171 operation is used.
172 Otherwise, existing blocks are read and the data discarded.
173 If the user does not have read permission for the tape, it is positioned
174 using the tape
175 .Xr ioctl 2
176 function calls.
177 If the seek operation is past the end of file, space from the current
178 end of file to the specified offset is filled with blocks of
179 .Dv NUL
180 bytes.
181 .It Cm skip Ns = Ns Ar n
182 Skip
183 .Ar n
184 blocks from the beginning of the input before copying.
185 On input which supports seeks, an
186 .Xr lseek 2
187 operation is used.
188 Otherwise, input data is read and discarded.
189 For pipes, the correct number of bytes is read.
190 For all other devices, the correct number of blocks is read without
191 distinguishing between a partial or complete block being read.
192 .It Cm speed Ns = Ns Ar n
193 Limit the copying speed to
194 .Ar n
195 bytes per second.
196 .It Cm status Ns = Ns Ar value
197 Where
198 .Cm value
199 is one of the symbols from the following list.
200 .Bl -tag -width "progress"
201 .It Cm noxfer
202 Do not print the transfer statistics as the last line of status output.
203 .It Cm none
204 Do not print the status output.
205 Error messages are shown; informational messages are not.
206 .It Cm progress
207 Print basic transfer statistics once per second.
208 .El
209 .It Cm conv Ns = Ns Ar value Ns Op , Ns Ar value ...
210 Where
211 .Cm value
212 is one of the symbols from the following list.
213 .Bl -tag -width "unblock"
214 .It Cm ascii , oldascii
215 The same as the
216 .Cm unblock
217 value except that characters are translated from
218 .Tn EBCDIC
219 to
220 .Tn ASCII
221 before the
222 records are converted.
223 (These values imply
224 .Cm unblock
225 if the operand
226 .Cm cbs
227 is also specified.)
228 There are two conversion maps for
229 .Tn ASCII .
230 The value
231 .Cm ascii
232 specifies the recommended one which is compatible with
233 .At V .
234 The value
235 .Cm oldascii
236 specifies the one used in historic
237 .At
238 and
239 .No pre- Ns Bx 4.3 reno
240 systems.
241 .It Cm block
242 Treats the input as a sequence of newline or end-of-file terminated variable
243 length records independent of input and output block boundaries.
244 Any trailing newline character is discarded.
245 Each input record is converted to a fixed length output record where the
246 length is specified by the
247 .Cm cbs
248 operand.
249 Input records shorter than the conversion record size are padded with spaces.
250 Input records longer than the conversion record size are truncated.
251 The number of truncated input records, if any, are reported to the standard
252 error output at the completion of the copy.
253 .It Cm ebcdic , ibm , oldebcdic , oldibm
254 The same as the
255 .Cm block
256 value except that characters are translated from
257 .Tn ASCII
258 to
259 .Tn EBCDIC
260 after the
261 records are converted.
262 (These values imply
263 .Cm block
264 if the operand
265 .Cm cbs
266 is also specified.)
267 There are four conversion maps for
268 .Tn EBCDIC .
269 The value
270 .Cm ebcdic
271 specifies the recommended one which is compatible with
272 .At V .
273 The value
274 .Cm ibm
275 is a slightly different mapping, which is compatible with the
276 .At V
277 .Cm ibm
278 value.
279 The values
280 .Cm oldebcdic
281 and
282 .Cm oldibm
283 are maps used in historic
284 .At
285 and
286 .No pre- Ns Bx 4.3 reno
287 systems.
288 .It Cm fdatasync
289 Perform an
290 .Xr fdatasync 2
291 on the output file before closing it.
292 .It Cm fsync
293 Perform an
294 .Xr fsync 2
295 on the output file before closing it.
296 .It Cm lcase
297 Transform uppercase characters into lowercase characters.
298 .It Cm pareven , parnone , parodd , parset
299 Output data with the specified parity.
300 The parity bit on input is stripped unless
301 .Tn EBCDIC
302 to
303 .Tn ASCII
304 conversions is also specified.
305 .It Cm noerror
306 Do not stop processing on an input error.
307 When an input error occurs, a diagnostic message followed by the current
308 input and output block counts will be written to the standard error output
309 in the same format as the standard completion message.
310 If the
311 .Cm sync
312 conversion is also specified, any missing input data will be replaced
313 with
314 .Dv NUL
315 bytes (or with spaces if a block oriented conversion value was
316 specified) and processed as a normal input buffer.
317 If the
318 .Cm fillchar
319 option is specified, the fill character provided on the command line
320 will override
321 the automatic selection of the fill character.
322 If the
323 .Cm sync
324 conversion is not specified, the input block is omitted from the output.
325 On input files which are not tapes or pipes, the file offset
326 will be positioned past the block in which the error occurred using
327 .Xr lseek 2 .
328 .It Cm notrunc
329 Do not truncate the output file.
330 This will preserve any blocks in the output file not explicitly written
331 by
332 .Nm .
333 The
334 .Cm notrunc
335 value is not supported for tapes.
336 .It Cm osync
337 Pad the final output block to the full output block size.
338 If the input file is not a multiple of the output block size
339 after conversion, this conversion forces the final output block
340 to be the same size as preceding blocks for use on devices that require
341 regularly sized blocks to be written.
342 This option is incompatible with use of the
343 .Cm bs Ns = Ns Ar n
344 block size specification.
345 .It Cm sparse
346 If one or more output blocks would consist solely of
347 .Dv NUL
348 bytes, try to seek the output file by the required space instead of
349 filling them with
350 .Dv NUL Ns s ,
351 resulting in a sparse file.
352 .It Cm swab
353 Swap every pair of input bytes.
354 If an input buffer has an odd number of bytes, the last byte will be
355 ignored during swapping.
356 .It Cm sync
357 Pad every input block to the input buffer size.
358 Spaces are used for pad bytes if a block oriented conversion value is
359 specified, otherwise
360 .Dv NUL
361 bytes are used.
362 .It Cm ucase
363 Transform lowercase characters into uppercase characters.
364 .It Cm unblock
365 Treats the input as a sequence of fixed length records independent of input
366 and output block boundaries.
367 The length of the input records is specified by the
368 .Cm cbs
369 operand.
370 Any trailing space characters are discarded and a newline character is
371 appended.
372 .El
373 .El
374 .Pp
375 Where sizes or speed are specified, a decimal, octal, or hexadecimal number of
376 bytes is expected.
377 If the number ends with a
378 .Dq Li b ,
379 .Dq Li k ,
380 .Dq Li m ,
381 .Dq Li g ,
382 .Dq Li t ,
383 .Dq Li p ,
384 or
385 .Dq Li w ,
386 the
387 number is multiplied by 512, 1024 (1K), 1048576 (1M), 1073741824 (1G),
388 1099511627776 (1T), 1125899906842624 (1P)
389 or the number of bytes in an integer, respectively.
390 Two or more numbers may be separated by an
391 .Dq Li x
392 to indicate a product.
393 .Pp
394 When finished,
395 .Nm
396 displays the number of complete and partial input and output blocks,
397 truncated input records and odd-length byte-swapping blocks to the
398 standard error output.
399 A partial input block is one where less than the input block size
400 was read.
401 A partial output block is one where less than the output block size
402 was written.
403 Partial output blocks to tape devices are considered fatal errors.
404 Otherwise, the rest of the block will be written.
405 Partial output blocks to character devices will produce a warning message.
406 A truncated input block is one where a variable length record oriented
407 conversion value was specified and the input line was too long to
408 fit in the conversion record or was not newline terminated.
409 .Pp
410 Normally, data resulting from input or conversion or both are aggregated
411 into output blocks of the specified size.
412 After the end of input is reached, any remaining output is written as
413 a block.
414 This means that the final output block may be shorter than the output
415 block size.
416 .Pp
417 If
418 .Nm
419 receives a
420 .Dv SIGINFO
421 (see the
422 .Cm status
423 argument for
424 .Xr stty 1 )
425 signal, the current input and output block counts will
426 be written to the standard error output
427 in the same format as the standard completion message.
428 If
429 .Nm
430 receives a
431 .Dv SIGINT
432 signal, the current input and output block counts will
433 be written to the standard error output
434 in the same format as the standard completion message and
435 .Nm
436 will exit.
437 .Sh EXIT STATUS
438 .Ex -std
439 .Sh EXAMPLES
440 Check that a disk drive contains no bad blocks:
441 .Pp
442 .Dl "dd if=/dev/ada0 of=/dev/null bs=1m"
443 .Pp
444 Do a refresh of a disk drive, in order to prevent presently
445 recoverable read errors from progressing into unrecoverable read errors:
446 .Pp
447 .Dl "dd if=/dev/ada0 of=/dev/ada0 bs=1m"
448 .Pp
449 Remove parity bit from a file:
450 .Pp
451 .Dl "dd if=file conv=parnone of=file.txt"
452 .Pp
453 Check for (even) parity errors on a file:
454 .Pp
455 .Dl "dd if=file conv=pareven | cmp -x - file"
456 .Pp
457 To create an image of a Mode-1 CD-ROM, which is a commonly used format
458 for data CD-ROM disks, use a block size of 2048 bytes:
459 .Pp
460 .Dl "dd if=/dev/cd0 of=filename.iso bs=2048"
461 .Pp
462 Write a filesystem image to a memory stick, padding the end with zeros,
463 if necessary, to a 1MiB boundary:
464 .Pp
465 .Dl "dd if=memstick.img of=/dev/da0 bs=1m conv=noerror,sync"
466 .Sh SEE ALSO
467 .Xr cp 1 ,
468 .Xr mt 1 ,
469 .Xr recoverdisk 1 ,
470 .Xr tr 1 ,
471 .Xr geom 4 ,
472 .Xr trim 8
473 .Sh STANDARDS
474 The
475 .Nm
476 utility is expected to be a superset of the
477 .St -p1003.2
478 standard.
479 The
480 .Cm files
481 and
482 .Cm status
483 operands and the
484 .Cm ascii ,
485 .Cm ebcdic ,
486 .Cm ibm ,
487 .Cm oldascii ,
488 .Cm oldebcdic
489 and
490 .Cm oldibm
491 values are extensions to the
492 .Tn POSIX
493 standard.
494 .Sh HISTORY
495 A
496 .Nm
497 command appeared in
498 .At v5 .
499 .Sh BUGS
500 Protection mechanisms in the
501 .Xr geom 4
502 subsystem might prevent the super-user from writing blocks to a disk.
503 Instructions for temporarily disabling these protection mechanisms can be
504 found in the
505 .Xr geom 4
506 man page.