dd Options

Copy a file , according to [OPERAND] Transform and format

(1). OPERAND Parameters

explain 1:dd The only options are ’--help’ and ’--version’, That is, help and version information . And the following are [ Operands ], Not options .

explain 2: Read is input , Writing is output

explain 3: Don't specify if, Read from standard input by default . If you don't specify of, Write to standard output by default

bs=BYTES Set both read and write ( Input ibs Output obs) The block size of is BYTES Bytes , See this chapter for details (4). The unit of measurement that block size can use

cbs=BYTES One conversion BYTES Bytes , That is, specify the conversion buffer size

conv=CONVERSION[,CONVERSION] Convert the file with the specified parameters

count=N Just copy N Block , The size of the block is equal to ibs Number of bytes specified

ibs=BYTES Read once BYTES Bytes , That is, to specify a block size of BYTES Bytes ( Default 512)

if=FILE Read from file instead of standard input , That is, specify the source file

iflag=FLAG[,FLAG] Use FLAG Input method specified by parameter

obs=BYTES Write once BYTES Bytes , That is, specify a fast size of BYTES Bytes ( Default 512)

of=FILE Write to file instead of standard output , I.e. designated purpose document

oflag=FLAG[,FLAG] Use FLAG The output mode specified by the parameter

seek=BLOCKS Skip from the beginning of the output file BLOCKS And then start copying ( look out ibs and obs Dissimilarity )

skip=BLOCKS Skip from the beginning of the input file BLOCKS Input blocks and start copying ( look out ibs and obs Dissimilarity )

status=WHICH Used to control dd The output of the program . Respectively noxfer,none and progress, The default is progress.none Don't output any relevant information , The error message is output normally .noxfer Don't output the final statistics .progress Output all the information .

(2).CONVERSION Parameters

ascii from ebcdic Code conversion to ascii code

ebcdic from ascii Code conversion to ebcdic code

ibm from ascii Code to replace ebcdic code

block For each line in the input, the output cbs Bytes , Replace input line breaks with spaces , Fill in the blanks if necessary

unblock Delete cbs The trailing space of a block of size , And add a line break

lcase Convert uppercase characters to lowercase characters

nocreat Do not create output file , The output file must already exist

excl If the output file already exists, it fails ;dd The command must create the file itself

notrunc Don't truncate the output file ( Don't shorten the file length to 0)

ucase Convert lowercase characters to uppercase characters

sparse Try to find instead of writing empty (NUL) Output block . In a file system that supports sparse files , When extending the output file , This creates a sparse output .

swab Swap each pair of bytes , When odd, only the last byte is copied

noerror Continue after reading data error

sync Leave each input block blank (NUL) Fill to ibs size , If it's with the day block or unblock Use , Instead of empty space (NUL) fill

fdatasync Write the output file data to disk before the end

fsync Similar to above , But metadata is also written in

(3).FLAG Parameters

append Append mode . Copy the data to the end of the target file , At the same time... Should be set conv=notrunc. Otherwise, the file will be cleared before it is copied .

cio Use concurrency I/O Access mode , This mode uses direct I/O. And delete POSIX requirement , Will all I/O Serialize to the same file . stay cio The file cannot be opened in mode , Open a standard file at the same time ( This sentence may be wrong , original text :A file cannot be opened at cio mode,and with a standard open in the same time.).

direct Use direct I/O Access mode , Avoid buffer caching ( Do not cache file data in memory )

directory Just copy the folder , Because many systems don't support I/O operation , So it's not very practical .

dsync Use synchronization I/O Mode read and write data . Every time I write , Force a physical write ( write in / Save to disk )

sync Both data and metadata use synchronization I/O Pattern .

fullblock It doesn't return until a block is filled

nonblack Use non blocking I/O

noatime Do not change the access time of the file

noctty incorrect dd Use the specified file as the control terminal

nofollow Don't follow symbolic links

nolinks If there are multiple hard links, it fails ( Hard links and soft links are symbolic links , Check for yourself , It's a little complicated. )

binary Use binary I/O

text Use text I/0

count_bytes take count The unit of is set to byte , Not a block

(4). The unit of measurement that block size can use

Unit size


byte (1B)


byte (2B)


block (512B)


kilobytes (1024B)


Megabytes (1024KB)


Gigabyte (1024MB)


(5). example

according to /dev/zero Empty file to create a 50M Empty file









[[email protected] ~]$ dd if=/dev/zero of=1.txt bs=M count=50

Recorded 50+0 Read in of

Recorded 50+0 Write

52428800 byte (52 MB) Copied ,0.0508383 second ,1.0 GB/ second

[[email protected] ~]$ ll -h 1.txt

-rw-rw-r--. 1 xf xf 50M 2 month   26 10:17 1.txt

[[email protected] ~]$ cat 1.txt

[[email protected] ~]$

Be careful : It can also be used for full backup .dd if=/dev/sda of=/dev/sdb( Including super block and so on )