Dd (command)
Jump to navigation
Jump to search
↑ 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://askubuntu.com/a/227933
↑ https://stackoverflow.com/a/20531600
↑ https://superuser.com/a/470957
dd[1][2] is a command-line utility for Linux and 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]conv=notrunc,noerror[4]. notrunc is only important to prevent truncation when writing into a file. This has no effect on a block device such as sda or sdb[5]
Contents
Examples[edit]
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
status=progress not supported on macOS
- 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)
if=/dev/vda | gzip -1 | ssh your.server.com dd of=/mnt/storage/imagename.img.gz
Activities[edit]
Basic
- Write a 10GB file with random data and review your disk performance:
dd iflag=fullblock if=/dev/urandom of=sample_output_file.txt - Read Linux I/O Performance Tests using dd: https://www.thomas-krenn.com/en/wiki/Linux_I/O_Performance_Tests_using_dd
- /Benchmark disk performance using dd/
Advanced
- Understand iflags, such us fullblock
iflag=fullblockmeaning - Try to interrupt/kill your command:
dd iflag=fullblock if=/dev/urandom of=sample_output_file.txt bs=10G count=1and explain outcome.
Related terms[edit]
See also[edit]
cp,dd,sftp,scp,rsync,casync,mv,fio,ln,docker cp, kubectl cp,minikube cp,multipass transfer,Copy-Item,Xcopy- IO performance:
iotop, iostat, sar -d, fio, nmon, vmstat -d,dd,nmon,stress - PV, pv (pipe viewer), progress (command)
- Benchmarking tools
- file, File system, directory,
touch,mkdir,ls,lntruncate,fallocate,split,stat, inode, File descriptor, superblock, block size (blockdev),fuser,lsof,scrub,chattr, ulimit (nofiles),cp,mv,file (command),mkfifo,chmod
Advertising: