dd
Quick Reference
Command Name:
dd
Category:
disk utilities
Platform:
Linux/Unix
Basic Usage:
Common Use Cases
- 1
Create disk images
Make exact copies of disks or partitions for backup or cloning
- 2
Convert data formats
Transform data between different formats while copying
- 3
Backup & restore
Backup MBR, partition tables, and other critical disk areas
- 4
Disk benchmarking
Test read/write performance of storage devices
Syntax
dd [OPERAND]...
Options
Operand | Description |
---|---|
if=FILE | Read from FILE instead of stdin |
of=FILE | Write to FILE instead of stdout |
bs=BYTES | Read and write up to BYTES bytes at a time (default: 512); overrides ibs and obs |
ibs=BYTES | Read up to BYTES bytes at a time |
obs=BYTES | Write BYTES bytes at a time |
count=N | Copy only N input blocks |
skip=N | Skip N input blocks before starting to copy |
seek=N | Skip N output blocks before starting to write |
conv=CONVS | Convert the file according to the comma-separated list of conversions |
status=LEVEL | The level of information to print (none, noxfer, progress) |
iflag=FLAGS | Read as per the comma-separated list of flags |
oflag=FLAGS | Write as per the comma-separated list of flags |
Conversion Options (for conv=):
Option | Description |
---|---|
ascii | Convert EBCDIC to ASCII |
ebcdic | Convert ASCII to EBCDIC |
lcase | Change uppercase to lowercase |
ucase | Change lowercase to uppercase |
sparse | Try to seek rather than write all-NUL output blocks |
sync | Pad every input block with NULs to ibs size |
fdatasync | Physically write output file data before finishing |
fsync | Physically write output file data and metadata before finishing |
noerror | Continue after read errors |
notrunc | Do not truncate the output file |
Examples
How to Use These Examples
The examples below show common ways to use the dd
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
dd if=/dev/zero of=file.txt count=100 bs=1k
Create a 100KB file filled with zeros.
dd if=/dev/sda of=disk.img
Create an exact image of the /dev/sda disk.
dd if=source.file of=dest.file bs=1M
Copy source.file to dest.file using 1MB blocks.
Advanced Examples:
dd if=/dev/sda of=/dev/sdb bs=4M status=progress
Clone one disk to another with progress indication.
dd if=/dev/urandom of=random.bin bs=1M count=10
Create a 10MB file filled with random data.
dd if=file.img of=/dev/sdc bs=4M conv=fdatasync status=progress
Write an image file to a USB device, ensuring data is physically written.