Difference between revisions of "Dd (command)"

From wikieduonline
Jump to navigation Jump to search
Line 50: Line 50:
  
 
[[Category:Linux]]
 
[[Category:Linux]]
 +
[[Category:Linux command]]

Revision as of 16:05, 8 December 2019

dd[1][2] is a command-line utility for Unix-like operating systems used to copy or create files on block devices (HDD).

Warning: write operations will not ask for confirmation if you are overwriting an existing file.

Options:

oflag=sync[3]
iflag=[fullblock|nocache]


Examples

  • Write a 10G file with random data: 10 G (bs=10G count=1), with random data (/dev/urandom)[4]:

dd iflag=fullblock if=/dev/urandom of=sample_output_file.txt bs=10G count=1 status=progress

 10737418240 bytes (11 GB, 10 GiB) copied, 66 s, 162 MB/s
 1+0 records in
 1+0 records out
 10737418240 bytes (11 GB, 10 GiB) copied, 66.4367 s, 162 MB/s
  • Write a 10G with zeroes: 10 G (bs=10G count=1), file with "zeroes" (/dev/zero):

dd iflag=fullblock if=/dev/zero of=sample_output_file.txt bs=10G count=1 status=progress

 10737418240 bytes (11 GB, 10 GiB) copied, 66 s, 162 MB/s
 1+0 records in
 1+0 records out
 10737418240 bytes (11 GB, 10 GiB) copied, 66.4367 s, 162 MB/s
dd iflag=fullblock if=/dev/zero of=sample_output_file.txt bs=10G count=1
dd: memory exhausted by input buffer of size 10737418240 bytes (10 GiB)

Activities

Basic

  1. Write a 10GB file with random data and review your disk performance: dd iflag=fullblock if=/dev/urandom of=sample_output_file.txt
  2. Read Linux I/O Performance Tests using dd: https://www.thomas-krenn.com/en/wiki/Linux_I/O_Performance_Tests_using_dd
  3. /Benchmark disk performance using dd/

Advanced

  1. Understand iflags, such us fullblock iflag=fullblock meaning
  2. Try to interrupt/kill your command: dd iflag=fullblock if=/dev/urandom of=sample_output_file.txt bs=10G count=1 and explain outcome.

See also

  • http://man7.org/linux/man-pages/man1/dd.1.html
  • https://www.gnu.org/software/coreutils/manual/html_node/dd-invocation.html#dd-invocation
  • https://www.gnu.org/software/coreutils/manual/html_node/dd-invocation.html#dd-invocation
  • https://superuser.com/a/470957
  • Advertising: