Dd: Difference between revisions
No edit summary |
|||
| Line 2: | Line 2: | ||
== Ignoring Errors == | == Ignoring Errors == | ||
To make dd ignore errors, such as when cloning a failing drive, add the {{code|conv=noerror}} option. | To make dd ignore errors, such as when cloning a failing drive, add the {{code|1=conv=noerror}} option. | ||
The {{code|conv}} option specifies the type of conversion that dd needs to do to the input data. In this case, specifying {{code|noerror}} 'converts' errors from the input medium into nulls in the output medium. | The {{code|conv}} option specifies the type of conversion that dd needs to do to the input data. In this case, specifying {{code|noerror}} 'converts' errors from the input medium into nulls in the output medium. | ||
Revision as of 17:21, 10 April 2017
Ignoring Errors
To make dd ignore errors, such as when cloning a failing drive, add the conv=noerror option.
The conv option specifies the type of conversion that dd needs to do to the input data. In this case, specifying noerror 'converts' errors from the input medium into nulls in the output medium.
dd conv=noerror,sync if=/dev/sda1 > /mnt/rescue.img
There are lots of other conversions that dd can handle such as case conversion, EBCDIC, byte swapping, and more. (see https://www.gnu.org/software/coreutils/manual/html_node/dd-invocation.html#dd-invocation)
Manipulating by Bytes
Use the iflag=skip_bytes,count_bytes flags when working with data in bytes. The bs block size value will be ignored when these flags are used.
Question: When using the count_bytes flag, is this equivalent to bs=1? (It looks like it...)
Offset / Skipping Bytes
If you need to extract a chunk of data, say everything past byte 199232000 from a file:
$ dd if=blah.dat iflag=skip_bytes,count_bytes skip=199232000 | xxd
To get only 200 bytes of data instead:
$ dd if=blah.dat iflag=skip_bytes,count_bytes skip=199232000 count=200 | xxd
Or 2 kilobytes (2048 bytes):
$ dd if=blah.dat iflag=skip_bytes,count_bytes skip=199232000 count=2k | xxd