dd
is used to read from an input file stream and to write to an output file stream. It can perform encoding conversions. dd [OPERAND]… dd OPTION
bs=BYTES | Read and write up to BYTES bytes at a time (default: 512); overrides ibs and obs |
cbs=BYTES | Convert BYTES bytes at a time |
conv=CONVS | Convert the file as per the comma separated symbol list |
count=N | Copy only N input blocks |
ibs=BYTES | Read up to BYTES bytes at a time (default: 512) |
if=FILE | Read from FILE instead of stdin, stdout and stderr |
iflag=FLAGS | Read as per the comma separated symbol list |
obs=BYTES | Write BYTES bytes at a time (default: 512) |
of=FILE | Write to FILE instead of stdout |
oflag=FLAGS | Write as per the comma separated symbol list |
seek=N | Skip N obs-sized blocks at start of output |
skip=N | Skip N ibs-sized blocks at start of input |
status=LEVEL | LEVEL detemrmines the amount of information printed to stderr; none suppresses everything but error messages (similar to quiet mode which is turned on with -q in other shell commands), noxfer suppresses the final transfer statistics, progress shows periodic transfer statistics (Compare with pv ) |
N
and BYTES
may be followed by multiplicative suffixes: c | 1, |
w | 2, |
b | 512, |
kB | 1000, |
K , KiB | 1024, |
MB | 1000*1000, |
M , MiB | 1024*1024, |
xM | M, |
GB | 1000*1000*1000, |
G , MiB | 1024*1024*1024 |
T
, P
, E
, Z
, Y
. ascii | From EBCDIC to ASCII |
ebcdic | From ASCII to EBCDIC |
ibm | From ASCII to alternate EBCDIC |
block | Pad newline-terminated records with spaces to cbs-size |
unblock | Replace trailing spaces in cbs-size records with newline |
lcase | Change upper case to lower case |
ucase | Change lower case to upper case |
sparse | Try to seek rather than write all-NUL output blocks |
swab | Swap every pair of input bytes |
sync | Pad every input block with NULs to ibs-size; when used with block or unblock, pad with spaces rather than NULs |
excl | Fail if the output file already exists |
nocreat | Do not create the output file |
notrunc | Do not truncate the output file |
noerror | Continue after read errors |
fdatasync | Physically write output file data before finishing |
fsync | Likewise, but also write metadata |
append | Append mode (makes sense only for output; conv=notrunc suggested) |
direct | Use direct I/O for data |
directory | fail unless a directory |
dsync | Use synchronized I/O for data |
sync | Likewise, but also for metadata |
fullblock | accumulate full blocks of input (iflag only) |
nonblock | Use non-blocking I/O |
noatime | Do not update access time |
nocache | Request to drop cache. See also oflag=sync |
noctty | Do not assign controlling terminal from file |
nofollow | Do not follow symlinks |
count_bytes | Treat count=N as a byte count (iflag only) |
skip_bytes | Treat skip=N as a byte count (iflag only) |
seek_bytes | Treat seek=N as a byte count (oflag only) |
dd
has two options only: --help | Display this help and exit |
--version | Output version information and exit |
$ dd of=1GB if=/dev/random bs=GiB count=1
bs
, the trailing bytes will, as expected, be copied. 123456789 12345 2 * 16 = 32 | 3 * 16 = 48 | 4 * 16 = 64 | 5 * 16 = 80 | 6 * 16 = 96 | 7 * 16 = 112 | 8 * 16 = 128 | 9 * 16 = 144 | 10 * 16 = 160 | 11 * 16 = 176 | 12 * 16 = 192 | 13 * 16 = 208 | 14 * 16 = 224 | 15 * 16 = 240 | 16 * 16 = 256 | 17 * 16 = 272 | 18 * 16 = 288 | 19 * 16 = 304 | 20 * 16 = 320 | 21 * 16 = 336 | 22 * 16 = 352 | 23 * 16 = 368 | 24 * 16 = 384 | 25 * 16 = 400 | 26 * 16 = 416 | 27 * 16 = 432 | 28 * 16 = 448 | 29 * 16 = 464 | 30 * 16 = 480 | 31 * 16 = 496 | 32 * 16 = 512 | abc
dd
: dd if=516.bytes of=out.file bs=256
2+1
records in. The 2
indiciates that 2 blocks of 256 bytes where transferred, the +1
refers to the incomplete (less than 256 byte) final block (of 4 bytes). dd
would have reported 2+0 records in
. /dev/sda
) of a laptop. mount -l | grep sda
mount -t ntfs /dev/sdb1 /mnt
mkdir /mnt/Backups/T420
dd if=/dev/sda bs=1M | gzip > /mnt/Backups/T420/backup.sda.gz
gunzip -c /mnt/Backups/T420/backup.sda.gz | dd of=/dev/sda bs=1M
USR1
signal to a running dd
process makes it print I/O statistics to standard error and then resume copying. truncate